Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use WWW::Mechanize;
- use Date::Parse;
- use DateTime;
- use File::Path;
- use HTML::Grabber;
- use JSON::XS;
- use Data::Dumper;
- ########################################################################################################################
- # Change only the configuration settings in this section, nothing above or below it. #
- ########################################################################################################################
- # Enclose value in double quotes, folders with spaces in the name are ok.
- my $root_folder = "/Users/john/Desktop";
- ########################################################################################################################
- ########################################################################################################################
- # Suddenly web robot.
- my $mech = WWW::Mechanize->new();
- $mech->agent_alias('Mac Safari');
- # First we have to log in.
- $mech->get("https://vimeo.com/filmmakeriq/videos");
- my $dom = HTML::Grabber->new(html => $mech->content);
- my $z = 44;
- while ($z > 0) {
- $dom->find('li[id^="clip"] a')->each(sub {
- my $el = $_;
- print $el->attr('title') . "\n";
- # Let's go to the video page.
- my $mech2 = $mech->clone();
- $mech2->get($el->attr('href'));
- my $dom2 = HTML::Grabber->new(html => $mech2->content);
- # Looks like this finds the image, even as a jpeg
- $dom2->find('noscript img')->each(sub {
- my $pic = $mech2->clone();
- my $piclink = $_->attr('src');
- $piclink =~ s/(.+)\?.+$/$1/;
- $z--;
- #$pic->get($piclink, ':content_file' => "$root_folder/ep$z.jpg");
- });
- # Holy shitsnacks, the link to the actual video was hiding here all along.
- $dom2->find('div.wrap_content script:first-child')->each(sub {
- my $mech3 = $mech2->clone();
- my $mp4link = $_->text;
- $mp4link =~ s/.+e.open\("GET","(https.+?)".+$/$1/;
- $mech3->get($mp4link);
- my $json = JSON::XS->new->utf8->decode($mech3->content());
- my @qualtiies;
- my $progressive = $json->{'request'}->{'files'}->{'progressive'};
- foreach my $q (@$progressive) {
- if ($q->{'width'} == 1280) {
- $mech3->get($q->{'url'}, ':content_file' => "$root_folder/ep$z.mp4");
- system("/usr/local/bin/ffmpeg -i ep$z.mp4 -c copy -map_metadata -1 -map_chapters -1 -metadata:s:a:0 language=eng " .
- "\"Filmmaker IQ - S01E$z - " . $el->attr('title') . ".mp4\"");
- }
- }
- });
- });
- $mech->follow_link(text => "Next");
- $dom = HTML::Grabber->new(html => $mech->content);
- }
Add Comment
Please, Sign In to add comment