mirror of https://github.com/yt-dlp/yt-dlp.git
[hitbox] Add support for smashcast.tv (closes #13154)
This commit is contained in:
parent
00cb0faca8
commit
5f6fbcea08
|
@ -16,8 +16,8 @@ from ..utils import (
|
||||||
|
|
||||||
class HitboxIE(InfoExtractor):
|
class HitboxIE(InfoExtractor):
|
||||||
IE_NAME = 'hitbox'
|
IE_NAME = 'hitbox'
|
||||||
_VALID_URL = r'https?://(?:www\.)?hitbox\.tv/video/(?P<id>[0-9]+)'
|
_VALID_URL = r'https?://(?:www\.)?(?:hitbox|smashcast)\.tv/(?:[^/]+/)*videos?/(?P<id>[0-9]+)'
|
||||||
_TEST = {
|
_TESTS = [{
|
||||||
'url': 'http://www.hitbox.tv/video/203213',
|
'url': 'http://www.hitbox.tv/video/203213',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '203213',
|
'id': '203213',
|
||||||
|
@ -38,13 +38,15 @@ class HitboxIE(InfoExtractor):
|
||||||
# m3u8 download
|
# m3u8 download
|
||||||
'skip_download': True,
|
'skip_download': True,
|
||||||
},
|
},
|
||||||
}
|
}, {
|
||||||
|
'url': 'https://www.smashcast.tv/hitboxlive/videos/203213',
|
||||||
|
'only_matching': True,
|
||||||
|
}]
|
||||||
|
|
||||||
def _extract_metadata(self, url, video_id):
|
def _extract_metadata(self, url, video_id):
|
||||||
thumb_base = 'https://edge.sf.hitbox.tv'
|
thumb_base = 'https://edge.sf.hitbox.tv'
|
||||||
metadata = self._download_json(
|
metadata = self._download_json(
|
||||||
'%s/%s' % (url, video_id), video_id,
|
'%s/%s' % (url, video_id), video_id, 'Downloading metadata JSON')
|
||||||
'Downloading metadata JSON')
|
|
||||||
|
|
||||||
date = 'media_live_since'
|
date = 'media_live_since'
|
||||||
media_type = 'livestream'
|
media_type = 'livestream'
|
||||||
|
@ -63,14 +65,15 @@ class HitboxIE(InfoExtractor):
|
||||||
views = int_or_none(video_meta.get('media_views'))
|
views = int_or_none(video_meta.get('media_views'))
|
||||||
timestamp = parse_iso8601(video_meta.get(date), ' ')
|
timestamp = parse_iso8601(video_meta.get(date), ' ')
|
||||||
categories = [video_meta.get('category_name')]
|
categories = [video_meta.get('category_name')]
|
||||||
thumbs = [
|
thumbs = [{
|
||||||
{'url': thumb_base + video_meta.get('media_thumbnail'),
|
'url': thumb_base + video_meta.get('media_thumbnail'),
|
||||||
'width': 320,
|
'width': 320,
|
||||||
'height': 180},
|
'height': 180
|
||||||
{'url': thumb_base + video_meta.get('media_thumbnail_large'),
|
}, {
|
||||||
'width': 768,
|
'url': thumb_base + video_meta.get('media_thumbnail_large'),
|
||||||
'height': 432},
|
'width': 768,
|
||||||
]
|
'height': 432
|
||||||
|
}]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
|
@ -90,7 +93,7 @@ class HitboxIE(InfoExtractor):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
|
|
||||||
player_config = self._download_json(
|
player_config = self._download_json(
|
||||||
'https://www.hitbox.tv/api/player/config/video/%s' % video_id,
|
'https://www.smashcast.tv/api/player/config/video/%s' % video_id,
|
||||||
video_id, 'Downloading video JSON')
|
video_id, 'Downloading video JSON')
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
|
@ -121,8 +124,7 @@ class HitboxIE(InfoExtractor):
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
metadata = self._extract_metadata(
|
metadata = self._extract_metadata(
|
||||||
'https://www.hitbox.tv/api/media/video',
|
'https://www.smashcast.tv/api/media/video', video_id)
|
||||||
video_id)
|
|
||||||
metadata['formats'] = formats
|
metadata['formats'] = formats
|
||||||
|
|
||||||
return metadata
|
return metadata
|
||||||
|
@ -130,8 +132,8 @@ class HitboxIE(InfoExtractor):
|
||||||
|
|
||||||
class HitboxLiveIE(HitboxIE):
|
class HitboxLiveIE(HitboxIE):
|
||||||
IE_NAME = 'hitbox:live'
|
IE_NAME = 'hitbox:live'
|
||||||
_VALID_URL = r'https?://(?:www\.)?hitbox\.tv/(?!video)(?P<id>.+)'
|
_VALID_URL = r'https?://(?:www\.)?(?:hitbox|smashcast)\.tv/(?P<id>[^/?#&]+)'
|
||||||
_TEST = {
|
_TESTS = [{
|
||||||
'url': 'http://www.hitbox.tv/dimak',
|
'url': 'http://www.hitbox.tv/dimak',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'dimak',
|
'id': 'dimak',
|
||||||
|
@ -146,13 +148,20 @@ class HitboxLiveIE(HitboxIE):
|
||||||
# live
|
# live
|
||||||
'skip_download': True,
|
'skip_download': True,
|
||||||
},
|
},
|
||||||
}
|
}, {
|
||||||
|
'url': 'https://www.smashcast.tv/dimak',
|
||||||
|
'only_matching': True,
|
||||||
|
}]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def suitable(cls, url):
|
||||||
|
return False if HitboxIE.suitable(url) else super(HitboxLiveIE, cls).suitable(url)
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
|
|
||||||
player_config = self._download_json(
|
player_config = self._download_json(
|
||||||
'https://www.hitbox.tv/api/player/config/live/%s' % video_id,
|
'https://www.smashcast.tv/api/player/config/live/%s' % video_id,
|
||||||
video_id)
|
video_id)
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
|
@ -197,8 +206,7 @@ class HitboxLiveIE(HitboxIE):
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
metadata = self._extract_metadata(
|
metadata = self._extract_metadata(
|
||||||
'https://www.hitbox.tv/api/media/live',
|
'https://www.smashcast.tv/api/media/live', video_id)
|
||||||
video_id)
|
|
||||||
metadata['formats'] = formats
|
metadata['formats'] = formats
|
||||||
metadata['is_live'] = True
|
metadata['is_live'] = True
|
||||||
metadata['title'] = self._live_title(metadata.get('title'))
|
metadata['title'] = self._live_title(metadata.get('title'))
|
||||||
|
|
Loading…
Reference in New Issue