mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-09-03 16:45:17 +00:00
[SovietsCloset] Add duration from m3u8 (#908)
Authored by: ChillingPepper
This commit is contained in:
@ -2219,6 +2219,25 @@ class InfoExtractor(object):
|
||||
last_stream_inf = {}
|
||||
return formats, subtitles
|
||||
|
||||
def _extract_m3u8_vod_duration(
|
||||
self, m3u8_vod_url, video_id, note=None, errnote=None, data=None, headers={}, query={}):
|
||||
|
||||
m3u8_vod = self._download_webpage(
|
||||
m3u8_vod_url, video_id,
|
||||
note='Downloading m3u8 VOD manifest' if note is None else note,
|
||||
errnote='Failed to download VOD manifest' if errnote is None else errnote,
|
||||
fatal=False, data=data, headers=headers, query=query)
|
||||
|
||||
return self._parse_m3u8_vod_duration(m3u8_vod or '', video_id)
|
||||
|
||||
def _parse_m3u8_vod_duration(self, m3u8_vod, video_id):
|
||||
if '#EXT-X-PLAYLIST-TYPE:VOD' not in m3u8_vod:
|
||||
return None
|
||||
|
||||
return int(sum(
|
||||
float(line[len('#EXTINF:'):].split(',')[0])
|
||||
for line in m3u8_vod.splitlines() if line.startswith('#EXTINF:'))) or None
|
||||
|
||||
@staticmethod
|
||||
def _xpath_ns(path, namespace=None):
|
||||
if not namespace:
|
||||
|
Reference in New Issue
Block a user