Changeset 28301
- Timestamp:
- 01/12/09 00:15:27 (14 months ago)
- Location:
- lang/perl/WWW-Tube8/trunk
- Files:
-
- 5 modified
-
Build.PL (modified) (1 diff)
-
Changes (modified) (1 diff)
-
META.yml (modified) (3 diffs)
-
lib/WWW/Tube8.pm (modified) (5 diffs)
-
t/01.basic.t (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/WWW-Tube8/trunk/Build.PL
r28249 r28301 9 9 dist_version_from => 'lib/WWW/Tube8.pm', 10 10 requires => { 11 'Test::More' => 0, 12 'Carp' => 0, 13 'LWP::UserAgent' => 0, 11 'Test::More' => 0, 12 'Carp' => 0, 13 'LWP::UserAgent' => 0, 14 'Class::Accessor' => 0, 14 15 }, 15 16 add_to_cleanup => [ 'WWW-Tube8-*' ], -
lang/perl/WWW-Tube8/trunk/Changes
r28249 r28301 1 1 Revision history for WWW-Tube8 2 3 0.0.2 Mon Jan 12 00:05:05 2009 4 get more info. and add tests. 2 5 3 6 0.0.1 Sat Jan 10 12:34:56 2009 -
lang/perl/WWW-Tube8/trunk/META.yml
r28249 r28301 1 1 --- 2 2 name: WWW-Tube8 3 version: 0.0. 13 version: 0.0.2 4 4 author: 5 5 - 'Dai Okabayashi <bayashi@cpan.org>' … … 10 10 requires: 11 11 Carp: 0 12 Class::Accessor: 0 12 13 LWP::UserAgent: 0 13 14 Test::More: 0 … … 15 16 WWW::Tube8: 16 17 file: lib/WWW/Tube8.pm 17 version: 0.0. 118 version: 0.0.2 18 19 generated_by: Module::Build version 0.3 19 20 meta-spec: -
lang/perl/WWW-Tube8/trunk/lib/WWW/Tube8.pm
r28249 r28301 5 5 use Carp qw( croak ); 6 6 7 use version; our $VERSION = qv('0.0. 1');7 use version; our $VERSION = qv('0.0.2'); 8 8 9 9 use LWP::UserAgent; 10 11 use base qw(Class::Accessor); 12 __PACKAGE__->mk_accessors( 13 qw( flv thumb get_3gp url id title title_inurl category category_url duration ) 14 ); 10 15 11 16 sub new { … … 19 24 20 25 croak "url is required" unless $self->{url}; 21 croak "url is not tube8" if $self->{url} !~ /^http:\/\/www\.tube8\.com\//; 22 26 croak "url is wrong (perhaps not movie page of tube8.com)" 27 if $self->url !~ m!^http://www.tube8.com/[^/]+/([^/]+)/(\d+)/!; 28 $self->title_inurl($1); 29 $self->id($2); 23 30 $self->_get_info; 24 31 … … 34 41 35 42 while ( $tube8_page =~ s/so\.addVariable\('([^']+)','([^']+)'\);// ) { 36 my $key = $1; 37 my $value = $2; 43 my ($key, $value) = ($1, $2); 38 44 if ($key) { 39 45 if ( $key eq 'videoUrl' && $value =~ /\.flv$/ ) { 40 $self-> {flv} = $value;46 $self->flv($value); 41 47 } 42 48 elsif ( $key eq 'imageUrl' && $value =~ /\.jpg$/ ) { 43 $self-> {thumb} = 'http://www.tube8.com' . $value;49 $self->thumb('http://www.tube8.com' . $value); 44 50 } 45 51 } 46 52 } 47 ( $self->{'3gp'} ) 48 = ( 49 $tube8_page =~ /<a href="([^"]+\.3gp)">Download video for mobile/ ); 50 } 51 52 sub flv { 53 my $self = shift; 54 55 return $self->{flv} if $self->{flv}; 56 } 57 58 sub thumb { 59 my $self = shift; 60 61 return $self->{thumb} if $self->{thumb}; 62 } 63 64 sub get_3gp { 65 my $self = shift; 66 67 return $self->{'3gp'} if $self->{'3gp'}; 53 $self->get_3gp( 54 $tube8_page =~ /<a href="([^"]+\.3gp)">Download video for mobile/ ) ; 55 $self->title( 56 $tube8_page =~ /<td[^>]+><strong>Title<\/strong>: ([^<]+)<\/td>/ ); 57 $self->duration( 58 $tube8_page =~ /<td[^>]+><strong>Duration<\/strong>: ([^<]+)<\/td>/ ); 59 $tube8_page =~ /<td[^>]+><strong>Category<\/strong>: <a href='([^']+)'><b>([^<]+)<\/b><\/a><\/td>/; 60 $self->category_url($1); 61 $self->category($2); 68 62 } 69 63 … … 89 83 my $t8 = WWW::Tube8->new({ 90 84 url => 'http://www.tube8.com/category/hoge-hoge-/00000/', 91 ua => $ua, 85 ua => $ua, # optional 92 86 }); 93 87 94 print $t8->flv . "\n"; 95 print $t8->thumb . "\n"; 96 print $t8->get_3gp . "\n"; 88 print $t8->flv . "\n"; 89 print $t8->thumb . "\n"; 90 print $t8->get_3gp . "\n"; 91 print $t8->url . "\n"; 92 print $t8->id . "\n"; 93 print $t8->title . "\n"; 94 print $t8->title_inurl . "\n"; 95 print $t8->category . "\n"; 96 print $t8->category_url . "\n"; 97 print $t8->duration . "\n"; 97 98 98 99 … … 104 105 105 106 Creates a new WWW::Tube8 instance. 107 required param only url. 108 109 110 you can get video infomations like follow 106 111 107 112 =item flv 108 113 109 get the url of flv file110 111 114 =item thumb 112 113 get the url of thumbnail file114 115 115 116 =item get_3gp 116 117 117 get the url of 3gp(mp4) file 118 =item url 119 120 =item id 121 122 =item title 123 124 =item title_inurl 125 126 =item category 127 128 =item category_url 129 130 =item duration 118 131 119 132 =back -
lang/perl/WWW-Tube8/trunk/t/01.basic.t
r28249 r28301 1 1 use strict; 2 use Test::More tests => 8;2 use Test::More tests => 14; 3 3 use WWW::Tube8; 4 4 … … 16 16 my $t8 = WWW::Tube8->new({ url => 'http://www.example.com/' }); 17 17 }; 18 like $@, qr/url is not tube8/, 'new : not tube8 url';18 like $@, qr/url is wrong/, 'new : not tube8 url'; 19 19 20 20 my $ua = LWP::UserAgent->new(agent => 'WWW::Tube8.test'); … … 36 36 'get_3gp : get url of 3gp file'; 37 37 38 is $t8->id, '71930', 'id : get id of video'; 38 39 40 is $t8->title, 'Japanese AV Haruka Sanada', 'title : get title of video'; 39 41 42 is $t8->title_inurl, 'japanese-av-haruka-sanada', 'title_inurl : get title of video for url'; 43 44 is $t8->category, 'Asian', 'category : get category of video'; 45 46 is $t8->category_url, 'http://www.tube8.com/cat/asian/12/', 'category_url : get category link of video'; 47 48 is $t8->duration, '23:00', 'duration : get duration of video';
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)