Commit ed33b30f authored by Jean-Francois Dockes's avatar Jean-Francois Dockes
Browse files

media server radios: share entry-generating method

parent 465ee285
......@@ -77,6 +77,18 @@ class RadioIterator:
raise StopIteration
def radioToEntry(pid, idx, radio):
id = pid + '$e' + str(idx)
return {
'pid': pid,
'id': id,
'uri': radio["streamUri"],
'tp': 'it',
'res:mime': "audio/mpeg",
'upnp:class': 'object.item.audioItem.musicTrack',
'upnp:albumArtURI': radio["artUri"],
'tt': radio["title"]
}
if __name__ == "__main__":
......
......@@ -39,19 +39,6 @@ def _initradios():
global _g_radios
_g_radios = upradioconf.UpmpdcliRadios(config)
def _radioToEntry(pid, idx, radio):
id = pid + '$e' + str(idx)
return {
'pid': pid,
'id': id,
'uri': radio["streamUri"],
'tp': 'it',
'res:mime': "audio/mpeg",
'upnp:class': 'object.item.audioItem.musicTrack',
'upnp:albumArtURI': radio["artUri"],
'tt': radio["title"]
}
@dispatcher.record('trackuri')
def trackuri(a):
# We generate URIs which directly point to the radio, so this
......@@ -67,7 +54,7 @@ def browse(a):
entries = []
for radio in _g_radios:
entries.append(_radioToEntry(objid, len(entries), radio))
entries.append(upradioconf.radioToEntry(objid, len(entries), radio))
encoded = json.dumps(entries)
return {"entries" : encoded, "nocache" : "0"}
......
......@@ -81,20 +81,6 @@ class Playlists(object):
return [direntry(pid + 'playlists', pid,
str(len(self.utidx)) + ' playlists'),]
def radioToEntry(self, pid, idx, radio):
id = pid + '$e' + str(idx)
return {
'pid': pid,
'id': id,
'uri': radio["streamUri"],
'tp': 'it',
'res:mime': "audio/mpeg",
'upnp:class': 'object.item.audioItem.musicTrack',
'upnp:albumArtURI': radio["artUri"],
'tt': radio["title"]
}
# Browse method
# objid is like playlists$p<index>
# flag is meta or children.
......@@ -120,7 +106,7 @@ class Playlists(object):
elif idx == len(self.utidx):
# Special "upmpdcli radios" playlist. Don't sort, the user chose the order.
for radio in self._radios:
entries.append(self.radioToEntry(pid, len(entries), radio))
entries.append(upradioconf.radioToEntry(pid, len(entries), radio))
return entries
else:
pldoc = rcldocs[self.utidx[idx]]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment