diff options
author | Nigel Taylor <njtaylor0101@gmail.com> | 2013-03-07 09:52:51 +0000 |
---|---|---|
committer | Nigel Taylor <njtaylor0101@gmail.com> | 2013-03-07 09:52:51 +0000 |
commit | c2c918a40113561e4f5b632837c4bcc908c20f99 (patch) | |
tree | 5685a5b8b9f29781e4a8e0818b910db8840df457 | |
parent | 7c20f3e3757e3651d8fbb3bc1868763f36faa239 (diff) | |
download | get-flash-videos-c2c918a40113561e4f5b632837c4bcc908c20f99.tar.gz |
Handle short urls for sites such as youtube.
-rwxr-xr-x | get_flash_videos | 5 | ||||
-rw-r--r-- | lib/FlashVideo/URLFinder.pm | 10 |
2 files changed, 15 insertions, 0 deletions
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:://; |