mirror of
https://github.com/yt-dlp/yt-dlp
synced 2024-12-30 22:24:28 +01:00
[SovietsCloset] Add duration from m3u8 (#908)
Authored by: ChillingPepper
This commit is contained in:
parent
fecb20a503
commit
3cf4b91dc5
2 changed files with 28 additions and 0 deletions
|
@ -2219,6 +2219,25 @@ class InfoExtractor(object):
|
||||||
last_stream_inf = {}
|
last_stream_inf = {}
|
||||||
return formats, subtitles
|
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
|
@staticmethod
|
||||||
def _xpath_ns(path, namespace=None):
|
def _xpath_ns(path, namespace=None):
|
||||||
if not namespace:
|
if not namespace:
|
||||||
|
|
|
@ -72,6 +72,7 @@ class SovietsClosetIE(SovietsClosetBaseIE):
|
||||||
'upload_date': '20170413',
|
'upload_date': '20170413',
|
||||||
'uploader_id': 'SovietWomble',
|
'uploader_id': 'SovietWomble',
|
||||||
'uploader_url': 'https://www.twitch.tv/SovietWomble',
|
'uploader_url': 'https://www.twitch.tv/SovietWomble',
|
||||||
|
'duration': 7007,
|
||||||
'was_live': True,
|
'was_live': True,
|
||||||
'availability': 'public',
|
'availability': 'public',
|
||||||
'series': 'The Witcher',
|
'series': 'The Witcher',
|
||||||
|
@ -96,6 +97,7 @@ class SovietsClosetIE(SovietsClosetBaseIE):
|
||||||
'upload_date': '20160420',
|
'upload_date': '20160420',
|
||||||
'uploader_id': 'SovietWomble',
|
'uploader_id': 'SovietWomble',
|
||||||
'uploader_url': 'https://www.twitch.tv/SovietWomble',
|
'uploader_url': 'https://www.twitch.tv/SovietWomble',
|
||||||
|
'duration': 8804,
|
||||||
'was_live': True,
|
'was_live': True,
|
||||||
'availability': 'public',
|
'availability': 'public',
|
||||||
'series': 'Arma 3',
|
'series': 'Arma 3',
|
||||||
|
@ -116,9 +118,16 @@ class SovietsClosetIE(SovietsClosetBaseIE):
|
||||||
m3u8_formats = self._extract_m3u8_formats(m3u8_url, video_id, headers=self.MEDIADELIVERY_REFERER)
|
m3u8_formats = self._extract_m3u8_formats(m3u8_url, video_id, headers=self.MEDIADELIVERY_REFERER)
|
||||||
self._sort_formats(m3u8_formats)
|
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 {
|
return {
|
||||||
'formats': m3u8_formats,
|
'formats': m3u8_formats,
|
||||||
'thumbnail': thumbnail_url,
|
'thumbnail': thumbnail_url,
|
||||||
|
'duration': duration,
|
||||||
}
|
}
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
|
|
Loading…
Reference in a new issue