This commit is contained in:
j 2021-05-31 17:03:47 +01:00
parent 4ccd6adb86
commit 49ba3b6c7c
3 changed files with 11 additions and 11 deletions

View file

@ -36,7 +36,7 @@ def update_item(d, add_only=False):
if 'year' in info: if 'year' in info:
if isinstance(info['year'], list): if isinstance(info['year'], list):
info['year'] = info['year'][0] info['year'] = info['year'][0]
if isinstance(info['year'], basestring): if isinstance(info['year'], str):
info['year'] = info['year'][:4] info['year'] = info['year'][:4]
extra = [] extra = []
for key in ('director', 'publisher', 'creator', 'sponsor'): for key in ('director', 'publisher', 'creator', 'sponsor'):
@ -83,7 +83,7 @@ def update_item(d, add_only=False):
i, created = get_item(info['archive']) i, created = get_item(info['archive'])
if add_only and not created: if add_only and not created:
return return
print info['archive'], info.get('title', 'Untitled') print(info['archive'], info.get('title', 'Untitled'))
for k in info: for k in info:
i.data[k] = info[k] i.data[k] = info[k]
i.level = 0 i.level = 0
@ -117,7 +117,7 @@ def update_stream(i):
return False return False
oshash = ox.net.oshash(stream_url) oshash = ox.net.oshash(stream_url)
if oshash == 'IOError': if oshash == 'IOError':
print 'invalid url', stream_url print('invalid url', stream_url)
return False return False
f, created = archive.models.File.objects.get_or_create(oshash=oshash) f, created = archive.models.File.objects.get_or_create(oshash=oshash)
f.item = i f.item = i
@ -140,6 +140,6 @@ def update_streams():
import itemlist.models import itemlist.models
l = itemlist.models.List.get('j:with Video') l = itemlist.models.List.get('j:with Video')
for i in item.models.Item.objects.all(): for i in item.models.Item.objects.all():
print i print(i)
if update_item_stream(i): if update_item_stream(i):
l.add(i) l.add(i)

View file

@ -11,10 +11,10 @@ for e in internetarchive.search.Search('collection:prelinger'):
if files: if files:
break break
if files: if files:
print item.metadata['title'] print(item.metadata['title'])
print 'https://archive.org/details/%s' % item.identifier print('https://archive.org/details/%s' % item.identifier)
url = 'https://archive.org/download/%s/%s' % (item.identifier, files[0]['name']) url = 'https://archive.org/download/%s/%s' % (item.identifier, files[0]['name'])
print url print(url)
data[item.identifier] = { data[item.identifier] = {
'id': item.identifier, 'id': item.identifier,
'mp4': url, 'mp4': url,
@ -36,8 +36,8 @@ for e in internetarchive.search.Search('collection:prelinger'):
else: else:
formats = sorted({f['format']:1 for f in item.files}.keys()) formats = sorted({f['format']:1 for f in item.files}.keys())
if formats: if formats:
print item.identifier, item.files print(item.identifier, item.files)
print formats print(formats)
with open('prelinger.json', 'w') as f: with open('prelinger.json', 'w') as f:
json.dump(data.values(), f, indent=2) json.dump(list(data.values()), f, indent=2)

View file

@ -1,4 +1,4 @@
from __future__ import division
import re import re
import ox import ox
import item.models import item.models