Commit aab99430 authored by Agate's avatar Agate 💬
Browse files

Merge branch 'issue-6' into 'master'

Make Plugin with with mopidy 3

Closes #6

See merge request !5
parents 28c2b561 3a1868f6
Pipeline #10720 passed with stage
in 1 minute and 28 seconds
...@@ -3,7 +3,7 @@ stages: ...@@ -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 ...@@ -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:
......
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): ...@@ -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): ...@@ -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"): ...@@ -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"): ...@@ -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 ...@@ -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 ...@@ -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): ...@@ -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(): ...@@ -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): ...@@ -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]})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment