Skip to content

Instantly share code, notes, and snippets.

@miyagawa
Created January 19, 2015 20:22
Show Gist options
  • Save miyagawa/b771e9a80b7044958dc4 to your computer and use it in GitHub Desktop.
Save miyagawa/b771e9a80b7044958dc4 to your computer and use it in GitHub Desktop.
Post an audio link to Tumblr to generate a podcast with links (go to the URL /podcast on tumblr)
#!/usr/bin/env perl
use strict;
use Web::Query;
use WWW::Tumblr;
use YAML;
my $auth = YAML::LoadFile("$ENV{HOME}/.tumblr.yml"); # Grab them from API console
my $tumblr = WWW::Tumblr->new(%$auth);
my $link = shift @ARGV or die "Usage: pcast URL\n";
my $wq = Web::Query->new($link);
my $title = $wq->find("title")->first->text;
my $enclosure = $wq->find(\'//a[contains(@href, ".mp3")]')->first->attr('href')
or die "Could not find mp3 download from $link\n";
my $blog = $tumblr->blog("YOURBLOG.tumblr.com");
my $post = $blog->post(
type => "audio",
caption => $title,
external_url => $enclosure,
);
warn $post->{id};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment