diff options
author | Zakariyya Mughal <zaki.mughal@gmail.com> | 2012-12-12 22:47:32 -0600 |
---|---|---|
committer | Zakariyya Mughal <zaki.mughal@gmail.com> | 2012-12-12 22:47:32 -0600 |
commit | bc346e8ed1ac1ad7e71419399f4102252867c742 (patch) | |
tree | ac146f316dfd8dc5f0a930891a1742b06fa9ed0d | |
parent | 13558321fae51f671663c46df6821faaae871b19 (diff) | |
download | get-flash-videos-bc346e8ed1ac1ad7e71419399f4102252867c742.tar.gz |
add support for SockShare (same as PutLocker)
SockShare uses the same code as PutLocker, however it appears that
high-quality downloading does not work for SockShare.
-rw-r--r-- | lib/FlashVideo/Site/Putlocker.pm | 34 | ||||
-rw-r--r-- | lib/FlashVideo/Site/Sockshare.pm | 7 |
2 files changed, 30 insertions, 11 deletions
diff --git a/lib/FlashVideo/Site/Putlocker.pm b/lib/FlashVideo/Site/Putlocker.pm index 1a44c4d..0778fa1 100644 --- a/lib/FlashVideo/Site/Putlocker.pm +++ b/lib/FlashVideo/Site/Putlocker.pm @@ -5,6 +5,7 @@ use strict; use FlashVideo::Utils; use HTML::Tree; use HTML::Entities qw(decode_entities); +use URI; sub find_video { my ($self, $browser, $embed_url, $prefs) = @_; @@ -12,10 +13,11 @@ sub find_video { die 'Could not retrieve video' unless ($browser->success); my ($id) = ($embed_url =~ m,file/([^/]*),); - print $id,"\n"; my ($filename) = title_to_filename(extract_title($browser)); - $filename =~ s/[\s\|_]*PutLocker[\s_]*//; + my $host = URI->new($embed_url)->host; # www.putlocker.com or www.sockshare.com + my $sitename = _host_to_sitename($host); + $filename =~ s/[\s\|_]*$sitename[\s_]*//; my $url; # the final URL #get the "hash" value from the HTML @@ -25,7 +27,7 @@ sub find_video { info 'Found hash: ' . $hash; #Construct a POST request to get the tell the server to serve real page content - info "Confirming request to PutLocker."; + info "Confirming request to $sitename."; $browser->add_header( 'Content-Type' => 'application/x-www-form-urlencoded' ); $browser->add_header( 'Accept-Encoding' => 'text/html' ); @@ -46,7 +48,7 @@ sub find_video { info "Found the stream ID: " . $streamID; #request the url of the actual file - my $uri = URI->new( "http://www.putlocker.com/get_file.php" ); + my $uri = URI->new( "http://$host/get_file.php" ); $uri->query_form((stream=>$streamID)); #parse the url and title out of the response - much easier to regex it out, as the XML has dodgy &'s. @@ -62,11 +64,12 @@ sub find_video { if( $page_html =~ m,"/(get_file\.php\?id=[^"]*)", ) { # download original file if link available my $download_page = $1; - $url = URI->new( "http://www.putlocker.com/$1" ); - # this URL should be equivalent to what is returned by get_high_quality() + $url = URI->new( "http://$host/$1" ); + # this URL should be equivalent to what is returned by _get_high_quality() } - } elsif($prefs->{quality} eq 'high') { - $url = get_high_quality($id, $streamID); + } elsif($prefs->{quality} eq 'high' and $host eq 'www.putlocker.com') { + # only works on PutLocker + $url = _get_high_quality($host, $id, $streamID); } else { # get streaming version $url = $stream_url; @@ -76,9 +79,18 @@ sub find_video { return $url, $filename; } -sub get_high_quality { - my ( $id, $key ) = @_; - return "http://www.putlocker.com/get_file.php?id=$id&key=$key&original=1"; +sub _get_high_quality { + my ( $host, $id, $key ) = @_; + return "http://$host/get_file.php?id=$id&key=$key&original=1"; +} + +sub _host_to_sitename { + my ($host) = @_; + if($host eq 'www.putlocker.com') { + return "PutLocker"; + } elsif($host eq 'www.sockshare.com') { + return "SockShare"; + } } 1; diff --git a/lib/FlashVideo/Site/Sockshare.pm b/lib/FlashVideo/Site/Sockshare.pm new file mode 100644 index 0000000..61a79c8 --- /dev/null +++ b/lib/FlashVideo/Site/Sockshare.pm @@ -0,0 +1,7 @@ +# Part of get-flash-videos. See get_flash_videos for copyright. +package FlashVideo::Site::Sockshare; + +# SockShare uses the same software as PutLocker +use base 'FlashVideo::Site::Putlocker'; + +1; |