07/12/14 03:20:01 jWEjvsMQ
質問です。
Usteramで録画したflvをダウンロードしたくて、
URLリンク(unknownplace.org)を参考に以下のソースを実行しました。
#!/usr/bin/env perl
use strict;
use warnings;
use AMF::Perl;
use LWP::UserAgent;
my $cid = shift || '5Fq8cQp9eHsEEknbQ22OOZniqS2xUiuz';
my $amf = AMF::Perl::Util::Object->new;
$amf->addBody('client.watch_video', '/1', { cid => $cid });
my $outputstream = AMF::Perl::IO::OutputStream->new;
my $serializer = AMF::Perl::IO::Serializer->new($outputstream, 'utf-8');
$serializer->serialize($amf);
my $amfdata = $outputstream->flush;
$amfdata =~ s/\xff\xff\xff\xff/\0\0\0\x31\x0a\0\0\0\x01/;
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new( POST => 'URLリンク(gw.ustream.tv)' );
$req->content( $output );
$req->content_type('application/x-amf');
$req->content_length( length $amfdata );
my $res = $ua->request($req);
my $deserializer = AMF::Perl::IO::Deserializer->new(AMF::Perl::IO::InputStream->new($res->content), 'utf-8');
use YAML;
print Dump $deserializer->getObject->getBodyAt(0)->{value};