Compare commits

..

No commits in common. "6a597dea748df7e5f1e6e9f89dbc3debb660edb1" and "da37fd8f95d307bf8445d06d603f76629a952640" have entirely different histories.

View File

@ -8,6 +8,7 @@ from ..utils import (
UnsupportedError,
int_or_none,
parse_qs,
str_or_none,
traverse_obj,
urljoin,
)
@ -63,24 +64,25 @@ class AllstarBaseIE(InfoExtractor):
@staticmethod
def _parse_video_data(video_data):
def _media_url_or_none(path):
return urljoin('https://media.allstar.gg/', path)
return urljoin('https://media.allstar.gg/', str_or_none(path))
def _profile_url_or_none(path):
return urljoin('https:/allstar.gg/u/', path)
return urljoin('https:/allstar.gg/u/', str_or_none(path))
return traverse_obj(video_data, {
'id': ('_id', {str}),
'display_id': ('shareId', {str}),
'title': ('clipTitle', {str}),
'id': ('_id', {str_or_none}),
'display_id': ('shareId', {str_or_none}),
'title': ('clipTitle', {str_or_none}),
'url': ('clipLink', {_media_url_or_none}),
'thumbnail': ('clipImageThumb', {_media_url_or_none}),
'duration': ('clipLength', {int_or_none}),
'filesize': ('clipSizeBytes', {int_or_none}),
'timestamp': ('createdDate', {int_or_none}),
'uploader': ('username', {str}),
'uploader_id': ('user', '_id', {str}),
'uploader': ('username', {str_or_none}),
'uploader_id': ('user', '_id', {str_or_none}),
'uploader_url': ('user', '_id', {_profile_url_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):
@ -106,6 +108,7 @@ class AllstarIE(AllstarBaseIE):
'title': '4K on Inferno',
'url': 'md5:66befb5381eef0c9456026386c25fa55',
'thumbnail': 'md5:33c520f681627826a95ac43b092ecd2b',
'categories': '730',
'uploader': 'chrk.',
'ext': 'mp4',
'duration': 20,
@ -123,6 +126,7 @@ class AllstarIE(AllstarBaseIE):
'url': 'md5:dde224fd12f035c0e2529a4ae34c4283',
'ext': 'mp4',
'thumbnail': 'md5:90564b121f5fd7a4924920ef45614634',
'categories': '730',
'duration': 16,
'filesize': 30175859,
'timestamp': 1688333419392,
@ -161,7 +165,7 @@ class AllstarIE(AllstarBaseIE):
}]
def _real_extract(self, url):
query_id, video_id = self._match_valid_url(url).group('type', 'id')
query_id, video_id = self._match_valid_url(url).groups()
return self._parse_video_data(
self._send_query(
@ -232,16 +236,18 @@ class AllstarProfileIE(AllstarBaseIE):
def _real_extract(self, url):
display_id = self._match_id(url)
profile_data = self._download_json(
urljoin('https://api.allstar.gg/v1/users/profile/', display_id), display_id)
user_id = traverse_obj(profile_data, ('data', ('_id'), {str}))
urljoin('https://api.allstar.gg/v1/users/profile/', display_id),
display_id)
user_id = traverse_obj(profile_data, ('data', ('_id'), {str_or_none}))
if user_id is None:
raise ExtractorError('Can not extract the user_id')
username = traverse_obj(profile_data, ('data', 'profile', ('username'), {str}))
username = traverse_obj(profile_data, ('data', 'profile', ('username'), {str_or_none}))
url_query = parse_qs(url)
game = traverse_obj(url_query, ('game', 0, {int}))
query_id = traverse_obj(url_query, ('view', 0), default='Clips')
game = traverse_obj(url_query, ('game', 0, {int_or_none}))
view = traverse_obj(url_query, ('view', 0, {str_or_none}), default='Clips')
query_id = view
if query_id not in ('Clips', 'Montages', 'Mobile Clips'):
raise UnsupportedError(url)
@ -250,4 +256,4 @@ class AllstarProfileIE(AllstarBaseIE):
OnDemandPagedList(
functools.partial(
self._get_page, user_id, display_id, game, _QUERIES.get(query_id)), self._PAGE_SIZE),
user_id, f'{username or display_id} - {query_id}')
user_id, f'{username or display_id} - {view}')