From b5bf87bf6ba8205728aebb5b4a47e9092ae080bc Mon Sep 17 00:00:00 2001 From: krateng Date: Sat, 1 Jan 2022 04:25:03 +0100 Subject: [PATCH] Slightly changed import architecture --- install/dependencies_build.txt | 1 + install_alpine.sh | 1 + maloja/thirdparty/__init__.py | 10 +++++++--- maloja/thirdparty/maloja.py | 4 ++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/install/dependencies_build.txt b/install/dependencies_build.txt index e72a452..7980da1 100644 --- a/install/dependencies_build.txt +++ b/install/dependencies_build.txt @@ -1,4 +1,5 @@ gcc +python3-dev libxml2-dev libxslt-dev libffi-dev diff --git a/install_alpine.sh b/install_alpine.sh index fc1ce7c..890e033 100644 --- a/install_alpine.sh +++ b/install_alpine.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash apk add \ python3 \ + python3-dev \ gcc \ libxml2-dev \ libxslt-dev \ diff --git a/maloja/thirdparty/__init__.py b/maloja/thirdparty/__init__.py index 36116cc..68e221c 100644 --- a/maloja/thirdparty/__init__.py +++ b/maloja/thirdparty/__init__.py @@ -152,9 +152,13 @@ class ImportInterface(GenericInterface,abstract=True): # registering as import source doesnt do anything on its own, so no need for a setting ) - # wrapper so that all the inheriting classes can scrobble - def self_scrobble(self,artists,title,timestamp): - database.createScrobble(artists=artists,title=title,time=timestamp) + def import_scrobbles(self): + for scrobble in self.get_remote_scrobbles(): + database.createScrobble( + artists=scrobble['artists'], + title=scrobble['title'], + time=scrobble['time'] + ) # metadata diff --git a/maloja/thirdparty/maloja.py b/maloja/thirdparty/maloja.py index 4dc2060..53413f8 100644 --- a/maloja/thirdparty/maloja.py +++ b/maloja/thirdparty/maloja.py @@ -29,12 +29,12 @@ class OtherMalojaInstance(ProxyScrobbleInterface, ImportInterface): def active_proxyscrobble(self): return False - def import_scrobbles(self): + def get_remote_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']) + yield scrobble return True