1
0
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:
ChillingPepper
2021-09-27 23:00:41 +02:00
committed by GitHub
parent fecb20a503
commit 3cf4b91dc5
2 changed files with 28 additions and 0 deletions

View File

@ -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: