Compare commits

...

6 Commits

Author SHA1 Message Date
sfn
6a597dea74 remove str_or_none 2023-11-17 17:09:26 +01:00
sfn
743d4049fe remove categories from test 2023-11-17 16:58:01 +01:00
Safouane Aarab
ab50a3bafa
game is not a good category name
Co-authored-by: sepro <4618135+seproDev@users.noreply.github.com>
2023-11-17 16:52:27 +01:00
Safouane Aarab
1252f45820
Update yt_dlp/extractor/allstar.py
Co-authored-by: sepro <4618135+seproDev@users.noreply.github.com>
2023-11-17 16:51:18 +01:00
Safouane Aarab
a065aef0fc
Update yt_dlp/extractor/allstar.py
group is preferred over groups

Co-authored-by: sepro <4618135+seproDev@users.noreply.github.com>
2023-11-17 16:50:57 +01:00
Safouane Aarab
db93c2bc9b
Apply suggestions from code review
use int/str instead of int_or_none/str_or_none

Co-authored-by: sepro <4618135+seproDev@users.noreply.github.com>
2023-11-17 16:49:57 +01:00

View File

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