PageRenderTime 68ms CodeModel.GetById 15ms app.highlight 28ms RepoModel.GetById 20ms app.codeStats 1ms

/lib/Teto/Track/NicoVideo/nm.pm

http://github.com/motemen/Teto
Perl | 25 lines | 19 code | 6 blank | 0 comment | 0 complexity | 5d2dd3b2fb3b2d9b76ee8dd582b91074 MD5 | raw file
 1package Teto::Track::NicoVideo::nm;
 2use Mouse;
 3
 4extends 'Teto::Track::NicoVideo';
 5
 6override buildargs_from_url => sub {
 7    my ($class, $url) = @_;
 8    $url =~ m<^http://(?:\w+\.nicovideo\.jp/watch|nico\.ms)/(nm\d+)> or return undef;
 9    return { video_id => $1 };
10};
11
12override _play => sub {
13    my $self = shift;
14    my $media_url = $self->media_url or return;
15    my $flv = $self->download_temporary($media_url => '.flv');
16    my $mp3 = $self->temporary_filename('.mp3');
17    $self->run_command([ 'swfextract', $flv, '-m', '-o', $mp3 ]);
18    $self->send_file_to_buffer($mp3);
19};
20
21__PACKAGE__->meta->make_immutable;
22
23no Mouse;
24
251;