Skip to content

Commit

Permalink
Fix misleading logging entries about metadata requests
Browse files Browse the repository at this point in the history
  • Loading branch information
krateng committed Nov 1, 2023
1 parent 76691a5 commit d0a20fe
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion maloja/pkg_global/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def find_good_folder(datatype,configobject):
"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),
Expand Down
11 changes: 8 additions & 3 deletions maloja/thirdparty/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -109,7 +111,10 @@ def __init__(self):
# 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
Expand Down
1 change: 1 addition & 0 deletions maloja/thirdparty/audiodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions maloja/thirdparty/deezer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions maloja/thirdparty/lastfm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions maloja/thirdparty/musicbrainz.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class MusicBrainz(MetadataInterface):
metadata = {
"response_type":"json",
"required_settings": [],
"enabled_entity_types": ["album","track"]
}

def get_image_artist(self,artist):
Expand Down
1 change: 1 addition & 0 deletions maloja/thirdparty/spotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit d0a20fe

Please sign in to comment.