Last active
December 17, 2015 11:58
-
-
Save wchristian/5605785 to your computer and use it in GitHub Desktop.
scripts to download all DI.fm playlists, either linear or parallelized ported from: https://twitter.com/_am3thyst/status/335854928654389248
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strictures; | |
use 5.010; | |
use IO::All -binary; | |
use JSON 'from_json'; | |
run( $ARGV[0] ) if !caller; | |
sub run { | |
my ( $pl_path ) = @_; | |
$pl_path //= '.'; | |
my @stations = @{ from_json io( "http://listen.di.fm/public2" )->all }; | |
for my $station ( @stations ) { | |
my ( $genre ) = ( $station->{playlist} =~ m@/([^/]*\.pls)$@ ); | |
say "[+] getting $genre"; | |
io( "$pl_path/$genre" )->print( io( $station->{playlist} )->all ); | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strictures; | |
use 5.010; | |
use IO::All -binary; | |
use JSON 'from_json'; | |
use HTTP::Request::Common qw( GET ); | |
use Parallel::Downloader 'async_download'; | |
run( $ARGV[0] ) if !caller; | |
sub run { | |
my ( $pl_path ) = @_; | |
$pl_path //= '.'; | |
my @stations = @{ from_json io( "http://listen.di.fm/public2" )->all }; | |
my @requests = map { GET $_->{playlist} } @stations; | |
$requests[$_]{file} = "$stations[$_]{key}.pls" for 0 .. $#stations; | |
io( "$pl_path/$_->[2]{file}" )->print( $_->[0] ) | |
for Parallel::Downloader->new( requests => \@requests, debug => 1 )->run; | |
return; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment