17 lines
1.6 KiB
Python
17 lines
1.6 KiB
Python
from pathlib import Path
|
|
import json,sys,hashlib,concurrent.futures
|
|
from urllib.parse import urlsplit
|
|
sys.path.insert(0,str(Path(__file__).parent));from fetch import fetch
|
|
P=Path(__file__).resolve().parents[2];D=P/'docs/rebuild-v2';R=D/'raw';media=json.loads((D/'media-inventory.json').read_text())
|
|
important=['/images/ni-x1.jpg','/images/ni-x2.jpg','/images/ni-x3.jpg','/images/ni-x4.jpg','/images/sert_1024x768.jpg','/download/doc/QuickStart_SVK007_006.zip','/download/doc/svk-002-mn.zip','/download/uvr_instr_2ch.zip','/download/doc/svk-007-instr.zip','/download/svk-002-mn.pdf','/download/samples/zeiss_800_600_GPS_1.zip','/download/samples/zeiss_800_600_GPS_2.zip']
|
|
important +=[x['path'] for x in media if x['mimetype']=='video/x-msvideo']
|
|
def work(item):
|
|
if item['path'] not in important or item['fetchStatus']=='downloaded-unreviewed' and item['path']!='/download/svk-002-mn.pdf':return
|
|
for year in ['2012','2008']:
|
|
url='https://web.archive.org/web/'+year+'id_/http://www.videoreg.ru:80'+item['path'];ext=Path(item['path']).suffix.lower();name='media/short-'+hashlib.sha256(url.encode()).hexdigest()[:16]+ext;rec=fetch(url,name,35)
|
|
if rec['httpStatus']=='200' and rec['bytes']>500:
|
|
item.update(fetchStatus='downloaded-unreviewed',rawFile=rec['raw'],sha256=rec['sha256'],bytes=rec['bytes'],requestedShortYear=year);return
|
|
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as ex:
|
|
for _ in ex.map(work,media):(D/'media-inventory.json').write_text(json.dumps(media,ensure_ascii=False,indent=2)+'\n')
|
|
print('IMPORTANT-MEDIA successes',[(x['path'],x['rawFile']) for x in media if x['path'] in important and x['fetchStatus']=='downloaded-unreviewed'])
|