youku --download the longest video in minimun segs
This commit is contained in:
parent
323f82a7e0
commit
b5d2c22d87
@ -138,6 +138,7 @@ class YoukuIE(InfoExtractor):
|
|||||||
compat_urllib_parse.urlencode(param)
|
compat_urllib_parse.urlencode(param)
|
||||||
video_urls.append(video_url)
|
video_urls.append(video_url)
|
||||||
video_urls_dict[format] = video_urls
|
video_urls_dict[format] = video_urls
|
||||||
|
print(video_urls)
|
||||||
|
|
||||||
return video_urls_dict
|
return video_urls_dict
|
||||||
|
|
||||||
@ -164,10 +165,6 @@ class YoukuIE(InfoExtractor):
|
|||||||
'flvhd': 'flv',
|
'flvhd': 'flv',
|
||||||
'mp4': 'mp4',
|
'mp4': 'mp4',
|
||||||
'mp4hd': 'mp4',
|
'mp4hd': 'mp4',
|
||||||
'mp4hd2': 'flv',
|
|
||||||
'mp4hd3': 'flv',
|
|
||||||
'hd2': 'flv',
|
|
||||||
'hd3': 'flv',
|
|
||||||
}
|
}
|
||||||
return ext_dict[fm]
|
return ext_dict[fm]
|
||||||
|
|
||||||
@ -231,6 +228,16 @@ class YoukuIE(InfoExtractor):
|
|||||||
# generate video_urls_dict
|
# generate video_urls_dict
|
||||||
video_urls_dict = self.construct_video_urls(data)
|
video_urls_dict = self.construct_video_urls(data)
|
||||||
|
|
||||||
|
# get the number of segs of the longest video stream
|
||||||
|
def get_segs(streams):
|
||||||
|
times = max([stream.get('milliseconds_video') for stream in streams])
|
||||||
|
seq = []
|
||||||
|
for stream in streams:
|
||||||
|
if times == stream.get('milliseconds_video'):
|
||||||
|
seq.append(len(stream.get('segs')))
|
||||||
|
return seq
|
||||||
|
|
||||||
|
seq = get_segs(data['stream'])
|
||||||
# construct info
|
# construct info
|
||||||
entries = [{
|
entries = [{
|
||||||
'id': '%s_part%d' % (video_id, i + 1),
|
'id': '%s_part%d' % (video_id, i + 1),
|
||||||
@ -238,12 +245,12 @@ class YoukuIE(InfoExtractor):
|
|||||||
'formats': [],
|
'formats': [],
|
||||||
# some formats are not available for all parts, we have to detect
|
# some formats are not available for all parts, we have to detect
|
||||||
# which one has all
|
# which one has all
|
||||||
} for i in range(max(len(v.get('segs')) for v in data['stream']))]
|
} for i in range(min(seq))]
|
||||||
for stream in data['stream']:
|
stream = data['stream'][seq.index(min(seq))]
|
||||||
fm = stream.get('stream_type')
|
fm = stream.get('stream_type')
|
||||||
video_urls = video_urls_dict[fm]
|
video_urls = video_urls_dict[fm]
|
||||||
for video_url, seg, entry in zip(video_urls, stream['segs'], entries):
|
for video_url, seg, entry in zip(video_urls, stream['segs'], entries):
|
||||||
entry['formats'].append({
|
entry['formats'].append({
|
||||||
'url': video_url,
|
'url': video_url,
|
||||||
'format_id': self.get_format_name(fm),
|
'format_id': self.get_format_name(fm),
|
||||||
'ext': self.parse_ext_l(fm),
|
'ext': self.parse_ext_l(fm),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user