a/src/mediaserver/cdplugins/qobuz/qobuz-app.py b/src/mediaserver/cdplugins/qobuz/qobuz-app.py
...
...
43
# Pipe message handler
43
# Pipe message handler
44
msgproc = cmdtalkplugin.Processor(dispatcher)
44
msgproc = cmdtalkplugin.Processor(dispatcher)
45
45
46
session = Session()
46
session = Session()
47
47
48
is_logged_in = False
48
_g_loginok = False
49
49
50
def maybelogin(a={}):
50
def maybelogin(a={}):
51
    global formatid
51
    global formatid
52
    global httphp
52
    global httphp
53
    global pathprefix
53
    global pathprefix
54
    global is_logged_in
54
    global _g_loginok
55
55
56
    # Do this always
56
    # Do this always
57
    setidprefix(qobidprefix)
57
    setidprefix(qobidprefix)
58
58
59
    if is_logged_in:
59
    if _g_loginok:
60
        return True
60
        return True
61
61
62
    if "UPMPD_HTTPHOSTPORT" not in os.environ:
62
    if "UPMPD_HTTPHOSTPORT" not in os.environ:
63
        raise Exception("No UPMPD_HTTPHOSTPORT in environment")
63
        raise Exception("No UPMPD_HTTPHOSTPORT in environment")
64
    httphp = os.environ["UPMPD_HTTPHOSTPORT"]
64
    httphp = os.environ["UPMPD_HTTPHOSTPORT"]
...
...
87
        setMimeAndSamplerate("application/flac", "44100")
87
        setMimeAndSamplerate("application/flac", "44100")
88
88
89
    if not username or not password:
89
    if not username or not password:
90
        raise Exception("qobuzuser and/or qobuzpass not set in configuration")
90
        raise Exception("qobuzuser and/or qobuzpass not set in configuration")
91
91
92
    is_logged_in = session.login(username, password)
92
    _g_loginok = session.login(username, password)
93
93
94
94
95
# This is not used by the media server. It's for use by the OpenHome
95
# This is not used by the media server. It's for use by the OpenHome
96
# Credentials service
96
# Credentials service
97
@dispatcher.record('login')
97
@dispatcher.record('login')
98
def login(a):
98
def login(a):
99
    maybelogin(a)
99
    maybelogin(a)
100
    appid, token = session.get_appid_and_token()
100
    appid, token = session.get_appid_and_token()
101
    if token is None:
102
        # login failed. cmdtalk does not like None values
103
        token = ''
101
    return {'appid': appid, 'token' : token}
104
    return {'appid': appid, 'token' : token}
102
    
105
    
103
    
106
    
104
@dispatcher.record('trackuri')
107
@dispatcher.record('trackuri')
105
def trackuri(a):
108
def trackuri(a):