Make Plugin with with mopidy 3
parent
28c2b561e5
commit
3a1868f6fb
|
@ -3,7 +3,7 @@ stages:
|
||||||
|
|
||||||
test:
|
test:
|
||||||
stage: test
|
stage: test
|
||||||
image: python:2
|
image: python:3
|
||||||
before_script:
|
before_script:
|
||||||
- apt-get update
|
- apt-get update
|
||||||
- apt-get install libgirepository1.0-dev -y
|
- apt-get install libgirepository1.0-dev -y
|
||||||
|
|
|
@ -22,9 +22,7 @@ Features
|
||||||
Installation
|
Installation
|
||||||
------------
|
------------
|
||||||
|
|
||||||
We assume you have a Mopidy server available. **Because of `a bug in recent mopidy versions <https://github.com/mopidy/mopidy/issues/1528>`_,
|
We assume you have a Mopidy server available (version 3 or greater required).
|
||||||
if you face any playback issues, you should use at least Mopidy 2.2.3 which is currently unreleased, or install the development version with
|
|
||||||
``pip install --user git+https://github.com/mopidy/mopidy.git``**.
|
|
||||||
|
|
||||||
We don't have any package for this extension yet, so you may install
|
We don't have any package for this extension yet, so you may install
|
||||||
from the repository:
|
from the repository:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from mopidy import commands, compat, exceptions
|
from mopidy import commands, exceptions
|
||||||
|
|
||||||
import requests_oauthlib
|
import requests_oauthlib
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ class LoginCommand(commands.Command):
|
||||||
|
|
||||||
prompt = "\nEnter the token:"
|
prompt = "\nEnter the token:"
|
||||||
|
|
||||||
authorization_code = compat.input(prompt)
|
authorization_code = input(prompt)
|
||||||
token = oauth.fetch_token(
|
token = oauth.fetch_token(
|
||||||
url + token_endpoint,
|
url + token_endpoint,
|
||||||
code=authorization_code,
|
code=authorization_code,
|
||||||
|
|
|
@ -99,7 +99,7 @@ class FunkwhaleLibraryProvider(backend.LibraryProvider):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# root directory
|
# root directory
|
||||||
return self.vfs.get(uri, {}).values()
|
return list(self.vfs.get(uri, {}).values())
|
||||||
|
|
||||||
def browse_favorites(self, remaining):
|
def browse_favorites(self, remaining):
|
||||||
if remaining == []:
|
if remaining == []:
|
||||||
|
@ -292,7 +292,6 @@ def convert_to_album(payload, uri_prefix="funkwhale:albums"):
|
||||||
uri=uri_prefix + ":%s" % payload["id"],
|
uri=uri_prefix + ":%s" % payload["id"],
|
||||||
name=payload["title"],
|
name=payload["title"],
|
||||||
musicbrainz_id=payload["mbid"],
|
musicbrainz_id=payload["mbid"],
|
||||||
images=[image] if image else [],
|
|
||||||
artists=[artist],
|
artists=[artist],
|
||||||
date=payload["release_date"],
|
date=payload["release_date"],
|
||||||
num_tracks=len(payload.get("tracks", [])),
|
num_tracks=len(payload.get("tracks", [])),
|
||||||
|
@ -314,7 +313,7 @@ def convert_to_track(payload, uri_prefix="funkwhale:tracks"):
|
||||||
artists=[artist],
|
artists=[artist],
|
||||||
album=album,
|
album=album,
|
||||||
date=payload["album"]["release_date"],
|
date=payload["album"]["release_date"],
|
||||||
bitrate=(upload.get("bitrate") or 0) / 1000,
|
bitrate=int((upload.get("bitrate") or 0) / 1000),
|
||||||
length=(upload.get("duration") or 0) * 1000,
|
length=(upload.get("duration") or 0) * 1000,
|
||||||
track_no=payload["position"],
|
track_no=payload["position"],
|
||||||
)
|
)
|
||||||
|
|
|
@ -9,8 +9,6 @@ long_description = file: README.rst
|
||||||
license = GLP-3
|
license = GLP-3
|
||||||
keywords = code, diff, copy-paste, linter, DRY
|
keywords = code, diff, copy-paste, linter, DRY
|
||||||
classifiers =
|
classifiers =
|
||||||
Programming Language :: Python :: 2
|
|
||||||
Programming Language :: Python :: 2.7
|
|
||||||
Programming Language :: Python :: 3
|
Programming Language :: Python :: 3
|
||||||
Programming Language :: Python :: 3.6
|
Programming Language :: Python :: 3.6
|
||||||
|
|
||||||
|
@ -19,7 +17,7 @@ zip_safe = True
|
||||||
include_package_data = True
|
include_package_data = True
|
||||||
packages = find:
|
packages = find:
|
||||||
install_requires =
|
install_requires =
|
||||||
mopidy
|
mopidy>=3,<3.1
|
||||||
requests
|
requests
|
||||||
requests_oauthlib
|
requests_oauthlib
|
||||||
pygobject
|
pygobject
|
||||||
|
|
|
@ -25,7 +25,7 @@ class AlbumJSONFactory(factory.Factory):
|
||||||
id = factory.Sequence(int)
|
id = factory.Sequence(int)
|
||||||
mbid = factory.Faker("uuid4")
|
mbid = factory.Faker("uuid4")
|
||||||
title = factory.Faker("name")
|
title = factory.Faker("name")
|
||||||
tracks = factory.Iterator([range(i) for i in range(1, 30)])
|
tracks = factory.Iterator([list(range(i)) for i in range(1, 30)])
|
||||||
artist = factory.SubFactory(ArtistJSONFactory)
|
artist = factory.SubFactory(ArtistJSONFactory)
|
||||||
release_date = factory.Faker("date")
|
release_date = factory.Faker("date")
|
||||||
cover = factory.SubFactory(CoverJSONFactory)
|
cover = factory.SubFactory(CoverJSONFactory)
|
||||||
|
|
|
@ -44,7 +44,6 @@ def test_convert_album_to_model():
|
||||||
assert result.artists == frozenset(
|
assert result.artists == frozenset(
|
||||||
[mopidy_funkwhale.library.convert_to_artist(payload["artist"])]
|
[mopidy_funkwhale.library.convert_to_artist(payload["artist"])]
|
||||||
)
|
)
|
||||||
assert result.images == frozenset([payload["cover"]["original"]])
|
|
||||||
|
|
||||||
|
|
||||||
def test_convert_track_to_model():
|
def test_convert_track_to_model():
|
||||||
|
@ -193,7 +192,7 @@ def test_browse_artists_albums(client, library, requests_mock):
|
||||||
album2 = factories.AlbumJSONFactory(artist=album1["artist"])
|
album2 = factories.AlbumJSONFactory(artist=album1["artist"])
|
||||||
url = (
|
url = (
|
||||||
client.session.url_base
|
client.session.url_base
|
||||||
+ "albums/?page_size=50&ordering=title&playable=true&artist%s"
|
+ "albums/?ordering=title&page_size=50&playable=true&artist=%s"
|
||||||
% album1["artist"]["id"]
|
% album1["artist"]["id"]
|
||||||
)
|
)
|
||||||
requests_mock.get(url, json={"results": [album1, album2]})
|
requests_mock.get(url, json={"results": [album1, album2]})
|
||||||
|
|
Loading…
Reference in New Issue