diff --git a/maloja/globalconf.py b/maloja/globalconf.py index 8bddd2e..0859ed9 100644 --- a/maloja/globalconf.py +++ b/maloja/globalconf.py @@ -171,6 +171,8 @@ malojaconfig = Configuration( "spotify_api_id":(tp.String(), "Spotify API ID", None), "spotify_api_secret":(tp.String(), "Spotify API Secret", None), "audiodb_api_key":(tp.String(), "TheAudioDB API Key", None), + "other_maloja_url":(tp.String(), "Other Maloja Instance URL", None), + "other_maloja_api_key":(tp.String(), "Other Maloja Instance API Key",None), "track_search_provider":(tp.String(), "Track Search Provider", None), "send_stats":(tp.Boolean(), "Send Statistics", None), diff --git a/maloja/thirdparty/__init__.py b/maloja/thirdparty/__init__.py index 3b6e515..36116cc 100644 --- a/maloja/thirdparty/__init__.py +++ b/maloja/thirdparty/__init__.py @@ -245,7 +245,8 @@ __all__ = [ "spotify", "musicbrainz", "audiodb", - "deezer" + "deezer", + "maloja" ] from . import * diff --git a/maloja/thirdparty/maloja.py b/maloja/thirdparty/maloja.py new file mode 100644 index 0000000..4dc2060 --- /dev/null +++ b/maloja/thirdparty/maloja.py @@ -0,0 +1,40 @@ +from . import ProxyScrobbleInterface, ImportInterface +import urllib.request +from doreah.logging import log +import json + + +class OtherMalojaInstance(ProxyScrobbleInterface, ImportInterface): + + name = "Maloja" + identifier = "maloja" + + settings = { + "apikey":"OTHER_MALOJA_API_KEY", + "instance":"OTHER_MALOJA_URL" + } + + proxyscrobble = { + "scrobbleurl": "http://ws.audioscrobbler.com/2.0/", + "required_settings": ["apikey","instance"], + "activated_setting": "FORWARD_OTHER_MALOJA_SERVER" + } + + scrobbleimport = { + "required_settings":["apikey","instance"] + } + + + + def active_proxyscrobble(self): + return False + + def import_scrobbles(self): + url = f"{self.settings['instance']}/apis/mlj_1/scrobbles" + + response = urllib.request.urlopen(url) + data = json.loads(response.read().decode('utf-8')) + + for scrobble in data['list']: + self.self_scrobble(scrobble['artists'],scrobble['title'],scrobble['time']) + return True