diff options
author | Tomáš Čech <sleep_walker@suse.cz> | 2013-04-02 22:03:36 +0200 |
---|---|---|
committer | Tomáš Čech <sleep_walker@suse.cz> | 2013-04-02 22:03:36 +0200 |
commit | 265468d43e34e886fbcba19b04cebc40212fb955 (patch) | |
tree | fc964ae06ec5cb387b8511d82fc75676c77cc6ab | |
parent | e4da231361f8b3b7e24a81ed887293cd70f01cb1 (diff) | |
download | get-flash-videos-265468d43e34e886fbcba19b04cebc40212fb955.tar.gz |
use decode_entities(), add versioning of the plugin, proper file suffix
during Nigel Taylor's review he proposed several patches
- use more advanced decode_entities() instead of s/// for one case
- add versioning to module (with this changed jumped to 0.02)
- set file suffix according to content
-rw-r--r-- | lib/FlashVideo/Site/Vk.pm | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/FlashVideo/Site/Vk.pm b/lib/FlashVideo/Site/Vk.pm index 105d6b0..391c35e 100644 --- a/lib/FlashVideo/Site/Vk.pm +++ b/lib/FlashVideo/Site/Vk.pm @@ -3,21 +3,28 @@ package FlashVideo::Site::Vk; use strict; use FlashVideo::Utils; +use HTML::Entities; + +our $VERSION = '0.02'; +sub Version() { $VERSION; } sub find_video { my ($self, $browser, $embed_url) = @_; + my $new_embed_url = ""; my $title = ""; my $host = ""; my $uid = ""; my $vtag = ""; my $url = ""; my $reget = 0; -# return unless ($embed_url !~ /^http:\/\/([^.\/]+\.)?vk\.com\/.*/); - # it seems that ampersands are often escaped (why?) - if ($embed_url =~ /&/) { - info ("URI with encoded ampersands... re-GETing"); - $embed_url =~ s/&/&/g; + $new_embed_url = decode_entities($embed_url); + + # if the URL contains undecoded HTML entities, we have the wrong URL + # and need to get proper one + if ($embed_url != $new_embed_url) { + info ("URI with encoded entities... re-GETing"); + $embed_url = $new_embed_url; $reget = 1; } @@ -51,7 +58,7 @@ sub find_video { $url = $host . "u" . $uid . "/videos/" . $vtag . ".360.mp4"; debug ("URL: '" . $url . "'"); - return $url, title_to_filename($title); + return $url, title_to_filename($title, "mp4"); } 1; |