Created
September 28, 2010 13:41
-
-
Save marcusramberg/601006 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package Startsiden::TVGuide::App::Command::import_queue; | |
use Moose; | |
extends qw(MooseX::App::Cmd::Command); | |
with 'Startsiden::TVGuide::Meta::Config'; | |
with 'Startsiden::TVGuide::Meta::RuntimeLoader' => { | |
deps => [qw/ | |
TVDB::API | |
/], | |
}; | |
with 'Startsiden::TVGuide::Meta::Entity'; | |
use Data::Dumper; | |
has 'picture_dir' => ( | |
is => 'rw', | |
isa => 'Str', | |
required => 1, | |
documentation => 'Directory to download images to.', | |
); | |
use MooseX::Daemonize::Pid::File; | |
sub execute { | |
my ($self)=@_; | |
my $api=TVDB::API::new('0DD9BD772F91237B','no'); | |
$api->setBannerPath($self->picture_dir); | |
my $pid=MooseX::Daemonize::Pid::File->new(file=>'/tmp/import_queue.pid'); | |
if($pid->is_running) { | |
warn "import_queue Job already running, bailing out\n"; | |
return; | |
} | |
$pid->write; | |
my @series= $self->entity->query({TYPE=>'Entity::Series'})->all; | |
foreach my $serie (@series) { | |
die Dumper($api->getSeriesBanners($serie->name)); | |
my %banners=$api->getSeriesBanner($serie->name); | |
foreach my $banner (keys %banners) { | |
warn "Fetching $banner"; | |
sleep 5; | |
$api->getBanner($banner); | |
} | |
} | |
$pid->remove; | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment