Fix misleading logging entries about metadata requests

This commit is contained in:
krateng 2023-11-01 20:07:05 +01:00
parent 76691a5b0f
commit d0a20fecb2
7 changed files with 14 additions and 4 deletions

View File

@ -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),

View File

@ -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

View File

@ -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):

View File

@ -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

View File

@ -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):

View File

@ -19,6 +19,7 @@ class MusicBrainz(MetadataInterface):
metadata = {
"response_type":"json",
"required_settings": [],
"enabled_entity_types": ["album","track"]
}
def get_image_artist(self,artist):

View File

@ -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):