mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 03:49:16 +02:00
Started work on library scanning
This commit is contained in:
parent
472cc7e26a
commit
520fb9d078
9 changed files with 157 additions and 4 deletions
27
api/funkwhale_api/federation/tasks.py
Normal file
27
api/funkwhale_api/federation/tasks.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
from funkwhale_api.taskapp import celery
|
||||
|
||||
from . import library as lb
|
||||
from . import models
|
||||
|
||||
|
||||
@celery.app.task(name='federation.scan_library')
|
||||
@celery.require_instance(models.Library, 'library')
|
||||
def scan_library(library):
|
||||
if not library.federation_enabled:
|
||||
return
|
||||
|
||||
data = lb.get_library_data(library.url)
|
||||
scan_library_page.delay(
|
||||
library_id=library.id, page_url=data['first'])
|
||||
|
||||
|
||||
@celery.app.task(name='federation.scan_library_page')
|
||||
@celery.require_instance(models.Library, 'library')
|
||||
def scan_library_page(library, page_url):
|
||||
if not library.federation_enabled:
|
||||
return
|
||||
|
||||
data = lb.get_library_page(library, page_url)
|
||||
lts = []
|
||||
for item_serializer in data['items']:
|
||||
lts.append(item_serializer.save())
|
Loading…
Add table
Add a link
Reference in a new issue