Fix all flake8 warnings
This commit is contained in:
parent
73b5f9bcc5
commit
128ba8173f
4 changed files with 22 additions and 39 deletions
|
@ -1,6 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from mopidy import backend, models
|
from mopidy import backend
|
||||||
from mopidy.models import Ref, SearchResult
|
from mopidy.models import Ref, SearchResult
|
||||||
from mopidy_subidy import uri
|
from mopidy_subidy import uri
|
||||||
|
|
||||||
|
@ -130,22 +130,6 @@ class SubidyLibraryProvider(backend.LibraryProvider):
|
||||||
def refresh(self, uri):
|
def refresh(self, uri):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def search_uri(self, query):
|
|
||||||
type = uri.get_type(lookup_uri)
|
|
||||||
if type == uri.ARTIST:
|
|
||||||
artist = self.lookup_artist(uri.get_artist_id(lookup_uri))
|
|
||||||
if artist is not None:
|
|
||||||
return SearchResult(artists=[artist])
|
|
||||||
elif type == uri.ALBUM:
|
|
||||||
album = self.lookup_album(uri.get_album_id(lookup_uri))
|
|
||||||
if album is not None:
|
|
||||||
return SearchResult(albums=[album])
|
|
||||||
elif type == uri.SONG:
|
|
||||||
song = self.lookup_song(uri.get_song_id(lookup_uri))
|
|
||||||
if song is not None:
|
|
||||||
return SearchResult(tracks=[song])
|
|
||||||
return None
|
|
||||||
|
|
||||||
def search_by_artist_album_and_track(
|
def search_by_artist_album_and_track(
|
||||||
self, artist_name, album_name, track_name
|
self, artist_name, album_name, track_name
|
||||||
):
|
):
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from mopidy import backend
|
from mopidy import backend
|
||||||
from mopidy.models import Playlist
|
|
||||||
from mopidy_subidy import uri
|
from mopidy_subidy import uri
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
@ -35,13 +34,11 @@ class SubidyPlaylistsProvider(backend.PlaylistsProvider):
|
||||||
self.subsonic_api.delete_playlist_raw(playlist_id)
|
self.subsonic_api.delete_playlist_raw(playlist_id)
|
||||||
|
|
||||||
def get_items(self, items_uri):
|
def get_items(self, items_uri):
|
||||||
# logger.info('ITEMS %s: %s' % (lookup_uri, self.subsonic_api.get_playlist_songs_as_refs(uri.get_playlist_id(items_uri))))
|
|
||||||
return self.subsonic_api.get_playlist_as_songs_as_refs(
|
return self.subsonic_api.get_playlist_as_songs_as_refs(
|
||||||
uri.get_playlist_id(items_uri)
|
uri.get_playlist_id(items_uri)
|
||||||
)
|
)
|
||||||
|
|
||||||
def lookup(self, lookup_uri):
|
def lookup(self, lookup_uri):
|
||||||
# logger.info('LOOKUP PLAYLIST %s: %s' % (lookup_uri, self.subsonic_api.get_playlist_as_playlist(uri.get_playlist_id(lookup_uri))))
|
|
||||||
return self.subsonic_api.get_playlist_as_playlist(
|
return self.subsonic_api.get_playlist_as_playlist(
|
||||||
uri.get_playlist_id(lookup_uri)
|
uri.get_playlist_id(lookup_uri)
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import itertools
|
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
from urllib.parse import urlencode, urlparse
|
from urllib.parse import urlencode, urlparse
|
||||||
|
@ -16,7 +15,9 @@ UNKNOWN_ARTIST = "Unknown Artist"
|
||||||
MAX_SEARCH_RESULTS = 100
|
MAX_SEARCH_RESULTS = 100
|
||||||
MAX_LIST_RESULTS = 500
|
MAX_LIST_RESULTS = 500
|
||||||
|
|
||||||
ref_sort_key = lambda ref: ref.name
|
|
||||||
|
def ref_sort_key(ref):
|
||||||
|
return ref.name
|
||||||
|
|
||||||
|
|
||||||
def string_nums_nocase_sort_key(s):
|
def string_nums_nocase_sort_key(s):
|
||||||
|
@ -66,7 +67,8 @@ class SubsonicApi:
|
||||||
self.username = username
|
self.username = username
|
||||||
self.password = password
|
self.password = password
|
||||||
logger.info(
|
logger.info(
|
||||||
f"Connecting to subsonic server on url {url} as user {username}, API version {api_version}"
|
f"Connecting to subsonic server on url {url} as user {username}, "
|
||||||
|
f"API version {api_version}"
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
self.connection.ping()
|
self.connection.ping()
|
||||||
|
@ -108,7 +110,7 @@ class SubsonicApi:
|
||||||
MAX_SEARCH_RESULTS if not exclude_songs else 0,
|
MAX_SEARCH_RESULTS if not exclude_songs else 0,
|
||||||
0,
|
0,
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logger.warning("Connecting to subsonic failed when searching.")
|
logger.warning("Connecting to subsonic failed when searching.")
|
||||||
return None
|
return None
|
||||||
if response.get("status") != RESPONSE_OK:
|
if response.get("status") != RESPONSE_OK:
|
||||||
|
@ -148,7 +150,7 @@ class SubsonicApi:
|
||||||
def create_playlist_raw(self, name):
|
def create_playlist_raw(self, name):
|
||||||
try:
|
try:
|
||||||
response = self.connection.createPlaylist(name=name)
|
response = self.connection.createPlaylist(name=name)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Connecting to subsonic failed when creating playlist."
|
"Connecting to subsonic failed when creating playlist."
|
||||||
)
|
)
|
||||||
|
@ -164,7 +166,7 @@ class SubsonicApi:
|
||||||
def delete_playlist_raw(self, playlist_id):
|
def delete_playlist_raw(self, playlist_id):
|
||||||
try:
|
try:
|
||||||
response = self.connection.deletePlaylist(playlist_id)
|
response = self.connection.deletePlaylist(playlist_id)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Connecting to subsonic failed when deleting playlist."
|
"Connecting to subsonic failed when deleting playlist."
|
||||||
)
|
)
|
||||||
|
@ -182,7 +184,7 @@ class SubsonicApi:
|
||||||
response = self.connection.createPlaylist(
|
response = self.connection.createPlaylist(
|
||||||
playlist_id, songIds=song_ids
|
playlist_id, songIds=song_ids
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Connecting to subsonic failed when creating playlist."
|
"Connecting to subsonic failed when creating playlist."
|
||||||
)
|
)
|
||||||
|
@ -198,7 +200,7 @@ class SubsonicApi:
|
||||||
def get_raw_artists(self):
|
def get_raw_artists(self):
|
||||||
try:
|
try:
|
||||||
response = self.connection.getArtists()
|
response = self.connection.getArtists()
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Connecting to subsonic failed when loading list of artists."
|
"Connecting to subsonic failed when loading list of artists."
|
||||||
)
|
)
|
||||||
|
@ -225,7 +227,7 @@ class SubsonicApi:
|
||||||
def get_raw_rootdirs(self):
|
def get_raw_rootdirs(self):
|
||||||
try:
|
try:
|
||||||
response = self.connection.getIndexes()
|
response = self.connection.getIndexes()
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Connecting to subsonic failed when loading list of rootdirs."
|
"Connecting to subsonic failed when loading list of rootdirs."
|
||||||
)
|
)
|
||||||
|
@ -252,7 +254,7 @@ class SubsonicApi:
|
||||||
def get_song_by_id(self, song_id):
|
def get_song_by_id(self, song_id):
|
||||||
try:
|
try:
|
||||||
response = self.connection.getSong(song_id)
|
response = self.connection.getSong(song_id)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Connecting to subsonic failed when loading song by id."
|
"Connecting to subsonic failed when loading song by id."
|
||||||
)
|
)
|
||||||
|
@ -272,7 +274,7 @@ class SubsonicApi:
|
||||||
def get_album_by_id(self, album_id):
|
def get_album_by_id(self, album_id):
|
||||||
try:
|
try:
|
||||||
response = self.connection.getAlbum(album_id)
|
response = self.connection.getAlbum(album_id)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Connecting to subsonic failed when loading album by id."
|
"Connecting to subsonic failed when loading album by id."
|
||||||
)
|
)
|
||||||
|
@ -292,7 +294,7 @@ class SubsonicApi:
|
||||||
def get_artist_by_id(self, artist_id):
|
def get_artist_by_id(self, artist_id):
|
||||||
try:
|
try:
|
||||||
response = self.connection.getArtist(artist_id)
|
response = self.connection.getArtist(artist_id)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Connecting to subsonic failed when loading artist by id."
|
"Connecting to subsonic failed when loading artist by id."
|
||||||
)
|
)
|
||||||
|
@ -312,7 +314,7 @@ class SubsonicApi:
|
||||||
def get_raw_playlists(self):
|
def get_raw_playlists(self):
|
||||||
try:
|
try:
|
||||||
response = self.connection.getPlaylists()
|
response = self.connection.getPlaylists()
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Connecting to subsonic failed when loading list of playlists."
|
"Connecting to subsonic failed when loading list of playlists."
|
||||||
)
|
)
|
||||||
|
@ -334,7 +336,7 @@ class SubsonicApi:
|
||||||
def get_raw_playlist(self, playlist_id):
|
def get_raw_playlist(self, playlist_id):
|
||||||
try:
|
try:
|
||||||
response = self.connection.getPlaylist(playlist_id)
|
response = self.connection.getPlaylist(playlist_id)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Connecting to subsonic failed when loading playlist."
|
"Connecting to subsonic failed when loading playlist."
|
||||||
)
|
)
|
||||||
|
@ -350,7 +352,7 @@ class SubsonicApi:
|
||||||
def get_raw_dir(self, parent_id):
|
def get_raw_dir(self, parent_id):
|
||||||
try:
|
try:
|
||||||
response = self.connection.getMusicDirectory(parent_id)
|
response = self.connection.getMusicDirectory(parent_id)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Connecting to subsonic failed when listing content of music directory."
|
"Connecting to subsonic failed when listing content of music directory."
|
||||||
)
|
)
|
||||||
|
@ -370,7 +372,7 @@ class SubsonicApi:
|
||||||
def get_raw_albums(self, artist_id):
|
def get_raw_albums(self, artist_id):
|
||||||
try:
|
try:
|
||||||
response = self.connection.getArtist(artist_id)
|
response = self.connection.getArtist(artist_id)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Connecting to subsonic failed when loading list of albums."
|
"Connecting to subsonic failed when loading list of albums."
|
||||||
)
|
)
|
||||||
|
@ -392,7 +394,7 @@ class SubsonicApi:
|
||||||
def get_raw_songs(self, album_id):
|
def get_raw_songs(self, album_id):
|
||||||
try:
|
try:
|
||||||
response = self.connection.getAlbum(album_id)
|
response = self.connection.getAlbum(album_id)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Connecting to subsonic failed when loading list of songs in album."
|
"Connecting to subsonic failed when loading list of songs in album."
|
||||||
)
|
)
|
||||||
|
@ -411,7 +413,7 @@ class SubsonicApi:
|
||||||
def get_raw_album_list(self, ltype, size=MAX_LIST_RESULTS):
|
def get_raw_album_list(self, ltype, size=MAX_LIST_RESULTS):
|
||||||
try:
|
try:
|
||||||
response = self.connection.getAlbumList2(ltype=ltype, size=size)
|
response = self.connection.getAlbumList2(ltype=ltype, size=size)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Connecting to subsonic failed when loading album list."
|
"Connecting to subsonic failed when loading album list."
|
||||||
)
|
)
|
||||||
|
|
|
@ -16,7 +16,7 @@ def test_get_config_schema():
|
||||||
schema = ext.get_config_schema()
|
schema = ext.get_config_schema()
|
||||||
|
|
||||||
# TODO Test the content of your config schema
|
# TODO Test the content of your config schema
|
||||||
# assert "username" in schema
|
assert "url" in schema
|
||||||
# assert "password" in schema
|
# assert "password" in schema
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue