Slightly changed import architecture

This commit is contained in:
krateng 2022-01-01 04:25:03 +01:00
parent 4c9f824bbd
commit b5bf87bf6b
4 changed files with 11 additions and 5 deletions

View File

@ -1,4 +1,5 @@
gcc
python3-dev
libxml2-dev
libxslt-dev
libffi-dev

View File

@ -1,6 +1,7 @@
#!/usr/bin/env bash
apk add \
python3 \
python3-dev \
gcc \
libxml2-dev \
libxslt-dev \

View File

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

View File

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