1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Added other Maloja instance as third party option

This commit is contained in:
krateng 2021-12-31 23:13:22 +01:00
parent e62c637aa0
commit 4c9f824bbd
3 changed files with 44 additions and 1 deletions

View File

@ -171,6 +171,8 @@ malojaconfig = Configuration(
"spotify_api_id":(tp.String(), "Spotify API ID", None), "spotify_api_id":(tp.String(), "Spotify API ID", None),
"spotify_api_secret":(tp.String(), "Spotify API Secret", None), "spotify_api_secret":(tp.String(), "Spotify API Secret", None),
"audiodb_api_key":(tp.String(), "TheAudioDB API Key", 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), "track_search_provider":(tp.String(), "Track Search Provider", None),
"send_stats":(tp.Boolean(), "Send Statistics", None), "send_stats":(tp.Boolean(), "Send Statistics", None),

View File

@ -245,7 +245,8 @@ __all__ = [
"spotify", "spotify",
"musicbrainz", "musicbrainz",
"audiodb", "audiodb",
"deezer" "deezer",
"maloja"
] ]
from . import * from . import *

40
maloja/thirdparty/maloja.py vendored Normal file
View File

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