|
a/src/mediaserver/cdplugins/pycommon/upmplgutils.py |
|
b/src/mediaserver/cdplugins/pycommon/upmplgutils.py |
|
... |
|
... |
45 |
return
|
45 |
return
|
46 |
def setContent(self, a, b):
|
46 |
def setContent(self, a, b):
|
47 |
return
|
47 |
return
|
48 |
def addSortMethod(self, a, b):
|
48 |
def addSortMethod(self, a, b):
|
49 |
return
|
49 |
return
|
|
|
50 |
|
|
|
51 |
default_mime = "audio/mpeg"
|
|
|
52 |
default_samplerate = "44100"
|
|
|
53 |
|
|
|
54 |
# For now, we pretend that all tracks have the same format (for the
|
|
|
55 |
# resource record). For some services this may not be true, we'll see
|
|
|
56 |
# if it can stay this way.
|
|
|
57 |
def setMimeAndSamplerate(m, s):
|
|
|
58 |
global default_mime, default_samplerate
|
|
|
59 |
default_mime = m
|
|
|
60 |
default_samplerate = s
|
50 |
|
61 |
|
51 |
def trackentries(httphp, pathprefix, objid, tracks):
|
62 |
def trackentries(httphp, pathprefix, objid, tracks):
|
52 |
"""
|
63 |
"""
|
53 |
Transform a list of Track objects to the format expected by the parent
|
64 |
Transform a list of Track objects to the format expected by the parent
|
54 |
|
65 |
|
|
... |
|
... |
65 |
configured host:port and pathprefix arguments and track Id:
|
76 |
configured host:port and pathprefix arguments and track Id:
|
66 |
|
77 |
|
67 |
http://host:port/pathprefix/track?version=1&trackId=<trackid>
|
78 |
http://host:port/pathprefix/track?version=1&trackId=<trackid>
|
68 |
|
79 |
|
69 |
"""
|
80 |
"""
|
|
|
81 |
global default_mime, default_samplerate
|
70 |
|
82 |
|
71 |
entries = []
|
83 |
entries = []
|
72 |
for track in tracks:
|
84 |
for track in tracks:
|
73 |
if not track.available:
|
85 |
if not track.available:
|
74 |
continue
|
86 |
continue
|
|
... |
|
... |
89 |
li['upnp:originalTrackNumber'] = str(track.track_num)
|
101 |
li['upnp:originalTrackNumber'] = str(track.track_num)
|
90 |
li['upnp:artist'] = track.artist.name
|
102 |
li['upnp:artist'] = track.artist.name
|
91 |
li['dc:title'] = track.name
|
103 |
li['dc:title'] = track.name
|
92 |
li['discnumber'] = str(track.disc_num)
|
104 |
li['discnumber'] = str(track.disc_num)
|
93 |
li['duration'] = track.duration
|
105 |
li['duration'] = track.duration
|
|
|
106 |
li['upnp:class'] = track.upnpclass
|
|
|
107 |
li['res:mime'] = default_mime
|
|
|
108 |
li['res:samplefreq'] = default_samplerate
|
|
|
109 |
|
94 |
entries.append(li)
|
110 |
entries.append(li)
|
95 |
return entries
|
111 |
return entries
|
96 |
|
112 |
|
97 |
def trackid_from_urlpath(pathprefix, a):
|
113 |
def trackid_from_urlpath(pathprefix, a):
|
98 |
"""
|
114 |
"""
|
|
... |
|
... |
119 |
raise Exception("trackuri: path [%s] does not match [%s]" % (path, exp))
|
135 |
raise Exception("trackuri: path [%s] does not match [%s]" % (path, exp))
|
120 |
trackid = m.group(1)
|
136 |
trackid = m.group(1)
|
121 |
return trackid
|
137 |
return trackid
|
122 |
|
138 |
|
123 |
|
139 |
|
124 |
def direntry(id, pid, title, arturi=None, artist=None):
|
140 |
def direntry(id, pid, title, arturi=None, artist=None, upnpclass=None):
|
125 |
""" Create container entry in format expected by parent """
|
141 |
""" Create container entry in format expected by parent """
|
126 |
ret = {'id':id, 'pid':pid, 'tt':title, 'tp':'ct', 'searchable':'1'}
|
142 |
ret = {'id':id, 'pid':pid, 'tt':title, 'tp':'ct', 'searchable':'1'}
|
127 |
if arturi:
|
143 |
if arturi:
|
128 |
ret['upnp:albumArtURI'] = arturi
|
144 |
ret['upnp:albumArtURI'] = arturi
|
129 |
if artist:
|
145 |
if artist:
|
130 |
ret['upnp:artist'] = artist
|
146 |
ret['upnp:artist'] = artist
|
|
|
147 |
if upnpclass:
|
|
|
148 |
ret['upnp:class'] = upnpclass
|
131 |
return ret
|
149 |
return ret
|
132 |
|
|
|
133 |
|
|
|
134 |
def direntries(objid, ttidlist):
|
|
|
135 |
""" Create a list of directory entries """
|
|
|
136 |
content = []
|
|
|
137 |
for tt,id in ttidlist:
|
|
|
138 |
content.append(direntry(objid + '$' + id, objid, tt))
|
|
|
139 |
return content
|
|
|
140 |
|
|
|