Commit b649cb76 authored by Jean-Francois Dockes's avatar Jean-Francois Dockes
Browse files

Qobuz: behave closer to the web player

parent bbe64201
......@@ -159,4 +159,5 @@ def direntry(id, pid, title, arturi=None, artist=None, upnpclass=None):
def uplog(s):
print("%s: %s" % (g_idprefix, s), file=sys.stderr)
print(("%s: %s" % (g_idprefix, s)).encode('utf-8'), file=sys.stderr)
......@@ -166,8 +166,8 @@ def browse(a):
@plugin.route('/')
def root():
add_directory("Discover", whats_new)
add_directory('Genres', root_genres)
add_directory('Discover Catalog', whats_new)
add_directory('Discover Genres', root_genres)
add_directory('Favourites', my_music)
@plugin.route('/root_genres')
......@@ -177,32 +177,25 @@ def root_genres():
@plugin.route('/genre/<genre_id>')
def genre_view(genre_id):
items = session.get_genres(genre_id)
if False and len(items) != 0:
# List subgenres. We don't do it any more as they all contain
# the same data (there is no actual discrimination between
# e.g. metal and pop, same list arrives.
view(items, urls_from_id(genre_view, items))
else:
add_directory('New Releases', plugin.url_for(genre_view_type,
genre_id=genre_id,
type='new-releases'))
add_directory('Qobuz Playlists', plugin.url_for(genre_view_playlists,
genre_id=genre_id))
add_directory('Most Streamed', plugin.url_for(genre_view_type,
genre_id=genre_id,
type='most-streamed'))
add_directory('Most Downloaded', plugin.url_for(genre_view_type,
genre_id=genre_id,
type='best-sellers'))
add_directory('Editor Picks', plugin.url_for(genre_view_type,
genre_id=genre_id,
type='editor-picks'))
add_directory('Press Awards', plugin.url_for(genre_view_type,
genre_id=genre_id,
type='press-awards'))
items = session.get_featured_albums(genre_id)
view(items, urls_from_id(album_view, items))
add_directory('New Releases', plugin.url_for(genre_view_type,
genre_id=genre_id,
type='new-releases'))
add_directory('Qobuz Playlists', plugin.url_for(genre_view_playlists,
genre_id=genre_id))
add_directory('Most Streamed', plugin.url_for(genre_view_type,
genre_id=genre_id,
type='most-streamed'))
add_directory('Most Downloaded', plugin.url_for(genre_view_type,
genre_id=genre_id,
type='best-sellers'))
add_directory('Editor Picks', plugin.url_for(genre_view_type,
genre_id=genre_id,
type='editor-picks'))
add_directory('Press Awards', plugin.url_for(genre_view_type,
genre_id=genre_id,
type='press-awards'))
items = session.get_featured_albums(genre_id)
view(items, urls_from_id(album_view, items))
@plugin.route('/featured/<genre_id>/<type>')
def genre_view_type(genre_id, type):
......
......@@ -58,10 +58,14 @@ class Session(object):
return [_parse_artist(art) for art in data['artists']['items']]
return []
def get_featured_albums(self, genre_id=None, type='new-releases'):
def get_featured_albums(self, genre_id='None', type='new-releases'):
#uplog("get_featured_albums, genre_id %s type %s " % (genre_id, type))
data = self.api.album_getFeatured(type=type,
genre_id=genre_id, limit=100)
if genre_id != 'None':
data = self.api.album_getFeatured(type=type,
genre_id=genre_id, limit=100)
else:
data = self.api.album_getFeatured(type=type, limit=100)
try:
albums = [_parse_album(alb) for alb in data['albums']['items']]
if albums:
......@@ -70,9 +74,13 @@ class Session(object):
pass
return []
def get_featured_playlists(self, genre_id=None):
data = self.api.playlist_getFeatured(type='editor-picks',
genre_id=genre_id, limit=100)
def get_featured_playlists(self, genre_id='None'):
if genre_id != 'None':
data = self.api.playlist_getFeatured(type='editor-picks',
genre_id=genre_id, limit=100)
else:
data = self.api.playlist_getFeatured(type='editor-picks',
limit=100)
if data and 'playlists' in data:
return [_parse_playlist(pl) for pl in data['playlists']['items']]
return []
......@@ -84,11 +92,10 @@ class Session(object):
# catalog_getFeaturedTypes call which returns the above list, I
# could not find a way to pass the type parameter to
# catalog_getFeatured (setting type triggers an
# error). album_getFeatured() accepts type, but it's not clear
# what it does.
# error). album_getFeatured() and playlist_getFeatured() do accept type.
def get_featured_items(self, content_type, type=''):
#uplog("FEATURED TYPES: %s" % self.api.catalog_getFeaturedTypes())
limit = '100'
limit = '40'
data = self.api.catalog_getFeatured(limit=limit)
#uplog("Featured: %s" % json.dumps(data,indent=4)))
if content_type == 'artists':
......@@ -104,7 +111,8 @@ class Session(object):
def get_genres(self, parent=None):
data = self.api.genre_list(parent_id=parent)
return [_parse_genre(g) for g in data['genres']['items']]
return [Genre(id=None, name='All Genres')] + \
[_parse_genre(g) for g in data['genres']['items']]
def _search1(self, query, tp):
limit = 200
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment