mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-09-23 10:51:24 +02:00
Compare commits
6 Commits
da37fd8f95
...
6a597dea74
Author | SHA1 | Date | |
---|---|---|---|
|
6a597dea74 | ||
|
743d4049fe | ||
|
ab50a3bafa | ||
|
1252f45820 | ||
|
a065aef0fc | ||
|
db93c2bc9b |
|
@ -8,7 +8,6 @@ from ..utils import (
|
||||||
UnsupportedError,
|
UnsupportedError,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
parse_qs,
|
parse_qs,
|
||||||
str_or_none,
|
|
||||||
traverse_obj,
|
traverse_obj,
|
||||||
urljoin,
|
urljoin,
|
||||||
)
|
)
|
||||||
|
@ -64,25 +63,24 @@ class AllstarBaseIE(InfoExtractor):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse_video_data(video_data):
|
def _parse_video_data(video_data):
|
||||||
def _media_url_or_none(path):
|
def _media_url_or_none(path):
|
||||||
return urljoin('https://media.allstar.gg/', str_or_none(path))
|
return urljoin('https://media.allstar.gg/', path)
|
||||||
|
|
||||||
def _profile_url_or_none(path):
|
def _profile_url_or_none(path):
|
||||||
return urljoin('https:/allstar.gg/u/', str_or_none(path))
|
return urljoin('https:/allstar.gg/u/', path)
|
||||||
|
|
||||||
return traverse_obj(video_data, {
|
return traverse_obj(video_data, {
|
||||||
'id': ('_id', {str_or_none}),
|
'id': ('_id', {str}),
|
||||||
'display_id': ('shareId', {str_or_none}),
|
'display_id': ('shareId', {str}),
|
||||||
'title': ('clipTitle', {str_or_none}),
|
'title': ('clipTitle', {str}),
|
||||||
'url': ('clipLink', {_media_url_or_none}),
|
'url': ('clipLink', {_media_url_or_none}),
|
||||||
'thumbnail': ('clipImageThumb', {_media_url_or_none}),
|
'thumbnail': ('clipImageThumb', {_media_url_or_none}),
|
||||||
'duration': ('clipLength', {int_or_none}),
|
'duration': ('clipLength', {int_or_none}),
|
||||||
'filesize': ('clipSizeBytes', {int_or_none}),
|
'filesize': ('clipSizeBytes', {int_or_none}),
|
||||||
'timestamp': ('createdDate', {int_or_none}),
|
'timestamp': ('createdDate', {int_or_none}),
|
||||||
'uploader': ('username', {str_or_none}),
|
'uploader': ('username', {str}),
|
||||||
'uploader_id': ('user', '_id', {str_or_none}),
|
'uploader_id': ('user', '_id', {str}),
|
||||||
'uploader_url': ('user', '_id', {_profile_url_or_none}),
|
'uploader_url': ('user', '_id', {_profile_url_or_none}),
|
||||||
'view_count': ('views', {int_or_none}),
|
'view_count': ('views', {int_or_none}),
|
||||||
'categories': ('game', {str_or_none}),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
def _send_query(self, query, variables={}, path=(), video_id=None, note=None):
|
def _send_query(self, query, variables={}, path=(), video_id=None, note=None):
|
||||||
|
@ -108,7 +106,6 @@ class AllstarIE(AllstarBaseIE):
|
||||||
'title': '4K on Inferno',
|
'title': '4K on Inferno',
|
||||||
'url': 'md5:66befb5381eef0c9456026386c25fa55',
|
'url': 'md5:66befb5381eef0c9456026386c25fa55',
|
||||||
'thumbnail': 'md5:33c520f681627826a95ac43b092ecd2b',
|
'thumbnail': 'md5:33c520f681627826a95ac43b092ecd2b',
|
||||||
'categories': '730',
|
|
||||||
'uploader': 'chrk.',
|
'uploader': 'chrk.',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'duration': 20,
|
'duration': 20,
|
||||||
|
@ -126,7 +123,6 @@ class AllstarIE(AllstarBaseIE):
|
||||||
'url': 'md5:dde224fd12f035c0e2529a4ae34c4283',
|
'url': 'md5:dde224fd12f035c0e2529a4ae34c4283',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'thumbnail': 'md5:90564b121f5fd7a4924920ef45614634',
|
'thumbnail': 'md5:90564b121f5fd7a4924920ef45614634',
|
||||||
'categories': '730',
|
|
||||||
'duration': 16,
|
'duration': 16,
|
||||||
'filesize': 30175859,
|
'filesize': 30175859,
|
||||||
'timestamp': 1688333419392,
|
'timestamp': 1688333419392,
|
||||||
|
@ -165,7 +161,7 @@ class AllstarIE(AllstarBaseIE):
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
query_id, video_id = self._match_valid_url(url).groups()
|
query_id, video_id = self._match_valid_url(url).group('type', 'id')
|
||||||
|
|
||||||
return self._parse_video_data(
|
return self._parse_video_data(
|
||||||
self._send_query(
|
self._send_query(
|
||||||
|
@ -236,18 +232,16 @@ class AllstarProfileIE(AllstarBaseIE):
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
display_id = self._match_id(url)
|
display_id = self._match_id(url)
|
||||||
profile_data = self._download_json(
|
profile_data = self._download_json(
|
||||||
urljoin('https://api.allstar.gg/v1/users/profile/', display_id),
|
urljoin('https://api.allstar.gg/v1/users/profile/', display_id), display_id)
|
||||||
display_id)
|
user_id = traverse_obj(profile_data, ('data', ('_id'), {str}))
|
||||||
user_id = traverse_obj(profile_data, ('data', ('_id'), {str_or_none}))
|
|
||||||
|
|
||||||
if user_id is None:
|
if user_id is None:
|
||||||
raise ExtractorError('Can not extract the user_id')
|
raise ExtractorError('Can not extract the user_id')
|
||||||
|
|
||||||
username = traverse_obj(profile_data, ('data', 'profile', ('username'), {str_or_none}))
|
username = traverse_obj(profile_data, ('data', 'profile', ('username'), {str}))
|
||||||
url_query = parse_qs(url)
|
url_query = parse_qs(url)
|
||||||
game = traverse_obj(url_query, ('game', 0, {int_or_none}))
|
game = traverse_obj(url_query, ('game', 0, {int}))
|
||||||
view = traverse_obj(url_query, ('view', 0, {str_or_none}), default='Clips')
|
query_id = traverse_obj(url_query, ('view', 0), default='Clips')
|
||||||
query_id = view
|
|
||||||
|
|
||||||
if query_id not in ('Clips', 'Montages', 'Mobile Clips'):
|
if query_id not in ('Clips', 'Montages', 'Mobile Clips'):
|
||||||
raise UnsupportedError(url)
|
raise UnsupportedError(url)
|
||||||
|
@ -256,4 +250,4 @@ class AllstarProfileIE(AllstarBaseIE):
|
||||||
OnDemandPagedList(
|
OnDemandPagedList(
|
||||||
functools.partial(
|
functools.partial(
|
||||||
self._get_page, user_id, display_id, game, _QUERIES.get(query_id)), self._PAGE_SIZE),
|
self._get_page, user_id, display_id, game, _QUERIES.get(query_id)), self._PAGE_SIZE),
|
||||||
user_id, f'{username or display_id} - {view}')
|
user_id, f'{username or display_id} - {query_id}')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user