aab21
This commit is contained in:
commit
0508d8cd9a
53 changed files with 765 additions and 0 deletions
30
app/video/management/commands/load_titles.py
Normal file
30
app/video/management/commands/load_titles.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
from django.core.management.base import BaseCommand
|
||||
|
||||
import ox
|
||||
from ... import models
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'import titles from pan.do/ra'
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument("--api", dest="api", type=str, default='https://pad.ma/api/'),
|
||||
parser.add_argument("--group", dest="group", type=str, default='Asian Art Biennial 2021'),
|
||||
|
||||
def handle(self, *args, **options):
|
||||
api = ox.api.signin(options['api'])
|
||||
query = {
|
||||
'query': {
|
||||
'conditions': [{'key': 'groups', 'value': options['group'], 'operator': '=='}]
|
||||
},
|
||||
'keys': ['id', 'title', 'director', 'summary', 'source'],
|
||||
'range': [0, 1000]
|
||||
}
|
||||
for item in api.find(**query)['data']['items']:
|
||||
print(item)
|
||||
f, c = models.Film.objects.get_or_create(padma_id=item['id'])
|
||||
for key, value in item.items():
|
||||
if key != 'id':
|
||||
f.data[key] = value
|
||||
f.public = True
|
||||
f.slug = item['id']
|
||||
f.save()
|
||||
Loading…
Add table
Add a link
Reference in a new issue