mirror of
https://github.com/soimort/you-get.git
synced 2025-02-12 13:05:19 +03:00
实现了懒加载的同时,修复了下载问题
This commit is contained in:
parent
2b4fe58dd9
commit
2ae79f8f93
@ -151,17 +151,6 @@ class QQ(VideoExtractor):
|
|||||||
{'id': 'sd'},
|
{'id': 'sd'},
|
||||||
]
|
]
|
||||||
|
|
||||||
def _getvkey(self, vid, format, idx):
|
|
||||||
import uuid
|
|
||||||
appver = '3.2.38.401'
|
|
||||||
guid = uuid.uuid4().hex
|
|
||||||
platform = 11
|
|
||||||
cKey = echo_ckeyv3(vid=vid, guid=guid, player_version=appver, platform=platform)
|
|
||||||
key_api = 'http://vv.video.qq.com/getvkey?vid={vid}&appver={appver}&platform={platform}&otype=json&filename={vid}.p{format1000}.{idx}.mp4&format={format}&cKey={cKey}&guid={guid}&charge=0&encryptVer=5.4&lnk={vid}'.format(vid=vid, appver=appver, format1000=format%1000, format=format, cKey=cKey, guid=guid, platform=platform, idx=idx)
|
|
||||||
part_info = get_html(key_api)
|
|
||||||
key_json = json.loads(match1(part_info, r'QZOutputJson=(.*)')[:-1])
|
|
||||||
return key_json['key']
|
|
||||||
|
|
||||||
def prepare(self, **kwargs):
|
def prepare(self, **kwargs):
|
||||||
# vid = kwargs['vid'] if 'vid' in kwargs else None
|
# vid = kwargs['vid'] if 'vid' in kwargs else None
|
||||||
# vid = vid if vid is not None else self.vid
|
# vid = vid if vid is not None else self.vid
|
||||||
@ -181,12 +170,30 @@ class QQ(VideoExtractor):
|
|||||||
fi = video_json['fl']['fi'] # streams
|
fi = video_json['fl']['fi'] # streams
|
||||||
self.streams = {}
|
self.streams = {}
|
||||||
|
|
||||||
def lazy_urls(fid):
|
class LazyDict(dict):
|
||||||
for idx in range(1, vi0['cl']['fc']+1):
|
def __init__(self, stream_id=None, **kwargs):
|
||||||
yield '{prefix}/{vid}.p{format1000}.{idx}.mp4?vkey={vkey}'.format(prefix=url_prefix, vid=vid, format1000=fid%1000, idx=idx, vkey=self._getvkey(vid, fid, idx))
|
dict.__init__(self, **kwargs)
|
||||||
|
self.stream_id = stream_id
|
||||||
|
|
||||||
|
def _getvkey(self, vid, format, idx):
|
||||||
|
import uuid
|
||||||
|
appver = '3.2.38.401'
|
||||||
|
guid = uuid.uuid4().hex
|
||||||
|
platform = 11
|
||||||
|
cKey = echo_ckeyv3(vid=vid, guid=guid, player_version=appver, platform=platform)
|
||||||
|
key_api = 'http://vv.video.qq.com/getvkey?vid={vid}&appver={appver}&platform={platform}&otype=json&filename={vid}.p{format1000}.{idx}.mp4&format={format}&cKey={cKey}&guid={guid}&charge=0&encryptVer=5.4&lnk={vid}'.format(vid=vid, appver=appver, format1000=format%1000, format=format, cKey=cKey, guid=guid, platform=platform, idx=idx)
|
||||||
|
part_info = get_html(key_api)
|
||||||
|
key_json = json.loads(match1(part_info, r'QZOutputJson=(.*)')[:-1])
|
||||||
|
return key_json['key']
|
||||||
|
|
||||||
|
def __getitem__(self, key):
|
||||||
|
if key == 'src' and 'src' not in self:
|
||||||
|
self['src'] = ['{prefix}/{vid}.p{format1000}.{idx}.mp4?vkey={vkey}'.format(prefix=url_prefix, vid=vid, format1000=self.stream_id%1000, idx=idx, vkey=self._getvkey(vid, self.stream_id, idx)) for idx in range(1, vi0['cl']['fc']+1)]
|
||||||
|
return self['src']
|
||||||
|
else:
|
||||||
|
return dict.__getitem__(self, key)
|
||||||
|
|
||||||
for f in fi:
|
for f in fi:
|
||||||
|
|
||||||
# urls = ['{prefix}/{vid}.p{format1000}.{idx}.mp4?vkey={vkey}'.format(prefix=url_prefix, vid=vid, format1000=f['id']%1000, idx=idx, vkey=self._getvkey(vid, f['id'], idx)) for idx in range(1, vi0['cl']['fc']+1)]
|
# urls = ['{prefix}/{vid}.p{format1000}.{idx}.mp4?vkey={vkey}'.format(prefix=url_prefix, vid=vid, format1000=f['id']%1000, idx=idx, vkey=self._getvkey(vid, f['id'], idx)) for idx in range(1, vi0['cl']['fc']+1)]
|
||||||
|
|
||||||
# print(vi0['ul']['ui'])
|
# print(vi0['ul']['ui'])
|
||||||
@ -195,12 +202,12 @@ class QQ(VideoExtractor):
|
|||||||
# test = '{prefix}/{vid}.p{format1000}.1.mp4?vkey={vkey}'.format(prefix=ui['url'], vid=vid, format1000=f['id']%1000, vkey=vkey)
|
# test = '{prefix}/{vid}.p{format1000}.1.mp4?vkey={vkey}'.format(prefix=ui['url'], vid=vid, format1000=f['id']%1000, vkey=vkey)
|
||||||
# print(test)
|
# print(test)
|
||||||
|
|
||||||
self.streams[f['name']] = {
|
self.streams[f['name']] = LazyDict(
|
||||||
'video_profile': f['cname'],
|
video_profile=f['cname'],
|
||||||
'size': f['fs'],
|
size=f['fs'],
|
||||||
'container': 'mp4',
|
container='mp4',
|
||||||
'src': lazy_urls(f['id']),
|
stream_id=f['id']
|
||||||
}
|
)
|
||||||
|
|
||||||
|
|
||||||
site = QQ()
|
site = QQ()
|
||||||
|
Loading…
Reference in New Issue
Block a user