Skip to content

Instantly share code, notes, and snippets.

@mcarlton00
Created January 9, 2024 22:03
Show Gist options
  • Select an option

  • Save mcarlton00/c08a6046d67e6c85643162da826e1ac1 to your computer and use it in GitHub Desktop.

Select an option

Save mcarlton00/c08a6046d67e6c85643162da826e1ac1 to your computer and use it in GitHub Desktop.
Convert jellyfin favorites into a playlist
import requests
server_url = 'http://192.168.0.147:8096'
username = 'your_username'
password = 'your_password'
auth_data = {
'username': username,
'Pw': password
}
headers = {}
authorization = (
'MediaBrowser , '
'Client="other", '
'Device="script", '
'DeviceId="script1", '
'Version="0.0.0"'
)
headers['Authorization'] = authorization
r = requests.post(server_url + '/Users/AuthenticateByName', headers=headers, json=auth_data)
token = r.json().get('AccessToken')
user_id = r.json().get('User').get('Id')
headers['Authorization'] = f'{authorization}, Token="{token}"'
raw_favorites = requests.get(f'{server_url}/Users/{user_id}/Items?IncludeItemTypes=Music&Recursive=True&IsFavorite=True&Fields=Path', headers=headers)
playlist_id = '6512561be25890c4c711378d2235382a'
for item in raw_favorites.json().get('Items'):
item_id = item.get('Id')
r = requests.post(f'{server_url}/Playlists/{playlist_id}/Items?Ids={item_id}&userId={user_id}', headers=headers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment