Created
January 19, 2015 20:22
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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