--- a/src/cdplugins/qobuz/qobuz-app.py
+++ b/src/cdplugins/qobuz/qobuz-app.py
@@ -22,11 +22,11 @@
from __future__ import print_function
import sys
import os
-import posixpath
import json
import re
import conftree
import cmdtalkplugin
+from upmplgutils import *
# Using kodi plugin routing plugin: lets use reuse a lot of code from
# the addon.
@@ -77,60 +77,11 @@
is_logged_in = session.login(username, password)
-def trackentries(objid, tracks):
- entries = []
- for track in tracks:
- li = {}
- li['pid'] = objid
- li['id'] = objid + '$' + "%s" % track.id
- li['tt'] = track.name
- li['uri'] = 'http://%s' % httphp + \
- posixpath.join(pathprefix,
- 'track?version=1&trackId=%s' % \
- track.id)
- #msgproc.log("URI: [%s]" % li['uri'])
- li['tp'] = 'it'
- if track.album:
- li['upnp:album'] = track.album.name
- if track.album.image:
- li['upnp:albumArtURI'] = track.album.image
- if track.album.release_date:
- li['releasedate'] = track.album.release_date
- li['upnp:originalTrackNumber'] = str(track.track_num)
- li['upnp:artist'] = track.artist.name
- li['dc:title'] = track.name
- li['discnumber'] = str(track.disc_num)
- li['duration'] = track.duration
- entries.append(li)
- return entries
-
-def direntry(id, pid, title):
- return {'id': id, 'pid' : pid, 'tt': title, 'tp':'ct', 'searchable' : '1'}
-
-def direntries(objid, ttidlist):
- content = []
- for tt,id in ttidlist:
- content.append(direntry(objid + '$' + id, objid, tt))
- return content
-
-def trackid_from_urlpath(a):
- if 'path' not in a:
- raise Exception("No path in args")
- path = a['path']
-
- # pathprefix + 'track?version=1&trackId=trackid
- exp = posixpath.join(pathprefix, '''track\?version=1&trackId=(.+)$''')
- m = re.match(exp, path)
- if m is None:
- raise Exception("trackuri: path [%s] does not match [%s]" % (path, exp))
- trackid = m.group(1)
- return trackid
-
@dispatcher.record('trackuri')
def trackuri(a):
global formatid
msgproc.log("trackuri: [%s]" % a)
- trackid = trackid_from_urlpath(a)
+ trackid = trackid_from_urlpath(pathprefix, a)
maybelogin()
media_url = session.get_media_url(trackid, formatid)
#msgproc.log("%s" % media_url)
@@ -174,7 +125,8 @@
xbmcplugin.entries.append(direntry('0$qobuz$' + url, xbmcplugin.objid, title))
def track_list(tracks):
- xbmcplugin.entries += trackentries(xbmcplugin.objid, tracks)
+ xbmcplugin.entries += trackentries(httphp, pathprefix,
+ xbmcplugin.objid, tracks)
@dispatcher.record('browse')
def browse(a):