mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Slightly changed import architecture
This commit is contained in:
parent
4c9f824bbd
commit
b5bf87bf6b
@ -1,4 +1,5 @@
|
||||
gcc
|
||||
python3-dev
|
||||
libxml2-dev
|
||||
libxslt-dev
|
||||
libffi-dev
|
||||
|
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
apk add \
|
||||
python3 \
|
||||
python3-dev \
|
||||
gcc \
|
||||
libxml2-dev \
|
||||
libxslt-dev \
|
||||
|
10
maloja/thirdparty/__init__.py
vendored
10
maloja/thirdparty/__init__.py
vendored
@ -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
|
||||
|
4
maloja/thirdparty/maloja.py
vendored
4
maloja/thirdparty/maloja.py
vendored
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user