mikez / spotify-folders

Get your Spotify folder hierarchy with playlists into JSON.
MIT License
60 stars 6 forks source link

Backup utility #11

Closed brodmo closed 3 months ago

brodmo commented 7 months ago

@mikez Hey, just a heads-up, I've written a small backup utility for Spotify folders (https://github.com/brodmo/spotify-folders-backup) based on this project. I woud be grateful if you could notify me of any breaking changes.

mikez commented 7 months ago

@brodmo Would it be helpful if I put the spotifyfolders to pypi so you can do "pip install spotifyfolders"?

import spotifyfolders

folders = spotifyfolders.get()

something like that?

mikez commented 7 months ago

For breaking changes, it's easiest if you follow this project. In the past, others have posted here when something breaks.

brodmo commented 7 months ago

@brodmo Would it be helpful if I put the spotifyfolders to pypi so you can do "pip install spotifyfolders"?

import spotifyfolders

folders = spotifyfolders.get()

something like that?

That would certainly be simpler, the way I do it currently is pretty hacky:

folders_script_url = 'https://raw.githubusercontent.com/mikez/spotify-folders/master/folders.py'
response = requests.get(folders_script_url)
assert response.ok, 'could not get spotfiyfolders script'
folders_script_path = _here / 'folders.py'
folders_script_path.write_text(response.text)
folders_script_path.chmod(folders_script_path.stat().st_mode | stat.S_IEXEC)
folders_data = subprocess.run(folders_script_path, capture_output=True).stdout

I don't really mind, though, long as it works.

mikez commented 7 months ago

👍

Out of curiosity, why do you direct to Clear Spotify cache in Spotify settings?

brodmo commented 7 months ago

The extracted folders were way out of date before I did. Were they alway up-to-date in your testing?

mikez commented 7 months ago

The extracted folders were way out of date before I did. Were they alway up-to-date in your testing?

Interesting! The cache does indeed store several copies, however, the code is meant to get you the newest copy. Your comments suggests the code I provided isn't complete.

Technically, the key-value storage used by Spotify is LevelDB; implementation notes here. I wrote a simplified parser to attempt to get the newest spotify:user:{USERID}:rootlist key from the key-value storage.