Permalink
Browse files

Add support for Traileraddict (fixes issue 85).

  • Loading branch information...
1 parent ab9afbb commit 65bb0645f0263641b3ce50607ee3ab638a5aa8c5 @zakflash zakflash committed Apr 16, 2010
Showing with 64 additions and 0 deletions.
  1. +61 −0 FlashVideo/Site/Traileraddict.pm
  2. +3 −0 t/urls
@@ -0,0 +1,61 @@
+# Part of get-flash-videos. See get_flash_videos for copyright.
+package FlashVideo::Site::Traileraddict;
+
+use strict;
+use FlashVideo::Utils;
+use URI::Escape;
+
+sub find_video {
+ my ($self, $browser) = @_;
+
+ my $video_id;
+ if ($browser->content =~ m'/em[db]/(\d+)') {
+ $video_id = $1;
+ }
+ else {
+ die "Unable to get Traileraddict video ID";
+ }
+
+ my $video_info_url = "http://www.traileraddict.com/fvar.php?tid=$video_id";
+
+ $browser->get($video_info_url);
+
+ if (!$browser->success) {
+ die "Couldn't download Traileraddict video info URL: " .
+ $browser->response->status_line;
+ }
+
+ # Get video information -- this helpfully includes metadata which could
+ # be useful for gfv's upcoming metadata feature.
+ my %info = parse_video_info($browser->content);
+
+ die "Couldn't find Traileraddict video URL" unless $info{fileurl};
+
+ $browser->head($info{fileurl});
+ if ($browser->response->is_redirect()) {
+ $info{fileurl} = $browser->response->header('Location');
+ }
+
+ my $type = $info{fileurl} =~ /\.mp4/i ? 'mp4' : 'flv';
+
+ return $info{fileurl}, title_to_filename($info{title}, $type);
+}
+
+sub parse_video_info {
+ my $raw_video_info = shift;
+
+ my %info;
+
+ # Raw video info are URL-encoded key=value pairs.
+ foreach my $pair (split /&/, $raw_video_info) {
+ $pair = uri_unescape($pair);
+
+ my ($name, $value) = split /=/, $pair;
+
+ $info{$name} = $value;
+ }
+
+ return %info;
+}
+
+1;
View
@@ -190,3 +190,6 @@ http://www.liveleak.com/view?i=935_1220048342
# Movietv.us
http://www.movietv.us/share/view/163/second-chances/
+
+# Traileraddict
+http://www.traileraddict.com/trailer/dear-john/music-video-set-the-fire-to-the-third-bar

0 comments on commit 65bb064

Please sign in to comment.