Managing a tumblr posts-queue locally

For a change, today I won’t describe how I did something but how I did not.

I had I mind to use tumblr with a daily automated post of a picture. I devised it would be nice if a daily cronjob on my local server was updating a git directory and then post the first image in the queue.

First, I found out that tumblr refuses to handle mail sent directly by mutt and the local server smtp. So I then tried having mutt sending the mail using gmail authenticated smtp. I did not work either. But it works fine to any other recipient. And it works if directly sent with gmail web interface. We’ve made it incredibly easy to post from your desktop or mobile phone. Just send an email to the custom email address for the blog you’d like to publish to they claimed. Go figure, that probably something they implied by the confusing sentence Send posts directly to your mobile posting email address. You cannot email another email address and then forward the email from there. I understand spam is an issue they have to care about, but how comes that even gmail authentication isn’t proof enough of goodwill?

Anyway I ended up with a non working script for the simple task of sending a mail.

Update, May 21st:

Today, as the queue mecanism of the website was broken, I googled around and found the perl module WWW::Tumblr wrote by David Moreno Damog using the Tumblr API (which I was reluctant to use at first, because it’s unclear how stable such API can stay over time) and wrote another script using this module that works like a charm. It requires a ~/.tumblrrc file (defining email= and password=) and a git-managed directory with subdirs queue/ and over/.

I posted a RFP WWW::Tumblr on Debian.

It upload files in alphabetical order. But you can always run something like the following to randomize it:

cd queue && for i in *; do let cut_start=${#i}-19 cut_end=${#i}-4 && if (($cut_start < 1)); then cut_start=1; fi && mv $i `mktemp --dry-run --tmpdir=. -t XXXXXXX`-`basename $i ${i%%.*} | cut -c $cut_start-$cut_end`.`echo ${i##*.} | tr A-Z a-z`; done