|
a/src/mediaserver/cdplugins/gmusic/gmusic-app.py |
|
b/src/mediaserver/cdplugins/gmusic/gmusic-app.py |
|
... |
|
... |
79 |
|
79 |
|
80 |
is_logged_in = session.login(username, password, deviceid)
|
80 |
is_logged_in = session.login(username, password, deviceid)
|
81 |
|
81 |
|
82 |
if not is_logged_in:
|
82 |
if not is_logged_in:
|
83 |
raise Exception("gmusic login failed")
|
83 |
raise Exception("gmusic login failed")
|
|
|
84 |
|
|
|
85 |
setMimeAndSamplerate('audio/mpeg', "44100")
|
84 |
|
86 |
|
85 |
|
87 |
|
86 |
def get_mimeandkbs():
|
88 |
def get_mimeandkbs():
|
87 |
if quality == 'hi':
|
89 |
if quality == 'hi':
|
88 |
return ('audio/mpeg', str(320))
|
90 |
return ('audio/mpeg', str(320))
|
|
... |
|
... |
124 |
image = None
|
126 |
image = None
|
125 |
try:
|
127 |
try:
|
126 |
artnm = item.artist.name if item.artist.name else None
|
128 |
artnm = item.artist.name if item.artist.name else None
|
127 |
except:
|
129 |
except:
|
128 |
artnm = None
|
130 |
artnm = None
|
|
|
131 |
try:
|
|
|
132 |
upnpclass = item.upnpclass if item.upnpclass else None
|
|
|
133 |
except:
|
|
|
134 |
upnpclass = None
|
129 |
xbmcplugin.entries.append(
|
135 |
xbmcplugin.entries.append(
|
130 |
direntry('0$gmusic$' + url, xbmcplugin.objid, title, arturi=image,
|
136 |
direntry('0$gmusic$' + url, xbmcplugin.objid, title, arturi=image,
|
131 |
artist=artnm))
|
137 |
artist=artnm, upnpclass=upnpclass))
|
132 |
|
138 |
|
133 |
def track_list(tracks):
|
139 |
def track_list(tracks):
|
134 |
xbmcplugin.entries += trackentries(httphp, pathprefix,
|
140 |
xbmcplugin.entries += trackentries(httphp, pathprefix,
|
135 |
xbmcplugin.objid, tracks)
|
141 |
xbmcplugin.objid, tracks)
|
136 |
|
142 |
|
|
... |
|
... |
293 |
def search(a):
|
299 |
def search(a):
|
294 |
global xbmcplugin
|
300 |
global xbmcplugin
|
295 |
xbmcplugin = XbmcPlugin('0$gmusic$')
|
301 |
xbmcplugin = XbmcPlugin('0$gmusic$')
|
296 |
msgproc.log("search: [%s]" % a)
|
302 |
msgproc.log("search: [%s]" % a)
|
297 |
objid = a['objid']
|
303 |
objid = a['objid']
|
298 |
field = a['field']
|
304 |
field = a['field'] if 'field' in a else None
|
299 |
value = a['value']
|
305 |
value = a['value']
|
300 |
if re.match('0\$gmusic\$', objid) is None:
|
306 |
if re.match('0\$gmusic\$', objid) is None:
|
301 |
raise Exception("bad objid [%s]" % objid)
|
307 |
raise Exception("bad objid [%s]" % objid)
|
302 |
xbmcplugin.objid = objid
|
308 |
xbmcplugin.objid = objid
|
303 |
maybelogin()
|
309 |
maybelogin()
|
304 |
|
310 |
|
305 |
searchresults = session.search(value)
|
311 |
searchresults = session.search(value)
|
306 |
|
312 |
|
307 |
if field not in ['artist', 'album', 'playlist', 'track']:
|
313 |
if field and field not in ['artist', 'album', 'playlist', 'track']:
|
308 |
msgproc.log('Unknown field \'%s\'' % field)
|
314 |
msgproc.log('Unknown field \'%s\'' % field)
|
309 |
field = None
|
315 |
field = None
|
310 |
if field is None or field == 'artist':
|
316 |
if field is None or field == 'artist':
|
311 |
view(searchresults.artists,
|
317 |
view(searchresults.artists,
|
312 |
urls_from_id(artist_view, searchresults.artists), end=False)
|
318 |
urls_from_id(artist_view, searchresults.artists), end=False)
|
|
... |
|
... |
314 |
view(searchresults.albums,
|
320 |
view(searchresults.albums,
|
315 |
urls_from_id(album_view, searchresults.albums), end=False)
|
321 |
urls_from_id(album_view, searchresults.albums), end=False)
|
316 |
if field is None or field == 'playlist':
|
322 |
if field is None or field == 'playlist':
|
317 |
view(searchresults.playlists,
|
323 |
view(searchresults.playlists,
|
318 |
urls_from_id(playlist_view, searchresults.playlists), end=False)
|
324 |
urls_from_id(playlist_view, searchresults.playlists), end=False)
|
319 |
|
|
|
320 |
if field is None or field == 'track':
|
325 |
if field is None or field == 'track':
|
321 |
track_list(searchresults.tracks)
|
326 |
track_list(searchresults.tracks)
|
322 |
|
327 |
|
323 |
#msgproc.log("%s" % xbmcplugin.entries)
|
328 |
#msgproc.log("%s" % xbmcplugin.entries)
|
324 |
encoded = json.dumps(xbmcplugin.entries)
|
329 |
encoded = json.dumps(xbmcplugin.entries)
|