Add ability to shuffle music genres
This commit is contained in:
@@ -343,13 +343,14 @@ def show_menu(params):
|
||||
li.setProperty('menu_id', 'play')
|
||||
action_items.append(li)
|
||||
|
||||
if result["Type"] in ["Season", "MusicArtist", "MusicAlbum", "Playlist"]:
|
||||
if result["Type"] in ["Season", "MusicArtist", "MusicAlbum", "Playlist",
|
||||
"MusicGenre"]:
|
||||
li = xbmcgui.ListItem(translate_string(30317), offscreen=True)
|
||||
li.setProperty('menu_id', 'play_all')
|
||||
action_items.append(li)
|
||||
|
||||
if result["Type"] in ["MusicArtist", "MusicAlbum", "Playlist",
|
||||
"Series", "Season"]:
|
||||
"Series", "Season", "MusicGenre"]:
|
||||
li = xbmcgui.ListItem(translate_string(30448), offscreen=True)
|
||||
li.setProperty('menu_id', 'shuffle')
|
||||
action_items.append(li)
|
||||
@@ -366,7 +367,8 @@ def show_menu(params):
|
||||
action_items.append(li)
|
||||
|
||||
if result["Type"] in ["Episode", "Movie", "Music", "Video", "Audio",
|
||||
"MusicArtist", "MusicAlbum", "MusicVideo"]:
|
||||
"MusicArtist", "MusicAlbum", "MusicVideo",
|
||||
"MusicGenre"]:
|
||||
li = xbmcgui.ListItem(translate_string(30402), offscreen=True)
|
||||
li.setProperty('menu_id', 'add_to_playlist')
|
||||
action_items.append(li)
|
||||
|
||||
@@ -37,11 +37,13 @@ class HomeWindow:
|
||||
self.window.clearProperty(key)
|
||||
|
||||
|
||||
def add_menu_directory_item(label, path, folder=True, art=None):
|
||||
def add_menu_directory_item(label, path, folder=True, art=None, properties=None):
|
||||
li = xbmcgui.ListItem(label, path=path, offscreen=True)
|
||||
if art is None:
|
||||
art = {}
|
||||
art["thumb"] = addon.getAddonInfo('icon')
|
||||
if properties is not None:
|
||||
li.setProperties(properties)
|
||||
li.setArt(art)
|
||||
|
||||
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=path, listitem=li, isFolder=folder)
|
||||
|
||||
@@ -324,7 +324,9 @@ def show_genre_list(menu_params):
|
||||
for genre in result:
|
||||
title = genre.get('Name', translate_string(30250))
|
||||
|
||||
params["GenreIds"] = genre.get("Id")
|
||||
genre_id = genre.get("Id")
|
||||
params["GenreIds"] = genre_id
|
||||
li_properties = {"id": genre_id}
|
||||
|
||||
if parent_id is not None:
|
||||
params["ParentId"] = parent_id
|
||||
@@ -337,7 +339,7 @@ def show_genre_list(menu_params):
|
||||
"&mode=GET_CONTENT" +
|
||||
"&media_type=" + kodi_type)
|
||||
log.debug("addMenuDirectoryItem: {0} - {1} - {2}".format(title, url, art))
|
||||
add_menu_directory_item(title, url, art=art)
|
||||
add_menu_directory_item(title, url, art=art, properties=li_properties)
|
||||
|
||||
xbmcplugin.endOfDirectory(int(sys.argv[1]))
|
||||
|
||||
|
||||
@@ -286,19 +286,24 @@ def play_file(play_info):
|
||||
*all* items in that parent.
|
||||
* Taking the max queue size setting into account
|
||||
'''
|
||||
if result.get("Type") in ["Season", "MusicArtist", "MusicAlbum", "Playlist", "CollectionFolder"]:
|
||||
if result.get("Type") in ["Season", "MusicArtist", "MusicAlbum",
|
||||
"Playlist", "CollectionFolder", "MusicGenre"]:
|
||||
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
|
||||
url_params = {
|
||||
'ParentId': item_id,
|
||||
'Fields': 'MediaSources',
|
||||
'IncludeItemTypes': 'Episode,Audio',
|
||||
'Recursive': True,
|
||||
'SortBy': 'SortName',
|
||||
'limit': max_queue
|
||||
}
|
||||
if result.get("Type") == "MusicGenre":
|
||||
url_params['genreIds'] = item_id
|
||||
else:
|
||||
url_params['ParentId'] = item_id
|
||||
|
||||
if action == 'shuffle':
|
||||
url_params['SortBy'] = 'Random'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user