Permalink
Browse files

Fixed Wat.tv support, fixes issue 97.

  • Loading branch information...
1 parent e855752 commit 0318ef1b19a9f9f8577e6d648e4d86b5cfc1154d @zakflash zakflash committed Apr 21, 2010
Showing with 35 additions and 1 deletion.
  1. +35 −1 FlashVideo/Site/Wat.pm
View
@@ -18,7 +18,41 @@ sub find_video {
my $title = json_unescape(($browser->content =~ /title":"(.*?)",/)[0]);
my $url = json_unescape(($browser->content =~ /files.*?url":"(.*?)",/)[0]);
- my $filename = title_to_filename($title);
+ # Need to supply some other parameters
+ $url .= "?context=swf2&getURL=1&version=WIN%2010,0,45,2";
+
+ my $file_type = 'flv';
+
+ # This *looks* like a video URL, but it actually isn't - URL is supplied
+ # in the content of the response.
+ $browser->head($url);
+
+ if (!$browser->success) {
+ die "Couldn't do HEAD request $url: " . $browser->response->status_line;
+ }
+
+ my $content_type = $browser->response->header('Content-Type');
+ if ($content_type =~ /text/) {
+ $browser->get($url);
+
+ if (!$browser->success) {
+ die "Couldn't get $url: " . $browser->response->status_line;
+ }
+
+ if ($browser->content =~ m'^(http://\S+)') {
+ $url = $1;
+
+ # Some videos are H264
+ if ($url =~ /\.h264/) {
+ $file_type = 'mp4';
+ }
+ }
+ }
+ else {
+ die "Unexpected Content-Type ($content_type) from Wat server.";
+ }
+
+ my $filename = title_to_filename($title, $file_type);
$browser->allow_redirects;

0 comments on commit 0318ef1

Please sign in to comment.