Skip to content

Instantly share code, notes, and snippets.

@ahhmino
Last active August 3, 2023 21:29
Show Gist options
  • Save ahhmino/78bc0fd7318ad69a0a20f22da9be26a2 to your computer and use it in GitHub Desktop.
Save ahhmino/78bc0fd7318ad69a0a20f22da9be26a2 to your computer and use it in GitHub Desktop.
Create m3u8 playlists to export from spotify_sync downloads to jellyfin
import json
import os
import ffmpeg
# These paths will be found under the profile directory for your spotify_sync profile
playlist_mapping_path = "/home/<user>/.local/share/spotify_sync/<your-profile>/playlist-mapping-<profile-uid>.json"
processed_songs_path = "/home/<user>/.local/share/spotify_sync/<your-profile>/processed-<profile-uid>.json"
playlists = json.load(open(playlist_mapping_path))
songs = json.load(open(processed_songs_path))
def create_m3u8_playlists(playlists, songs):
for playlist in playlists:
filename = f"playlists/{playlists[playlist]['playlist_name'].replace('/', '-')}.m3u8"
os.makedirs(os.path.dirname(filename), exist_ok=True)
playlist_file = open(filename, "w")
playlist_file.write("#EXTM3U\n")
for song in playlists[playlist]["tracks"]:
if songs[song]["download_path"] is not None and songs[song]["download_path"] != "":
playlist_file.write(f"#EXTINF:{ffmpeg.probe(songs[song]['download_path'])['format']['duration']},\n")
playlist_file.write(f"{songs[song]['download_path']}\n")
playlist_file.close()
@AJPedersen
Copy link

'These paths will be found under the profile directory for your spotify_sync profile'

Where are these links? I do not see them in my config.json or by using 'spotify_sync config list-paths' - Thanks!

@ahhmino
Copy link
Author

ahhmino commented Aug 3, 2023 via email

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