aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--yt_dlp/extractor/common.py19
-rw-r--r--yt_dlp/extractor/sovietscloset.py9
2 files changed, 28 insertions, 0 deletions
diff --git a/yt_dlp/extractor/common.py b/yt_dlp/extractor/common.py
index 4797e8e2d..114b1faaf 100644
--- a/yt_dlp/extractor/common.py
+++ b/yt_dlp/extractor/common.py
@@ -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:
diff --git a/yt_dlp/extractor/sovietscloset.py b/yt_dlp/extractor/sovietscloset.py
index 64201c88c..7df23759a 100644
--- a/yt_dlp/extractor/sovietscloset.py
+++ b/yt_dlp/extractor/sovietscloset.py
@@ -72,6 +72,7 @@ class SovietsClosetIE(SovietsClosetBaseIE):
'upload_date': '20170413',
'uploader_id': 'SovietWomble',
'uploader_url': 'https://www.twitch.tv/SovietWomble',
+ 'duration': 7007,
'was_live': True,
'availability': 'public',
'series': 'The Witcher',
@@ -96,6 +97,7 @@ class SovietsClosetIE(SovietsClosetBaseIE):
'upload_date': '20160420',
'uploader_id': 'SovietWomble',
'uploader_url': 'https://www.twitch.tv/SovietWomble',
+ 'duration': 8804,
'was_live': True,
'availability': 'public',
'series': 'Arma 3',
@@ -116,9 +118,16 @@ class SovietsClosetIE(SovietsClosetBaseIE):
m3u8_formats = self._extract_m3u8_formats(m3u8_url, video_id, headers=self.MEDIADELIVERY_REFERER)
self._sort_formats(m3u8_formats)
+ if not m3u8_formats:
+ duration = None
+ else:
+ duration = self._extract_m3u8_vod_duration(
+ m3u8_formats[0]['url'], video_id, headers=self.MEDIADELIVERY_REFERER)
+
return {
'formats': m3u8_formats,
'thumbnail': thumbnail_url,
+ 'duration': duration,
}
def _real_extract(self, url):