├── ytlikely.sh ├── spotify-scrape.pl ├── spot2mp3.sh └── README.md /ytlikely.sh: -------------------------------------------------------------------------------- 1 | #example call: 2 | #sh ./ytlikely.sh 'daft punk - technologic' 3 | #sh ./ytlikely.sh 'search - term' 4 | 5 | #Author: Wouter Vandenneucker 6 | #Author twitter: http://twitter.com/woutervddn 7 | 8 | QUERY=$(echo $1 | sed -e 's/ - / /g' | sed 's/ /+/g') 9 | wget -O foo.html "http://gdata.youtube.com/feeds/api/videos?q=$QUERY&max-results=1&v=2"&& 10 | RESPONSE=$(cat foo.html) 11 | rm foo.html 12 | echo $RESPONSE | sed 's/>\n//g" 13 | 14 | -------------------------------------------------------------------------------- /spotify-scrape.pl: -------------------------------------------------------------------------------- 1 | #requirement 2 | #if not installed: sudo cpan install Web:Scraper 3 | 4 | #example call: 5 | #perl ./spotify-scrape.pl 'spotify:track:2qpmEFEoc6bVpYhc4Lp5Uo' 6 | #perl ./spotify-scrape.pl 'spotify-uri' 7 | 8 | #Author: Jonathan Spruytte 9 | #Author twitter: http://twitter.com/spruyttej 10 | 11 | #CoAuthor: Wouter Vandenneucker 12 | #CoAuthor twitter: http://twitter.com/woutervddn 13 | 14 | 15 | use strict; 16 | use URI; 17 | use Web::Scraper; 18 | 19 | #init 20 | my @songs=(); 21 | #scraper 22 | my $data = scraper { 23 | # we will save the urls from the teams 24 | process "ul.track-info", "tracks[]" => scraper { 25 | process "ul.track-info>li.track-title", 'title' => 'TEXT'; 26 | process "ul.track-info>li.artist", 'artist' => 'TEXT'; 27 | }; 28 | }; 29 | 30 | #loop over infput 31 | foreach ($ARGV[0]=~/(.*)/){ 32 | 33 | # scrape the data 34 | my $res = $data->scrape(URI->new("https://embed.spotify.com/?uri=$_")); 35 | 36 | #push(@songs,$res->{titles}[0] . " " . $res->{artists}[0]); 37 | 38 | 39 | #print join("\n",@songs),"\n"; 40 | for my $track (@{$res->{tracks}}) { 41 | print "$track->{title} - $track->{artist} \n"; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /spot2mp3.sh: -------------------------------------------------------------------------------- 1 | #requirements 2 | #make sure to have perl installed 3 | #if not installed: sudo cpan install Web:Scraper 4 | #check if spot2mp3.sh, ytlikely.sh and spotify-scrape.pl are in the same folder 5 | #install youtube-dl: sudo apt-get install youtube-dl 6 | 7 | #example call: 8 | #sh ./spot2mp3.sh 'spotify:track:1iNeZGJsoC0D7ZyJTdIbDS' 'DaftPunkTechnoLogic' 9 | #sh ./spot2mp3.sh 'spotify-uri' 'foldername' 10 | 11 | #Author: Wouter Vandenneucker 12 | #Author twitter: http://twitter.com/woutervddn 13 | 14 | #special thanks to: Jonathan Spruytte - http://twitter.com/spruyttej 15 | 16 | 17 | echo "saving playlist $1 in $2" 18 | TITLE="$(wget --quiet -O - https://embed.spotify.com/?uri=$1 \ | sed -n -e 's!.*\(.*\).*!\1!p')" 19 | #echo "downloading $TITLE" 20 | perl ./spotify-scrape.pl $1 > $2.sptlst 21 | #echo "$TITLE downloaded as $2" 22 | cat $2.sptlst | sed -e 's/.*\. //' > $2.spt2mp3 23 | IFS=" 24 | " 25 | for line in `cat $2.spt2mp3`;do 26 | #echo "downloading: $line" 27 | link="$(sh ./ytlikely.sh $line)" 28 | #echo "from url: $link" 29 | mkdir $2 30 | cd ./$2 31 | youtube-dl -t -f 18 --extract-audio --audio-format "mp3" $link 32 | cd ../ 33 | done 34 | rm $2.sptlst $2.spt2mp3 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SpotifyScrapeAndDownload 2 | ======================== 3 | 4 | General: 5 | This repo contains a perl script that converts a spotify uri to a playlist of tracks and artists 6 | A shell scripts that gives the most likely youtube url for a given query 7 | And a shell script that combines the two and downloads all songs from a spotify uri via youtube 8 | 9 | Requirements: 10 | make sure to have perl installed 11 | if not installed: sudo cpan install Web:Scraper 12 | check if spot2mp3.sh, ytlikely.sh and spotify-scrape.pl are in the same folder 13 | install youtube-dl: sudo apt-get install youtube-dl 14 | 15 | Example call: 16 | sh ./spot2mp3.sh 'spotify:track:1iNeZGJsoC0D7ZyJTdIbDS' 'DaftPunkTechnoLogic' 17 | sh ./spot2mp3.sh 'spotify-uri' 'foldername' 18 | 19 | special thanks to: Jonathan Spruytte - http://twitter.com/spruyttej 20 | 21 | Notes: 22 | All scripts can be used seperatly. 23 | 24 | Use Policy: 25 | spotify2mp3.sh should only be used in case the mobile version of spotify fails to work on your mobile phone. 26 | Respect the artists you listen to, if you really like the song: buy/download it in spotify. 27 | 28 | Legal Notice: 29 | The Author is not responisble for any infringements made by the users of these script 30 | --------------------------------------------------------------------------------