mirror of
https://github.com/l1ving/youtube-dl
synced 2025-03-13 21:47:23 +08:00
[StreamMe]: flake8 checked
This commit is contained in:
parent
4666796c6c
commit
45a80c1b16
@ -10,6 +10,7 @@ from ..utils import (
|
|||||||
ExtractorError,
|
ExtractorError,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class StreamMeIE(InfoExtractor):
|
class StreamMeIE(InfoExtractor):
|
||||||
IE_NAME = 'StreamMe:video'
|
IE_NAME = 'StreamMe:video'
|
||||||
_API_CHANNEL = 'https://www.stream.me/api-user/v1/<channel_id>/channel'
|
_API_CHANNEL = 'https://www.stream.me/api-user/v1/<channel_id>/channel'
|
||||||
@ -35,7 +36,6 @@ class StreamMeIE(InfoExtractor):
|
|||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
apiurl = self._API_ARCHIVE.replace('<channel_id>', m.group('channel_id'))
|
apiurl = self._API_ARCHIVE.replace('<channel_id>', m.group('channel_id'))
|
||||||
|
|
||||||
# webpage = self._download_webpage(url, video_id)
|
|
||||||
data = json.loads(self._download_webpage(apiurl, video_id))
|
data = json.loads(self._download_webpage(apiurl, video_id))
|
||||||
|
|
||||||
for vod in data.get('_embedded').get('vod'):
|
for vod in data.get('_embedded').get('vod'):
|
||||||
@ -43,14 +43,13 @@ class StreamMeIE(InfoExtractor):
|
|||||||
if vod.get('urlId') == video_id:
|
if vod.get('urlId') == video_id:
|
||||||
vod_info = vod
|
vod_info = vod
|
||||||
break
|
break
|
||||||
|
|
||||||
manifest_json = self._download_json(vod_info
|
manifest_json = self._download_json(vod_info
|
||||||
.get('_links')
|
.get('_links')
|
||||||
.get('manifest')
|
.get('manifest')
|
||||||
.get('href'), video_id)
|
.get('href'), video_id)
|
||||||
|
|
||||||
formats = self._extract_formats(manifest_json.get('formats'))
|
formats = self._extract_formats(manifest_json.get('formats'))
|
||||||
|
|
||||||
self._sort_formats(formats, 'vbr')
|
self._sort_formats(formats, 'vbr')
|
||||||
info = self._extract_info(vod_info)
|
info = self._extract_info(vod_info)
|
||||||
info['formats'] = formats
|
info['formats'] = formats
|
||||||
@ -79,23 +78,25 @@ class StreamMeIE(InfoExtractor):
|
|||||||
formats = []
|
formats = []
|
||||||
for fmt_tag, d in fmts.items():
|
for fmt_tag, d in fmts.items():
|
||||||
# skip websocket and mjpeg we can't handle them anyway
|
# skip websocket and mjpeg we can't handle them anyway
|
||||||
if fmt_tag in ('mjpeg-lodef', 'mp4-ws',): continue
|
if fmt_tag in ('mjpeg-lodef', 'mp4-ws',):
|
||||||
|
continue
|
||||||
for fmt_info in d.get('encodings'):
|
for fmt_info in d.get('encodings'):
|
||||||
formats.append({
|
formats.append({
|
||||||
'url': fmt_info.get('location'),
|
'url': fmt_info.get('location'),
|
||||||
'width': fmt_info.get('videoWidth'),
|
'width': fmt_info.get('videoWidth'),
|
||||||
'height': fmt_info.get('videoHeight'),
|
'height': fmt_info.get('videoHeight'),
|
||||||
'vbr': fmt_info.get('videoKbps'),
|
'vbr': fmt_info.get('videoKbps'),
|
||||||
'abr': fmt_info.get('audioKbps'),
|
'abr': fmt_info.get('audioKbps'),
|
||||||
'acodec': d.get('audioCodec'),
|
'acodec': d.get('audioCodec'),
|
||||||
'vcodec': d.get('videoCodec'),
|
'vcodec': d.get('videoCodec'),
|
||||||
'format_id': "%s%sp" % (fmt_tag, fmt_info.get('videoHeight')),
|
'format_id': "%s%sp" % (fmt_tag, fmt_info.get('videoHeight')),
|
||||||
'ext': 'flv' if fmt_tag.split('-')[1] == 'rtmp' else 'mp4',
|
'ext': 'flv' if fmt_tag.split('-')[1] == 'rtmp' else 'mp4',
|
||||||
# I don't know all the possible protocols yet.
|
# I don't know all the possible protocols yet.
|
||||||
# 'protocol': 'm3u8_native' if fmt_tag == 'mp4-hls' else 'http'
|
# 'protocol': 'm3u8_native' if fmt_tag == 'mp4-hls' else 'http'
|
||||||
})
|
})
|
||||||
return formats
|
return formats
|
||||||
|
|
||||||
|
|
||||||
class StreamMeLiveIE(StreamMeIE):
|
class StreamMeLiveIE(StreamMeIE):
|
||||||
IE_NAME = 'StreamIE:live'
|
IE_NAME = 'StreamIE:live'
|
||||||
_VALID_URL = r'%s/(?P<id>[^\#]+$)' % StreamMeIE._VALID_URL_BASE
|
_VALID_URL = r'%s/(?P<id>[^\#]+$)' % StreamMeIE._VALID_URL_BASE
|
||||||
@ -106,44 +107,48 @@ class StreamMeLiveIE(StreamMeIE):
|
|||||||
|
|
||||||
data = json.loads(self._download_webpage(apiurl, channel_id))
|
data = json.loads(self._download_webpage(apiurl, channel_id))
|
||||||
stream_info = []
|
stream_info = []
|
||||||
# search for a live stream...
|
# search for a live stream...
|
||||||
for stream in data.get('_embedded').get('streams'):
|
for stream in data.get('_embedded').get('streams'):
|
||||||
stream_info = stream
|
stream_info = stream
|
||||||
break # TODO: add to a list (multi-streams?)
|
break # TODO: add to a list (multi-streams?)
|
||||||
|
|
||||||
if not stream_info.get('active'):
|
if not stream_info.get('active'):
|
||||||
raise ExtractorError('%s is offline' % channel_id, expected=True)
|
raise ExtractorError('%s is offline' % channel_id, expected=True)
|
||||||
|
|
||||||
manifest_json = self._download_json(stream_info
|
|
||||||
.get('_links')
|
|
||||||
.get('manifest')
|
|
||||||
.get('href'), channel_id)
|
|
||||||
formats = self._extract_formats(manifest_json.get('formats'))
|
|
||||||
|
|
||||||
|
manifest_json = self._download_json(stream_info
|
||||||
|
.get('_links')
|
||||||
|
.get('manifest')
|
||||||
|
.get('href'), channel_id)
|
||||||
|
|
||||||
|
formats = self._extract_formats(manifest_json.get('formats'))
|
||||||
self._sort_formats(formats, 'vbr')
|
self._sort_formats(formats, 'vbr')
|
||||||
info = self._extract_info(stream_info)
|
info = self._extract_info(stream_info)
|
||||||
info['formats'] = formats
|
info['formats'] = formats
|
||||||
return info
|
return info
|
||||||
|
|
||||||
|
|
||||||
class StreamMeArchiveIE(StreamMeIE):
|
class StreamMeArchiveIE(StreamMeIE):
|
||||||
IE_NAME = 'StreamMe:archives'
|
IE_NAME = 'StreamMe:archives'
|
||||||
_VALID_URL = r'%s/(?P<id>[^\#]+(?P<tag>\#archives)$)' % StreamMeIE._VALID_URL_BASE
|
_VALID_URL = r'%s/(?P<id>[^\#]+(?P<tag>\#archives)$)' % StreamMeIE._VALID_URL_BASE
|
||||||
_PLAYLIST_TYPE = 'past broadcasts'
|
_PLAYLIST_TYPE = 'past broadcasts'
|
||||||
_PLAYLIST_LIMIT = 128
|
_PLAYLIST_LIMIT = 128
|
||||||
_TEST = {
|
_TEST = {
|
||||||
'url': 'https://www.stream.me/kombatcup#archives',
|
'url': 'https://www.stream.me/kombatcup#archives',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'kombatcup',
|
'id': 'kombatcup',
|
||||||
'title': 'KombatCup',
|
'title': 'KombatCup',
|
||||||
},
|
},
|
||||||
'playlist_mincount': 25,
|
'playlist_mincount': 25,
|
||||||
|
'params': {
|
||||||
|
'skip_download': True,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
channel_id = self._match_id(url).split('#')[0]
|
channel_id = self._match_id(url).split('#')[0]
|
||||||
apiurl = StreamMeIE._API_ARCHIVE.replace('<channel_id>', channel_id)
|
apiurl = StreamMeIE._API_ARCHIVE.replace('<channel_id>', channel_id)
|
||||||
# TODO: implement paginated downloading
|
# TODO: implement paginated downloading
|
||||||
data = json.loads(self._download_webpage(apiurl+'?limit=%d&offset=0' % self._PLAYLIST_LIMIT, channel_id))
|
data = json.loads(self._download_webpage(apiurl + '?limit=%d&offset=0' % self._PLAYLIST_LIMIT, channel_id))
|
||||||
playlist = []
|
playlist = []
|
||||||
|
|
||||||
for vod in data.get('_embedded').get('vod'):
|
for vod in data.get('_embedded').get('vod'):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user