Skip to content

Instantly share code, notes, and snippets.

@O-Zone
Created March 12, 2024 19:07
Show Gist options
  • Save O-Zone/8172d5ebf672765fd50c03d381aa3deb to your computer and use it in GitHub Desktop.
Save O-Zone/8172d5ebf672765fd50c03d381aa3deb to your computer and use it in GitHub Desktop.
Script to harvest all song/title/album from your favorite list in Napster and export them to a .csv file
var mainListe = document.getElementsByClassName('ant-table-tbody')[0].children;
var harvestedTunes = [];
for(i = 0; i < mainListe.length ; i++){
let currentSong = mainListe[i];
let albumAndArtist = currentSong.children[0].innerText.split('\n');
let tune = currentSong.children[1].innerText.split('\n');
let duration = currentSong.children[2].innerText.split('\n');
harvestedTunes.push([albumAndArtist[0], albumAndArtist[2], tune[0], duration[0]]);
}
var resultWindow = window.open('', '');
resultWindow.document.open();
resultWindow.document.write('Title, Artist, Album, Duration<br>\n' + harvestedTunes.map(a => a.join(';')).join('<br>\n'));
resultWindow.document.close();
@O-Zone
Copy link
Author

O-Zone commented Mar 12, 2024

I don't know why all music streaming services are so lame and protective, but I guess it all comes down to money?
Many years ago I discontinued my Youtube Music service, and I wanted to export all the lovely music I had collected in my favorites. That wasn't possible in any way, so I ended up writing a scraper, so I didn't have to write the complete list down song by song.

Now I am finally giving up on Napster too - it IS with a bleeding heart, because Napster is actually paying the musicians better than all the other streaminhg services. But their application (and especially their search interface) is so poorly written that it is close to unusable. So now I needed to export yet again. Yup - there are no export options in Napster either. So here is a new scraper for napster.

It isn't as easy to use as the one I wrote for Youtube Music, but you need to do as follows:

  1. Log into the Napster webapp on napster.com.
  2. Open the page "My Favorites"
  3. Scroll to the bottom of the list (it is an infinite scroller, and it might take a while, if you have as many favorites as I have).
  4. When you hit the bottom, open the developer tool (F12 or Ctrl+Shift+i)
  5. Copy/Paste the code from this gist, and press Enter
  6. A new window should open, with all your music fields separated by ";"
  7. Save the content of the new window as a .csv file, and import it in a spreadsheet or what you want it as.

I have tried it a couple of times, and I have noticed that the list isn't always containing the same amount of numbers, so I guess that Napster also has implemented their infinity scroller with bugs, so I will suggest that you scroll down the page slow and steadily! o_O (Unfortunately it wouldn't surprice me - I have tried for years now to make them code it better, but even though they always have tried to sweet-talk me and promised that there would come an update right around the corner any day now, it has been insanely buggy all the time! >:-7 (so now I have finally given up on them!))

I have no clue on which streaming service I want to move to! :-( They all have their flaws!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment