Skip to content

Instantly share code, notes, and snippets.

@paveljurca
Last active November 19, 2017 10:32
Show Gist options
  • Save paveljurca/7263fd17d53a3fddfbcb669b54f008ab to your computer and use it in GitHub Desktop.
Save paveljurca/7263fd17d53a3fddfbcb669b54f008ab to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use LWP::UserAgent;
use HTTP::Request::Common;
use constant API => shift;
$ua = new LWP::UserAgent;
$ua->agent('Mozilla/8.0');
my @html = split m|<div class="title">|,
$ua->request(GET API)->decoded_content;
my ($bc, $album) = (split '/album/', API);
$album =~ s/[^\w-]//g;
mkdir $album;
chdir $album;
shift @html;
for (@html) {
my ($track) = m|<a href="([^"]+)|;
# sleep 1;
system 'youtube-dl', qw(-o %(title)s.%(ext)s --restrict-filenames), $bc.$track;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment