Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #49 from pcwalden/master

Nasa.pm changed to use FlashVideo::JSON JSON parser.
  • Loading branch information...
commit 72ddc3ce36a420c332597f147e467c23436c2223 2 parents 6ba5003 + 3ac301c
@zakflash zakflash authored
Showing with 5 additions and 4 deletions.
  1. +5 −4 lib/FlashVideo/Site/Nasa.pm
View
9 lib/FlashVideo/Site/Nasa.pm
@@ -3,6 +3,7 @@ package FlashVideo::Site::Nasa;
use strict;
use FlashVideo::Utils;
+use FlashVideo::JSON;
sub find_video {
my ($self, $browser, $embed_url) = @_;
@@ -45,16 +46,16 @@ sub find_video {
die "Could not get video details" unless $browser->success();
# Content is JSON fomatted
+ my $result = from_json($browser->content());
+
# Get the video's url
- my ($url) = $browser->content() =~ m{\"url\"\:\"([^"]*)\"};
+ my $url = $result->{url};
die "Could not extract video url" unless $url;
- # unescape the JSON
- $url =~ s/\\//g;
# Hack: not sure why/where the "core" in the url is mutated to "core-dl" so just hacking it here
$url =~ s/\/core\//\/core-dl\//;
# Get the video's title from the JSON
- my ($filename) = $browser->content() =~ m{\"title\"\:\"([^"]*)\"};
+ my $filename = $result->{title};
$filename = title_to_filename($filename, "mp4");
return $url, $filename;
Please sign in to comment.
Something went wrong with that request. Please try again.