Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
funkwhale
mopidy
Commits
0d93ebea
Verified
Commit
0d93ebea
authored
Oct 03, 2018
by
Eliot Berriot
Browse files
Added authentication token in playback url
parent
3f0ad774
Pipeline
#2182
failed with stages
in 38 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
mopidy_funkwhale/actor.py
View file @
0d93ebea
...
...
@@ -42,4 +42,6 @@ class FunkwhalePlaybackProvider(backend.PlaybackProvider):
url
=
track
[
'listen_url'
]
if
url
.
startswith
(
'/'
):
url
=
self
.
backend
.
config
[
'funkwhale'
][
'url'
]
+
url
if
self
.
backend
.
remote
.
token
:
url
+=
'?jwt='
+
self
.
backend
.
remote
.
token
return
url
mopidy_funkwhale/client.py
View file @
0d93ebea
...
...
@@ -2,7 +2,7 @@ from __future__ import unicode_literals
import
requests
from
mopidy
import
httpclient
from
mopidy
import
httpclient
,
exceptions
from
.
import
Extension
,
__version__
...
...
@@ -42,10 +42,10 @@ def login(session, username, password):
try
:
response
.
raise_for_status
()
except
requests
.
exceptions
.
HTTPError
:
raise
BackendError
(
'Authentication failed for user %s'
%
(
username
,))
raise
exceptions
.
BackendError
(
'Authentication failed for user %s'
%
(
username
,))
token
=
response
.
json
()[
'token'
]
session
.
headers
.
update
({
'Authorization'
:
'JWT %s'
%
(
token
,)})
return
token
class
APIClient
(
object
):
def
__init__
(
self
,
session
):
...
...
@@ -82,8 +82,9 @@ class FunkwhaleClient(object):
)
)
self
.
username
=
config
[
'funkwhale'
][
'username'
]
self
.
token
=
None
if
config
[
'funkwhale'
][
'username'
]:
login
(
self
.
token
=
login
(
self
.
http_client
.
session
,
config
[
'funkwhale'
][
'username'
],
config
[
'funkwhale'
][
'password'
])
tests/test_library.py
View file @
0d93ebea
...
...
@@ -94,6 +94,7 @@ def test_convert_album_to_model():
assert
result
.
album
==
mopidy_funkwhale
.
library
.
convert_to_album
(
payload
[
'album'
])
assert
result
.
artists
==
frozenset
([
mopidy_funkwhale
.
library
.
convert_to_artist
(
payload
[
'artist'
])])
@
pytest
.
mark
.
parametrize
(
'uri, expected'
,
[
(
'funkwhale:albums:42'
,
(
'album'
,
42
)),
(
'funkwhale:tracks:42'
,
(
'track'
,
42
)),
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment