|
a/src/mediaserver/cdplugins/pycommon/upmplgutils.py |
|
b/src/mediaserver/cdplugins/pycommon/upmplgutils.py |
|
... |
|
... |
28 |
from __future__ import print_function, unicode_literals
|
28 |
from __future__ import print_function, unicode_literals
|
29 |
|
29 |
|
30 |
import posixpath
|
30 |
import posixpath
|
31 |
import re
|
31 |
import re
|
32 |
import sys
|
32 |
import sys
|
|
|
33 |
import conftree
|
33 |
|
34 |
|
34 |
default_mime = "audio/mpeg"
|
35 |
default_mime = "audio/mpeg"
|
35 |
default_samplerate = "44100"
|
36 |
default_samplerate = "44100"
|
36 |
|
37 |
|
37 |
# This is only used for log messages
|
38 |
# This is only used for log messages
|
|
... |
|
... |
164 |
ret['upnp:artist'] = artist
|
165 |
ret['upnp:artist'] = artist
|
165 |
if upnpclass:
|
166 |
if upnpclass:
|
166 |
ret['upnp:class'] = upnpclass
|
167 |
ret['upnp:class'] = upnpclass
|
167 |
return ret
|
168 |
return ret
|
168 |
|
169 |
|
|
|
170 |
# Get user and password from service, from the main configuration
|
|
|
171 |
# file, or possibly from the ohcredentials scratchpad. In the main
|
|
|
172 |
# file, the entries are like:
|
|
|
173 |
# qobuzuser=xxx
|
|
|
174 |
# qobuzpass=yyy
|
|
|
175 |
# In the ohcreds file, they are like:
|
|
|
176 |
# [qobuz]
|
|
|
177 |
# u=xxx
|
|
|
178 |
# p=yyy
|
|
|
179 |
def getserviceuserpass(upconfig, servicename):
|
|
|
180 |
username = upconfig.get(servicename + 'user')
|
|
|
181 |
password = upconfig.get(servicename + 'pass')
|
|
|
182 |
if not username or not password:
|
|
|
183 |
altconf = conftree.ConfSimple('/var/cache/upmpdcli/ohcreds/screds')
|
|
|
184 |
username = altconf.get('u', servicename)
|
|
|
185 |
password = altconf.get('p', servicename)
|
|
|
186 |
return username, password
|
169 |
|
187 |
|
170 |
def uplog(s):
|
188 |
def uplog(s):
|
171 |
if not type(s) == type(u''):
|
189 |
if not type(s) == type(u''):
|
172 |
s = s.decode('utf-8', errors='replace')
|
190 |
s = s.decode('utf-8', errors='replace')
|
173 |
print(("%s: %s" % (_idprefix, s)).encode('utf-8',errors='replace'),
|
191 |
print(("%s: %s" % (_idprefix, s)).encode('utf-8',errors='replace'),
|