|
a/src/mediaserver/cdplugins/pycommon/upmplgutils.py |
|
b/src/mediaserver/cdplugins/pycommon/upmplgutils.py |
|
... |
|
... |
29 |
|
29 |
|
30 |
import posixpath
|
30 |
import posixpath
|
31 |
import re
|
31 |
import re
|
32 |
import sys
|
32 |
import sys
|
33 |
|
33 |
|
|
|
34 |
default_mime = "audio/mpeg"
|
|
|
35 |
default_samplerate = "44100"
|
|
|
36 |
|
|
|
37 |
# This is only used for log messages
|
|
|
38 |
_idprefix = '0$UNKNOWN'
|
|
|
39 |
|
|
|
40 |
def setidprefix(idprefix):
|
|
|
41 |
global _idprefix
|
|
|
42 |
_idprefix = idprefix
|
|
|
43 |
|
34 |
# Bogus class instanciated as global object for helping with reusing
|
44 |
# Bogus class instanciated as global object for helping with reusing
|
35 |
# kodi addon code
|
45 |
# kodi addon code
|
36 |
class XbmcPlugin:
|
46 |
class XbmcPlugin:
|
37 |
SORT_METHOD_TRACKNUM = 1
|
47 |
SORT_METHOD_TRACKNUM = 1
|
38 |
def __init__(self, idprefix):
|
48 |
def __init__(self, idprefix):
|
39 |
global g_idprefix
|
|
|
40 |
self.entries = []
|
49 |
self.entries = []
|
41 |
self.objid = ''
|
50 |
self.objid = ''
|
42 |
self.idprefix = idprefix
|
51 |
self.idprefix = idprefix
|
43 |
g_idprefix = idprefix
|
52 |
setidprefix(idprefix)
|
|
|
53 |
|
44 |
def addDirectoryItem(self, hdl, endpoint, title, isend):
|
54 |
def addDirectoryItem(self, hdl, endpoint, title, isend):
|
45 |
self.entries.append(direntry(self.idprefix + endpoint, self.objid, title))
|
55 |
self.entries.append(direntry(self.idprefix + endpoint, self.objid,
|
46 |
return
|
56 |
title))
|
|
|
57 |
|
47 |
def endOfDirectory(self, h):
|
58 |
def endOfDirectory(self, h):
|
48 |
return
|
59 |
return
|
49 |
def setContent(self, a, b):
|
60 |
def setContent(self, a, b):
|
50 |
return
|
61 |
return
|
51 |
def addSortMethod(self, a, b):
|
62 |
def addSortMethod(self, a, b):
|
52 |
return
|
63 |
return
|
53 |
|
64 |
|
54 |
default_mime = "audio/mpeg"
|
|
|
55 |
default_samplerate = "44100"
|
|
|
56 |
|
65 |
|
57 |
# For now, we pretend that all tracks have the same format (for the
|
66 |
# For now, we pretend that all tracks have the same format (for the
|
58 |
# resource record). For some services this may not be true, we'll see
|
67 |
# resource record). For some services this may not be true, we'll see
|
59 |
# if it can stay this way.
|
68 |
# if it can stay this way.
|
60 |
def setMimeAndSamplerate(m, s):
|
69 |
def setMimeAndSamplerate(m, s):
|
|
... |
|
... |
157 |
ret['upnp:class'] = upnpclass
|
166 |
ret['upnp:class'] = upnpclass
|
158 |
return ret
|
167 |
return ret
|
159 |
|
168 |
|
160 |
|
169 |
|
161 |
def uplog(s):
|
170 |
def uplog(s):
|
162 |
print(("%s: %s" % (g_idprefix, s)).encode('utf-8',errors='replace'),
|
171 |
print(("%s: %s" % (_idprefix, s)).encode('utf-8',errors='replace'),
|
163 |
file=sys.stderr)
|
172 |
file=sys.stderr)
|
164 |
|
173 |
|