mirror of https://github.com/krateng/maloja.git
Slightly changed import architecture
This commit is contained in:
parent
4c9f824bbd
commit
b5bf87bf6b
|
@ -1,4 +1,5 @@
|
||||||
gcc
|
gcc
|
||||||
|
python3-dev
|
||||||
libxml2-dev
|
libxml2-dev
|
||||||
libxslt-dev
|
libxslt-dev
|
||||||
libffi-dev
|
libffi-dev
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
apk add \
|
apk add \
|
||||||
python3 \
|
python3 \
|
||||||
|
python3-dev \
|
||||||
gcc \
|
gcc \
|
||||||
libxml2-dev \
|
libxml2-dev \
|
||||||
libxslt-dev \
|
libxslt-dev \
|
||||||
|
|
|
@ -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
|
# 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 import_scrobbles(self):
|
||||||
def self_scrobble(self,artists,title,timestamp):
|
for scrobble in self.get_remote_scrobbles():
|
||||||
database.createScrobble(artists=artists,title=title,time=timestamp)
|
database.createScrobble(
|
||||||
|
artists=scrobble['artists'],
|
||||||
|
title=scrobble['title'],
|
||||||
|
time=scrobble['time']
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# metadata
|
# metadata
|
||||||
|
|
|
@ -29,12 +29,12 @@ class OtherMalojaInstance(ProxyScrobbleInterface, ImportInterface):
|
||||||
def active_proxyscrobble(self):
|
def active_proxyscrobble(self):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def import_scrobbles(self):
|
def get_remote_scrobbles(self):
|
||||||
url = f"{self.settings['instance']}/apis/mlj_1/scrobbles"
|
url = f"{self.settings['instance']}/apis/mlj_1/scrobbles"
|
||||||
|
|
||||||
response = urllib.request.urlopen(url)
|
response = urllib.request.urlopen(url)
|
||||||
data = json.loads(response.read().decode('utf-8'))
|
data = json.loads(response.read().decode('utf-8'))
|
||||||
|
|
||||||
for scrobble in data['list']:
|
for scrobble in data['list']:
|
||||||
self.self_scrobble(scrobble['artists'],scrobble['title'],scrobble['time'])
|
yield scrobble
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Reference in New Issue