40 lines
1.9 KiB
Python
40 lines
1.9 KiB
Python
import os, subprocess, json
|
|
D='/opt/work-hub/docs/datasheets/yealink'
|
|
os.makedirs(D, exist_ok=True)
|
|
BASE='https://www.yealink.com/website-service/download/'
|
|
models = [
|
|
('MeetingBar-A10','A10'), ('DeskVision-A24','A24'), ('MeetingBar-A40','A40'),
|
|
('MeetingEye-400','M400'), ('M500','M500'), ('MeetingEye-600','M600'), ('M900','M900'),
|
|
('MeetingBoard-65','MB65'), ('MeetingBoard-86','MB86'),
|
|
('MeetingDisplay-55','MD55'), ('MeetingDisplay-65','MD65'),
|
|
('RoomPanel','RoomPanel'), ('VP59','VP59'),
|
|
('UVC20','UVC20'), ('UVC40','UVC40'), ('UVC42','UVC42'), ('UVC44','UVC44'),
|
|
('UVC85','UVC85'), ('UVC86','UVC86'), ('UVC88','UVC88'),
|
|
('CP50','CP50'), ('CP965','CP965'), ('CTP18','CTP18'), ('MCore-Pro','MCore Pro'),
|
|
('VCM35','VCM35'), ('VCM36','VCM36-W'), ('CM20','CM20'), ('CS10','CS10'),
|
|
('RoomCast','RoomCast'), ('WPP30','WPP30'), ('VCH51','VCH51'), ('A50','A50'),
|
|
]
|
|
variants = ['{m}-Datasheet.pdf', '{m}-Datasheet-EN.pdf', 'Yealink-{m}-Datasheet.pdf', '{m}-DATASHEET.pdf']
|
|
ok, miss = [], []
|
|
for token, label in models:
|
|
got = False
|
|
for v in variants:
|
|
fname = v.format(m=token)
|
|
out = os.path.join(D, fname)
|
|
code = subprocess.run(['curl','-sL','--max-time','20','-A','Mozilla/5.0','-o',out,'-w','%{http_code}', BASE+fname],capture_output=True,text=True).stdout
|
|
if code != '200':
|
|
if os.path.exists(out): os.remove(out)
|
|
continue
|
|
with open(out,'rb') as fh:
|
|
head = fh.read(4)
|
|
if head != b'%PDF':
|
|
os.remove(out); continue
|
|
ok.append((label, fname, os.path.getsize(out)))
|
|
got = True
|
|
break
|
|
if not got:
|
|
miss.append(label)
|
|
print('скачано:', len(ok), '| не найдено:', len(miss))
|
|
for l,f,s in ok: print(' +', l, f, round(s/1024), 'КБ')
|
|
print(' не найдено:', ', '.join(miss) if miss else '—')
|
|
json.dump({'ok':ok,'miss':miss}, open('/opt/work-hub/docs/datasheets/yealink/_result.json','w'), ensure_ascii=False) |