|
a/src/cdplugins/qobuz/session.py |
|
b/src/cdplugins/qobuz/session.py |
|
... |
|
... |
3 |
# much alone as possible.
|
3 |
# much alone as possible.
|
4 |
from __future__ import print_function
|
4 |
from __future__ import print_function
|
5 |
|
5 |
|
6 |
import sys
|
6 |
import sys
|
7 |
import json
|
7 |
import json
|
8 |
from models import Artist, Album, Track, Playlist, SearchResult, Category, Role
|
8 |
from models import Artist, Album, Track, Playlist, SearchResult, Category
|
9 |
from qobuz.api import raw
|
9 |
from qobuz.api import raw
|
10 |
|
10 |
|
11 |
class Session(object):
|
11 |
class Session(object):
|
12 |
def __init__(self):
|
12 |
def __init__(self):
|
13 |
self.api = None
|
13 |
self.api = None
|
|
... |
|
... |
99 |
return SearchResult(artists=ar, albums=al, playlists=pl, tracks=tr)
|
99 |
return SearchResult(artists=ar, albums=al, playlists=pl, tracks=tr)
|
100 |
|
100 |
|
101 |
|
101 |
|
102 |
def _parse_artist(json_obj):
|
102 |
def _parse_artist(json_obj):
|
103 |
artist = Artist(id=json_obj['id'], name=json_obj['name'])
|
103 |
artist = Artist(id=json_obj['id'], name=json_obj['name'])
|
104 |
try:
|
|
|
105 |
artist.role = Role(json_obj['type'])
|
|
|
106 |
except:
|
|
|
107 |
pass
|
|
|
108 |
return artist
|
104 |
return artist
|
109 |
|
105 |
|
110 |
def _parse_album(json_obj, artist=None, artists=None):
|
106 |
def _parse_album(json_obj, artist=None, artists=None):
|
111 |
if artist is None and 'artist' in json_obj:
|
107 |
if artist is None and 'artist' in json_obj:
|
112 |
artist = _parse_artist(json_obj['artist'])
|
108 |
artist = _parse_artist(json_obj['artist'])
|