mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 00:46:18 +00:00
Add ListenBrainz documentation and tests
This commit is contained in:
parent
a39f2fb16a
commit
0f49dfb3ac
@ -14,6 +14,7 @@ Current supported features are:
|
||||
* cover art
|
||||
* starred tracks/albums and ratings
|
||||
* [Last.fm][lastfm] scrobbling
|
||||
* [ListenBrainz][listenbrainz] scrobbling
|
||||
* Jukebox mode
|
||||
|
||||
Supysonic currently targets the version 1.12.0 of the Subsonic API. For more
|
||||
@ -21,6 +22,7 @@ details, go check the [API implementation status][docs-api].
|
||||
|
||||
[subsonic]: http://www.subsonic.org/
|
||||
[lastfm]: https://www.last.fm/
|
||||
[listenbrainz]: https://listenbrainz.org/
|
||||
[docs-api]: https://supysonic.readthedocs.io/en/latest/api.html
|
||||
|
||||
## Documentation
|
||||
@ -72,6 +74,6 @@ And there's also the tests (which require `lxml` to run):
|
||||
$ python -m unittest tests.net.suite
|
||||
|
||||
The last command runs a few tests that make HTTP requests to remote third-party
|
||||
services (namely Last.fm and ChartLyrics).
|
||||
services (namely Last.fm, ListenBrainz and ChartLyrics).
|
||||
|
||||
[flask]: https://flask.palletsprojects.com/
|
||||
|
@ -74,6 +74,11 @@ log_rotate = yes
|
||||
;api_key =
|
||||
;secret =
|
||||
|
||||
[listenbrainz]
|
||||
; root URL of the ListenBrainz API.
|
||||
; Defaults: https://api.listenbrainz.org/
|
||||
;api_url =
|
||||
|
||||
[transcoding]
|
||||
; Programs used to convert from one format/bitrate to another. Defaults: none
|
||||
transcoder_mp3_mp3 = lame --quiet --mp3input -b %outrate %srcpath -
|
||||
|
@ -12,10 +12,12 @@ Current supported features are:
|
||||
* cover art
|
||||
* starred tracks/albums and ratings
|
||||
* `Last.FM`__ scrobbling
|
||||
* `ListenBrainz`__ scrobbling
|
||||
* Jukebox mode
|
||||
|
||||
__ http://www.subsonic.org/
|
||||
__ https://www.last.fm/
|
||||
__ https://listenbrainz.org/
|
||||
|
||||
.. rubric:: User's guide
|
||||
|
||||
|
@ -293,6 +293,35 @@ Sample configuration::
|
||||
;api_key =
|
||||
;secret =
|
||||
|
||||
.. _conf-listenbrainz:
|
||||
|
||||
``[listenbrainz]`` section
|
||||
--------------------------
|
||||
|
||||
This section allows a custom ListenBrainz instance to be configured
|
||||
for scrobbling. ListenBrainz is a music scrobbling service with social
|
||||
features, similar to LastFM, but it is open source and
|
||||
self-hostable. Supysonic can configured with any ListenBrainz
|
||||
instance, but it connects to the official instance by default.
|
||||
|
||||
In order to connect to ListenBrainz, each user requires an user token
|
||||
that can be obtained from their ListenBrainz profile (more information
|
||||
in the API docs). This token has to be configured per profile using
|
||||
the web UI.
|
||||
|
||||
The ListenBrainz API documentation can be found here:
|
||||
https://listenbrainz.readthedocs.io/en/latest/users/api/index.html
|
||||
|
||||
``api_url``
|
||||
root URL of the ListenBrainz API for the instance
|
||||
|
||||
Sample configuration::
|
||||
|
||||
[listenbrainz]
|
||||
; root URL of the ListenBrainz API.
|
||||
; Defaults: https://api.listenbrainz.org/
|
||||
;api_url =
|
||||
|
||||
.. _conf-transcoding:
|
||||
|
||||
``[transcoding]`` section
|
||||
|
@ -255,6 +255,22 @@ class UserTestCase(FrontendTestBase):
|
||||
rv = self.client.get("/user/me/lastfm/unlink", follow_redirects=True)
|
||||
self.assertIn("Unlinked", rv.data)
|
||||
|
||||
def test_listenbrainz_link(self):
|
||||
self._login("alice", "Alic3")
|
||||
rv = self.client.get("/user/me/listenbrainz/link", follow_redirects=True)
|
||||
self.assertIn("Missing ListenBrainz auth token", rv.data)
|
||||
# # Testing this requires an HTTP request!
|
||||
# rv = self.client.get(
|
||||
# "/user/me/listenbrainz/link",
|
||||
# query_string={"token": "abcdef"},
|
||||
# follow_redirects=True,
|
||||
# )
|
||||
# self.assertIn("Error: ", rv.data)
|
||||
|
||||
def test_listenbrainz_unlink(self):
|
||||
self._login("alice", "Alic3")
|
||||
rv = self.client.get("/user/me/listenbrainz/unlink", follow_redirects=True)
|
||||
self.assertIn("Unlinked", rv.data)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
26
tests/net/test_listenbrainz.py
Normal file
26
tests/net/test_listenbrainz.py
Normal file
@ -0,0 +1,26 @@
|
||||
# This file is part of Supysonic.
|
||||
# Supysonic is a Python implementation of the Subsonic server API.
|
||||
#
|
||||
# Copyright (C) 2017-2018 Alban 'spl0k' Féron
|
||||
# Copyright (C) 2024 Iván Ávalos
|
||||
#
|
||||
# Distributed under terms of the GNU AGPLv3 license.
|
||||
|
||||
import logging
|
||||
import unittest
|
||||
|
||||
from supysonic.listenbrainz import ListenBrainz
|
||||
|
||||
class ListenBrainzTestCase(unittest.TestCase):
|
||||
"""Basic test of unauthenticated ListenBrainz API method"""
|
||||
|
||||
def test_request(self):
|
||||
logging.getLogger("supysonic.listenbrainz").addHandler(logging.NullHandler())
|
||||
listenbrainz = ListenBrainz({"api_url": "https://api.listenbrainz.org/"}, None)
|
||||
|
||||
user = "aavalos"
|
||||
rv = listenbrainz._ListenBrainz__api_request(False, "/1/search/users/?search_term={0}".format(user), token="123")
|
||||
self.assertIsInstance(rv, dict)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
Loading…
Reference in New Issue
Block a user