Skip to content

Instantly share code, notes, and snippets.

@Nerten
Created September 12, 2012 13:44
Show Gist options
  • Save Nerten/3706698 to your computer and use it in GitHub Desktop.
Save Nerten/3706698 to your computer and use it in GitHub Desktop.
oneliner tunes.io downloader with trailing zeros in filenames, and make playlist in folder
perl -C -S -MTime::Piece -MFile::Util -Mojo -MMP3::Tag -E '$date = localtime->ymd; $i=0; $c=0; $ENV{MOJO_MAX_MESSAGE_SIZE} = 1073741824; mkdir $dir=$ENV{HOME}."/Dropbox/tunes.io/".$date; open (FILE, ">","${\$dir}/${\$date}.pls"); print FILE "[playlist]\n\n"; $file = "${\$dir}/".File::Util::escape_filename(sprintf("\%02d", ++$i)." - ${\$_->text}.mp3","") and say sprintf("\%02d", $i)." - ${\$_->text}.mp3" and (((-e "$file") && (-s "$file") > 0) || g($_->attrs("href"))->content->asset->move_to($file)) and ((-s "$file") > 0) and ++$c and print FILE "File${\$c}=".sprintf("\%02d", $i)." - ${\$_->text}.mp3\n\nTitle${\$c}=${\$_->text()}\n\nLength${\$c}=". MP3::Tag->new($file)->total_secs_int()."\n\n" for g("tunes.io/playlist.jsp?date=${\$date}")->dom("ul a")->each; print FILE "NumberOfEntries=${\$c}\n\nVersion=2\n\n"; close (FILE);'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment