mirror of
https://github.com/jellyfin/jellycon.git
synced 2025-02-18 12:50:23 +00:00
Add instant mix and shuffle all features for music
This commit is contained in:
parent
351c872c46
commit
3dfde5eb04
@ -343,6 +343,7 @@ def show_menu(params):
|
||||
|
||||
action_items = []
|
||||
|
||||
# Additional items to include in the context menu for different item types
|
||||
if result["Type"] in ["Episode", "Movie", "Music", "Video", "Audio", "TvChannel", "Program", "MusicVideo"]:
|
||||
li = xbmcgui.ListItem(translate_string(30314), offscreen=True)
|
||||
li.setProperty('menu_id', 'play')
|
||||
@ -353,6 +354,17 @@ def show_menu(params):
|
||||
li.setProperty('menu_id', 'play_all')
|
||||
action_items.append(li)
|
||||
|
||||
if result["Type"] in ["MusicArtist", "MusicAlbum", "Playlist", "Series", "Season"]:
|
||||
li = xbmcgui.ListItem(translate_string(30448), offscreen=True)
|
||||
li.setProperty('menu_id', 'shuffle')
|
||||
action_items.append(li)
|
||||
|
||||
if result["Type"] in ["MusicArtist", "MusicAlbum", "Audio"]:
|
||||
li = xbmcgui.ListItem(translate_string(30449), offscreen=True)
|
||||
li.setProperty('menu_id', 'instant_mix')
|
||||
action_items.append(li)
|
||||
|
||||
|
||||
if result["Type"] in ["Episode", "Movie", "Video", "TvChannel", "Program", "MusicVideo"]:
|
||||
li = xbmcgui.ListItem(translate_string(30275), offscreen=True)
|
||||
li.setProperty('menu_id', 'transcode')
|
||||
@ -499,6 +511,14 @@ def show_menu(params):
|
||||
elif selected_action == "play_all":
|
||||
play_action(params)
|
||||
|
||||
elif selected_action == "shuffle":
|
||||
params["action"] = "shuffle"
|
||||
play_action(params)
|
||||
|
||||
elif selected_action == "instant_mix":
|
||||
params["action"] = "instant_mix"
|
||||
play_action(params)
|
||||
|
||||
elif selected_action == "play_trailer":
|
||||
play_item_trailer(item_id)
|
||||
|
||||
|
@ -255,8 +255,30 @@ def play_file(play_info):
|
||||
log.debug("Playfile item was None, so can not play!")
|
||||
return
|
||||
|
||||
# Generate an instant mix based on the item
|
||||
if action == 'instant_mix':
|
||||
max_queue = int(settings.getSetting('max_play_queue'))
|
||||
url_root = '/Items/{}/InstantMix'.format(item_id)
|
||||
url_params = {
|
||||
'UserId': api.user_id,
|
||||
'Fields': 'MediaSources',
|
||||
'IncludeItemTypes': 'Audio',
|
||||
'SortBy': 'SortName',
|
||||
'limit': max_queue
|
||||
}
|
||||
url = get_jellyfin_url(url_root, url_params)
|
||||
result = api.get(url)
|
||||
log.debug("PlayAllFiles items: {0}".format(result))
|
||||
|
||||
# process each item
|
||||
items = result["Items"]
|
||||
if items is None:
|
||||
items = []
|
||||
return play_all_files(items)
|
||||
|
||||
# if this is a season, playlist or album then play all items in that parent
|
||||
if result.get("Type") in ["Season", "MusicArtist", "MusicAlbum", "Playlist"]:
|
||||
max_queue = int(settings.getSetting('max_play_queue'))
|
||||
log.debug("PlayAllFiles for parent item id: {0}".format(item_id))
|
||||
url_root = '/Users/{}/Items'.format(api.user_id)
|
||||
# Look specifically for episodes or audio files
|
||||
@ -264,8 +286,12 @@ def play_file(play_info):
|
||||
'ParentId': item_id,
|
||||
'Fields': 'MediaSources',
|
||||
'IncludeItemTypes': 'Episode,Audio',
|
||||
'Recursive': True
|
||||
'Recursive': True,
|
||||
'SortBy': 'SortName',
|
||||
'limit': max_queue
|
||||
}
|
||||
if action == 'shuffle':
|
||||
url_params['SortBy'] = 'Random'
|
||||
|
||||
url = get_jellyfin_url(url_root, url_params)
|
||||
result = api.get(url)
|
||||
|
Loading…
x
Reference in New Issue
Block a user