diff --git a/maloja/pkg_global/conf.py b/maloja/pkg_global/conf.py index 5ed6052..89a5cf3 100644 --- a/maloja/pkg_global/conf.py +++ b/maloja/pkg_global/conf.py @@ -164,7 +164,7 @@ malojaconfig = Configuration( "name":(tp.String(), "Name", "Generic Maloja User") }, "Third Party Services":{ - "metadata_providers":(tp.List(tp.String()), "Metadata Providers", ['lastfm','spotify','deezer','musicbrainz'], "Which metadata providers should be used in what order. Musicbrainz is rate-limited and should not be used first."), + "metadata_providers":(tp.List(tp.String()), "Metadata Providers", ['lastfm','spotify','deezer','audiodb','musicbrainz'], "Which metadata providers should be used in what order. Musicbrainz is rate-limited and should not be used first."), "scrobble_lastfm":(tp.Boolean(), "Proxy-Scrobble to Last.fm", False), "lastfm_api_key":(tp.String(), "Last.fm API Key", None), "lastfm_api_secret":(tp.String(), "Last.fm API Secret", None), diff --git a/maloja/thirdparty/__init__.py b/maloja/thirdparty/__init__.py index 7b45e38..baffd83 100644 --- a/maloja/thirdparty/__init__.py +++ b/maloja/thirdparty/__init__.py @@ -7,13 +7,12 @@ # pls don't sue me import xml.etree.ElementTree as ElementTree -import json import requests import urllib.parse import base64 import time from doreah.logging import log -from threading import BoundedSemaphore +from threading import BoundedSemaphore, Thread from ..pkg_global.conf import malojaconfig from .. import database @@ -53,6 +52,7 @@ def proxy_scrobble_all(artists,title,timestamp): def get_image_track_all(track): with thirdpartylock: for service in services["metadata"]: + if "track" not in service.metadata["enabled_entity_types"]: continue try: res = service.get_image_track(track) if res: @@ -65,6 +65,7 @@ def get_image_track_all(track): def get_image_artist_all(artist): with thirdpartylock: for service in services["metadata"]: + if "artist" not in service.metadata["enabled_entity_types"]: continue try: res = service.get_image_artist(artist) if res: @@ -77,6 +78,7 @@ def get_image_artist_all(artist): def get_image_album_all(album): with thirdpartylock: for service in services["metadata"]: + if "album" not in service.metadata["enabled_entity_types"]: continue try: res = service.get_image_album(album) if res: @@ -109,7 +111,10 @@ class GenericInterface: # avoid constant disk access, restart on adding services is acceptable for key in self.settings: self.settings[key] = malojaconfig[self.settings[key]] - self.authorize() + t = Thread(target=self.authorize) + t.daemon = True + t.start() + #self.authorize() # this makes sure that of every class we define, we immediately create an # instance (de facto singleton). then each instance checks if the requirements diff --git a/maloja/thirdparty/audiodb.py b/maloja/thirdparty/audiodb.py index 9a4d84a..5b9e71f 100644 --- a/maloja/thirdparty/audiodb.py +++ b/maloja/thirdparty/audiodb.py @@ -16,6 +16,7 @@ class AudioDB(MetadataInterface): #"response_parse_tree_track": ["tracks",0,"astrArtistThumb"], "response_parse_tree_artist": ["artists",0,"strArtistThumb"], "required_settings": ["api_key"], + "enabled_entity_types": ["artist"] } def get_image_track(self,track): diff --git a/maloja/thirdparty/deezer.py b/maloja/thirdparty/deezer.py index dfac7a8..f30a9ba 100644 --- a/maloja/thirdparty/deezer.py +++ b/maloja/thirdparty/deezer.py @@ -17,6 +17,7 @@ class Deezer(MetadataInterface): "response_parse_tree_artist": ["data",0,"artist","picture_medium"], "response_parse_tree_album": ["data",0,"album","cover_medium"], "required_settings": [], + "enabled_entity_types": ["artist","album"] } delay = 1 diff --git a/maloja/thirdparty/lastfm.py b/maloja/thirdparty/lastfm.py index ff2ec65..cfd79b0 100644 --- a/maloja/thirdparty/lastfm.py +++ b/maloja/thirdparty/lastfm.py @@ -32,6 +32,7 @@ class LastFM(MetadataInterface, ProxyScrobbleInterface): #"response_parse_tree_artist": ["artist","image",-1,"#text"], "response_parse_tree_album": ["album","image",-1,"#text"], "required_settings": ["apikey"], + "enabled_entity_types": ["track","album"] } def get_image_artist(self,artist): diff --git a/maloja/thirdparty/musicbrainz.py b/maloja/thirdparty/musicbrainz.py index 5dc6f72..668f7f3 100644 --- a/maloja/thirdparty/musicbrainz.py +++ b/maloja/thirdparty/musicbrainz.py @@ -19,6 +19,7 @@ class MusicBrainz(MetadataInterface): metadata = { "response_type":"json", "required_settings": [], + "enabled_entity_types": ["album","track"] } def get_image_artist(self,artist): diff --git a/maloja/thirdparty/spotify.py b/maloja/thirdparty/spotify.py index 03d614d..93f4d62 100644 --- a/maloja/thirdparty/spotify.py +++ b/maloja/thirdparty/spotify.py @@ -21,6 +21,7 @@ class Spotify(MetadataInterface): "response_parse_tree_album": ["albums","items",0,"images",0,"url"], "response_parse_tree_artist": ["artists","items",0,"images",0,"url"], "required_settings": ["apiid","secret"], + "enabled_entity_types": ["artist","album","track"] } def authorize(self):