Created
January 2, 2012 16:27
-
-
Save wata/1551301 to your computer and use it in GitHub Desktop.
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
use strict; | |
use warnings; | |
use 5.010; | |
use utf8; | |
use Time::Piece; | |
use Furl; | |
use JSON; | |
use Term::ReadKey qw/GetTerminalSize/; | |
my $id = '101763292'; # zeebratv | |
my $ua = Furl->new; | |
my $p = 0; | |
&main while 1; | |
# ------------------------------------------------------------------------- | |
sub width { (GetTerminalSize)[0] } | |
sub main { | |
$p++; | |
my $u = 'http://api.twitter.com/1/statuses/user_timeline.json?page=' . $p . '&user_id=' . $id; | |
my $content = do { | |
my $res = $ua->get($u); | |
die $res->status_line unless $res->is_success; | |
$res->content; | |
}; | |
foreach my $tweet (@{ decode_json($content) }) { | |
if ($tweet->{text} =~ /♬WZBR Now Playing: ([^by]+) by (.+)/) { | |
my $title = $1; | |
my $artist = $2; | |
my $date = localtime->strptime($tweet->{created_at}, '%a %b %d %H:%M:%S +0000 %Y') + 32400; | |
say "-" x width; | |
say "title : " . $title; | |
say "artist: " . $artist; | |
say "date : " . join ' ', $date->time, $date->date; | |
} | |
} | |
<STDIN>; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment