This commit is contained in:
Giovanni Fulco 2023-12-11 17:13:16 +01:00 committed by GitHub
commit 3c6cc47bcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 19 deletions

59
main.py
View File

@ -168,6 +168,11 @@ def menu_albums(params):
'name': Addon().get_localized_string(30026), 'name': Addon().get_localized_string(30026),
'thumb': None, 'thumb': None,
'args': {"ltype": "random"} 'args': {"ltype": "random"}
},
'albums_favorites': {
'name': Addon().get_localized_string(30027),
'thumb': None,
'args': {"starred": True}
} }
} }
@ -443,12 +448,16 @@ def list_albums(params):
link_root = navigate_root() link_root = navigate_root()
listing.append(link_root) listing.append(link_root)
if 'starred' in query_args:
if not 'artist_id' in params: if len(items) == albums_per_page:
# Pagination if we've not reached the end of the lsit link_next = navigate_next(params)
# if type(items) != type(True): TO FIX listing.append(link_next)
link_next = navigate_next(params) else:
listing.append(link_next) if not 'artist_id' in params:
# Pagination if we've not reached the end of the lsit
# if type(items) != type(True): TO FIX
link_next = navigate_next(params)
listing.append(link_next)
add_directory_items(create_listing( add_directory_items(create_listing(
listing, listing,
@ -1497,26 +1506,38 @@ def walk_genres():
except KeyError: except KeyError:
yield from () yield from ()
def walk_albums(ltype, size=None, fromYear=None,toYear=None, genre=None, offset=None): def walk_albums(ltype=None, size=None, fromYear=None,toYear=None, genre=None, offset=None, starred=None):
""" """
(ID3 tags) (ID3 tags)
Request all albums for a given genre and iterate over each album. Request all albums for a given genre and iterate over each album.
""" """
if ltype == 'byGenre' and genre is None:
return
if ltype == 'byYear' and (fromYear is None or toYear is None):
return
response = connection.getAlbumList2( if starred:
ltype=ltype, size=size, fromYear=fromYear, toYear=toYear,genre=genre, offset=offset) response = connection.getStarred2()
if not response['starred2']['album']: return
albums = response['starred2']['album']
offset = 0 if not offset else offset
if offset >= len(albums): return
albums_per_page = int(Addon().get_setting('albums_per_page'))
upper = min(len(albums), offset + albums_per_page)
albums = albums[offset:upper]
for album in albums:
yield album
else:
if ltype == 'byGenre' and genre is None:
return
if ltype == 'byYear' and (fromYear is None or toYear is None):
return
if not response["albumList2"]["album"]: response = connection.getAlbumList2(
return ltype=ltype, size=size, fromYear=fromYear, toYear=toYear,genre=genre, offset=offset)
for album in response["albumList2"]["album"]: if not response["albumList2"]["album"]:
yield album return
for album in response["albumList2"]["album"]:
yield album
def walk_album(album_id): def walk_album(album_id):

View File

@ -112,6 +112,10 @@ msgctxt "#30026"
msgid "Random albums" msgid "Random albums"
msgstr "" msgstr ""
msgctxt "#30027"
msgid "Favorite albums"
msgstr ""
msgctxt "#30029" msgctxt "#30029"
msgid "Next page" msgid "Next page"
msgstr "" msgstr ""

View File

@ -112,6 +112,10 @@ msgctxt "#30026"
msgid "Random albums" msgid "Random albums"
msgstr "Albums au hasard" msgstr "Albums au hasard"
msgctxt "#30027"
msgid "Favorite albums"
msgstr "Albums préférés"
msgctxt "#30029" msgctxt "#30029"
msgid "Next page" msgid "Next page"
msgstr "Page suivante" msgstr "Page suivante"

View File

@ -112,6 +112,10 @@ msgctxt "#30026"
msgid "Random albums" msgid "Random albums"
msgstr "Zufällige Alben" msgstr "Zufällige Alben"
msgctxt "#30027"
msgid "Favorite Albums"
msgstr ""
msgctxt "#30029" msgctxt "#30029"
msgid "Next page" msgid "Next page"
msgstr "Nächste Seite" msgstr "Nächste Seite"