Make Plugin with with mopidy 3

main
Georg Krause 2020-05-11 16:13:45 +02:00 committed by Agate
parent 28c2b561e5
commit 3a1868f6fb
7 changed files with 9 additions and 15 deletions

View File

@ -3,7 +3,7 @@ stages:
test:
stage: test
image: python:2
image: python:3
before_script:
- apt-get update
- apt-get install libgirepository1.0-dev -y

View File

@ -22,9 +22,7 @@ Features
Installation
------------
We assume you have a Mopidy server available. **Because of `a bug in recent mopidy versions <https://github.com/mopidy/mopidy/issues/1528>`_,
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 assume you have a Mopidy server available (version 3 or greater required).
We don't have any package for this extension yet, so you may install
from the repository:

View File

@ -1,4 +1,4 @@
from mopidy import commands, compat, exceptions
from mopidy import commands, exceptions
import requests_oauthlib
@ -77,7 +77,7 @@ class LoginCommand(commands.Command):
prompt = "\nEnter the token:"
authorization_code = compat.input(prompt)
authorization_code = input(prompt)
token = oauth.fetch_token(
url + token_endpoint,
code=authorization_code,

View File

@ -99,7 +99,7 @@ class FunkwhaleLibraryProvider(backend.LibraryProvider):
return result
# root directory
return self.vfs.get(uri, {}).values()
return list(self.vfs.get(uri, {}).values())
def browse_favorites(self, remaining):
if remaining == []:
@ -292,7 +292,6 @@ def convert_to_album(payload, uri_prefix="funkwhale:albums"):
uri=uri_prefix + ":%s" % payload["id"],
name=payload["title"],
musicbrainz_id=payload["mbid"],
images=[image] if image else [],
artists=[artist],
date=payload["release_date"],
num_tracks=len(payload.get("tracks", [])),
@ -314,7 +313,7 @@ def convert_to_track(payload, uri_prefix="funkwhale:tracks"):
artists=[artist],
album=album,
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,
track_no=payload["position"],
)

View File

@ -9,8 +9,6 @@ long_description = file: README.rst
license = GLP-3
keywords = code, diff, copy-paste, linter, DRY
classifiers =
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
@ -19,7 +17,7 @@ zip_safe = True
include_package_data = True
packages = find:
install_requires =
mopidy
mopidy>=3,<3.1
requests
requests_oauthlib
pygobject

View File

@ -25,7 +25,7 @@ class AlbumJSONFactory(factory.Factory):
id = factory.Sequence(int)
mbid = factory.Faker("uuid4")
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)
release_date = factory.Faker("date")
cover = factory.SubFactory(CoverJSONFactory)

View File

@ -44,7 +44,6 @@ def test_convert_album_to_model():
assert result.artists == frozenset(
[mopidy_funkwhale.library.convert_to_artist(payload["artist"])]
)
assert result.images == frozenset([payload["cover"]["original"]])
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"])
url = (
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"]
)
requests_mock.get(url, json={"results": [album1, album2]})