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

added small plugin for just exporting the upmpdcli radio list

parent a22c924d
# Copyright (C) 2021 J.F.Dockes
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <>.
import sys
import os
import json
import re
import cmdtalkplugin
import conftree
from upmplgutils import uplog, setidprefix
import upradioconf
# Func name to method mapper
dispatcher = cmdtalkplugin.Dispatch()
# Pipe message handler
msgproc = cmdtalkplugin.Processor(dispatcher)
def _initradios():
if "UPMPD_CONFIG" not in os.environ:
raise Exception("No UPMPD_CONFIG in environment")
config = conftree.ConfSimple(os.environ["UPMPD_CONFIG"])
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"]
def trackuri(a):
# We generate URIs which directly point to the radio, so this
# method should never be called.
raise Exception("trackuri: should not be called for upradios!")
def browse(a):
if 'objid' not in a:
raise Exception("No objid in args")
objid = a['objid']
entries = []
for radio in _g_radios:
entries.append(_radioToEntry(objid, len(entries), radio))
encoded = json.dumps(entries)
return {"entries" : encoded, "nocache" : "0"}
def search(a):
msgproc.log("search: [%s]" % a)
return {"entries" : [], "nocache" : "0"}
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