|
a/src/mediaserver/cdplugins/tidal/tidal-app.py |
|
b/src/mediaserver/cdplugins/tidal/tidal-app.py |
|
... |
|
... |
87 |
"Must be lossless/high/low")
|
87 |
"Must be lossless/high/low")
|
88 |
tidalconf = tidalapi.Config(quality)
|
88 |
tidalconf = tidalapi.Config(quality)
|
89 |
session = tidalapi.Session(config=tidalconf)
|
89 |
session = tidalapi.Session(config=tidalconf)
|
90 |
session.login(username, password)
|
90 |
session.login(username, password)
|
91 |
is_logged_in = True
|
91 |
is_logged_in = True
|
|
|
92 |
if quality == Quality.lossless:
|
|
|
93 |
setMimeAndSamplerate('audio/flac', "44100")
|
|
|
94 |
else:
|
|
|
95 |
setMimeAndSamplerate('audio/mpeg', "44100")
|
92 |
|
96 |
|
93 |
|
97 |
|
94 |
def get_mimeandkbs():
|
98 |
def get_mimeandkbs():
|
95 |
if quality == Quality.lossless:
|
99 |
if quality == Quality.lossless:
|
96 |
return ('audio/flac', str(1411))
|
100 |
return ('audio/flac', str(1411))
|
97 |
elif quality == Quality.high:
|
101 |
elif quality == Quality.high:
|
98 |
return ('video/x-flv', str(320))
|
102 |
return ('audio/mpeg', str(320))
|
99 |
else:
|
103 |
else:
|
100 |
return ('video/x-flv', str(96))
|
104 |
return ('audio/mpeg', str(96))
|
101 |
|
105 |
|
102 |
@dispatcher.record('trackuri')
|
106 |
@dispatcher.record('trackuri')
|
103 |
def trackuri(a):
|
107 |
def trackuri(a):
|
104 |
msgproc.log("trackuri: [%s]" % a)
|
108 |
msgproc.log("trackuri: [%s]" % a)
|
105 |
trackid = trackid_from_urlpath(pathprefix, a)
|
109 |
trackid = trackid_from_urlpath(pathprefix, a)
|
|
... |
|
... |
132 |
try:
|
136 |
try:
|
133 |
image = item.image if item.image else None
|
137 |
image = item.image if item.image else None
|
134 |
except:
|
138 |
except:
|
135 |
image = None
|
139 |
image = None
|
136 |
try:
|
140 |
try:
|
|
|
141 |
upnpclass = item.upnpclass if item.upnpclass else None
|
|
|
142 |
except:
|
|
|
143 |
upnpclass = None
|
|
|
144 |
try:
|
137 |
artnm = item.artist.name if item.artist.name else None
|
145 |
artnm = item.artist.name if item.artist.name else None
|
138 |
except:
|
146 |
except:
|
139 |
artnm = None
|
147 |
artnm = None
|
140 |
xbmcplugin.entries.append(
|
148 |
xbmcplugin.entries.append(
|
141 |
direntry('0$tidal$' + url, xbmcplugin.objid, title, arturi=image,
|
149 |
direntry('0$tidal$' + url, xbmcplugin.objid, title, arturi=image,
|
142 |
artist=artnm))
|
150 |
artist=artnm, upnpclass=upnpclass))
|
143 |
|
151 |
|
144 |
def track_list(tracks):
|
152 |
def track_list(tracks):
|
145 |
xbmcplugin.entries += trackentries(httphp, pathprefix,
|
153 |
xbmcplugin.entries += trackentries(httphp, pathprefix,
|
146 |
xbmcplugin.objid, tracks)
|
154 |
xbmcplugin.objid, tracks)
|
147 |
|
155 |
|
|
... |
|
... |
369 |
def search(a):
|
377 |
def search(a):
|
370 |
global xbmcplugin
|
378 |
global xbmcplugin
|
371 |
xbmcplugin = XbmcPlugin('0$tidal$')
|
379 |
xbmcplugin = XbmcPlugin('0$tidal$')
|
372 |
msgproc.log("search: [%s]" % a)
|
380 |
msgproc.log("search: [%s]" % a)
|
373 |
objid = a['objid']
|
381 |
objid = a['objid']
|
374 |
field = a['field']
|
382 |
field = a['field'] if 'field' in a else None
|
375 |
value = a['value']
|
383 |
value = a['value']
|
376 |
if re.match('0\$tidal\$', objid) is None:
|
384 |
if re.match('0\$tidal\$', objid) is None:
|
377 |
raise Exception("bad objid [%s]" % objid)
|
385 |
raise Exception("bad objid [%s]" % objid)
|
378 |
xbmcplugin.objid = objid
|
386 |
xbmcplugin.objid = objid
|
379 |
maybelogin()
|
387 |
maybelogin()
|
380 |
|
388 |
|
|
|
389 |
# field is mandatory and maybe 'artist', 'album', 'playlist', 'track'
|
|
|
390 |
# But quite frequently, our caller does not set it. So need to run multiple
|
|
|
391 |
# searches
|
|
|
392 |
if field is None or field = 'artist':
|
|
|
393 |
searchresults = session.search('artist', value)
|
|
|
394 |
view(searchresults.artists,
|
|
|
395 |
urls_from_id(artist_view, searchresults.artists), end=False)
|
|
|
396 |
if field is None or field = 'album':
|
381 |
searchresults = session.search(field, value)
|
397 |
searchresults = session.search('album', value)
|
382 |
msgproc.log("search: Got %d artists" % len(searchresults.artists))
|
398 |
view(searchresults.albums,
|
383 |
view(searchresults.artists, urls_from_id(artist_view, searchresults.artists),
|
399 |
urls_from_id(album_view, searchresults.albums), end=False)
|
384 |
end=False)
|
400 |
if field is None or field = 'playlist':
|
385 |
view(searchresults.albums, urls_from_id(album_view, searchresults.albums),
|
401 |
searchresults = session.search('playlist', value)
|
386 |
end=False)
|
402 |
view(searchresults.playlists,
|
387 |
view(searchresults.playlists, urls_from_id(playlist_view,
|
403 |
urls_from_id(playlist_view, searchresults.playlists), end=False)
|
388 |
searchresults.playlists),
|
404 |
if field is None or field = 'track':
|
389 |
end=False)
|
405 |
searchresults = session.search('track', value)
|
390 |
track_list(searchresults.tracks)
|
406 |
track_list(searchresults.tracks)
|
391 |
#msgproc.log("%s" % xbmcplugin.entries)
|
407 |
#msgproc.log("%s" % xbmcplugin.entries)
|
392 |
encoded = json.dumps(xbmcplugin.entries)
|
408 |
encoded = json.dumps(xbmcplugin.entries)
|
393 |
return {"entries" : encoded}
|
409 |
return {"entries" : encoded}
|
394 |
|
410 |
|