Open GoogleCodeExporter opened 9 years ago
Original comment by monsieur...@gmail.com
on 7 Jun 2009 at 1:56
I've run into this where it won't follow a redirect. It might better to have
redirects off by default. But at least there should be a command line switch
to either allow or disallow them and a nicer warning that there was a redirect
instead of crashing. If you specify which you want, I can implement it.
Original comment by Samuel.S...@gmail.com
on 11 May 2012 at 4:41
I can't imagine why you'd want them off by default. A redirect means that's
where the video is! :)
(I just ran into this problem pasting a link from twitter:
http://t.co/CrjZI5GhpJ )
Original comment by seegahan@gmail.com
on 6 Mar 2013 at 4:08
This is a slightly different case, using short form url's. These happen to use
redirection. gfv matches on the host in the supplied url, t.co is what trying
to be matched, this is different from www.youtube.com/... redirecting to the
same site, as the youtube plugin would still be used. I just changed the
Channel4 plugin to handle a redirect, here the supplied url contains
information to find the video. There are sites that do strange things with
redirections, like embed a url within an url and redirect to random adverts
instead. Others send you to login pages.
The issue your raising is an enhancement request to handle short form url's.
These changes should handle that.
diff --git a/get_flash_videos b/get_flash_videos
index d98e56b..c6a0239 100755
--- a/get_flash_videos
+++ b/get_flash_videos
@@ -310,6 +310,11 @@ sub download {
info "Downloading $url";
$browser->get($url);
+ # Handle short url which redirect...
+ if ($browser->response->is_redirect and ($url ne $possible_url)) {
+ info "Downloading redirected $possible_url";
+ $browser->get($possible_url);
+ }
# (Redirect check is for Youtube which sometimes redirects to login page
# for "mature" videos.)
diff --git a/lib/FlashVideo/URLFinder.pm b/lib/FlashVideo/URLFinder.pm
index ecb2928..bd42f4f 100644
--- a/lib/FlashVideo/URLFinder.pm
+++ b/lib/FlashVideo/URLFinder.pm
@@ -37,6 +37,16 @@ sub find_package {
}
}
+ # Handle redirection such as short urls.
+ if (!defined $package) {
+ $browser->get($url);
+ if ($browser->response->is_redirect) {
+ my $possible_url = $browser->response->header('Location');
+ $package = _find_package_url($possible_url, $browser);
+ return _found($package, $possible_url) if (defined $package);
+ }
+ }
+
if(!defined $package) {
for(@extra_can_handle) {
s/FlashVideo::Site:://;
If I see no problems I will add them
Original comment by njtaylor...@gmail.com
on 7 Mar 2013 at 12:32
Very nice! Thank you! :D
Original comment by seegahan@gmail.com
on 7 Mar 2013 at 5:38
Original issue reported on code.google.com by
monsieur...@gmail.com
on 7 Jun 2009 at 1:46