mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-23 15:51:24 +01:00
Compare commits
1 Commits
a9ed3fea3f
...
f6d459c4e6
Author | SHA1 | Date | |
---|---|---|---|
|
f6d459c4e6 |
|
@ -1,5 +1,12 @@
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import get_element_by_id, int_or_none, merge_dicts, mimetype2ext, str_or_none, url_or_none
|
from ..utils import (
|
||||||
|
get_element_by_id,
|
||||||
|
int_or_none,
|
||||||
|
merge_dicts,
|
||||||
|
mimetype2ext,
|
||||||
|
url_or_none,
|
||||||
|
urljoin,
|
||||||
|
)
|
||||||
from ..utils.traversal import traverse_obj
|
from ..utils.traversal import traverse_obj
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,8 +26,6 @@ class AparatIE(InfoExtractor):
|
||||||
'timestamp': 1387394859,
|
'timestamp': 1387394859,
|
||||||
'upload_date': '20131218',
|
'upload_date': '20131218',
|
||||||
'view_count': int,
|
'view_count': int,
|
||||||
'thumbnail': r're:https://static\.cdn\.asset\.aparat\.cloud/.+',
|
|
||||||
'like_count': int,
|
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
# multiple formats
|
# multiple formats
|
||||||
|
@ -128,35 +133,24 @@ class AparatPlaylistIE(InfoExtractor):
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
playlist_id = self._match_id(url)
|
playlist_id = self._match_id(url)
|
||||||
info = self._download_json(
|
info = self._download_json(
|
||||||
f'https://www.aparat.com/api/fa/v1/video/playlist/one/playlist_id/{playlist_id}',
|
f'https://www.aparat.com/api/fa/v1/video/playlist/one/playlist_id/{playlist_id}', playlist_id)
|
||||||
playlist_id, note='Getting playlist info', errnote='Failed to get playlist info')
|
|
||||||
|
|
||||||
info_dict = {
|
info_dict = traverse_obj(info, ('data', 'attributes', {
|
||||||
**traverse_obj(info, ('data', 'attributes', {
|
'playlist_title': ('title'),
|
||||||
'title': 'title',
|
'description': ('description'),
|
||||||
'description': 'description',
|
}), default={})
|
||||||
'thumbnails': (('big_poster', 'small_poster'), all, ..., {url_or_none}, {lambda x: {'url': x}}),
|
info_dict.update(thumbnails=traverse_obj([
|
||||||
}), default={}),
|
traverse_obj(info, ('data', 'attributes', {'url': ('big_poster', {url_or_none})})),
|
||||||
'id': playlist_id,
|
traverse_obj(info, ('data', 'attributes', {'url': ('small_poster', {url_or_none})})),
|
||||||
'entries': traverse_obj(info, (
|
], (...), default=[]))
|
||||||
'included', lambda _, v: v['type'] == 'Video', 'attributes', 'uid',
|
info_dict.update(**traverse_obj(info, ('included', lambda _, v: v['type'] == 'channel', 'attributes', {
|
||||||
{lambda x: self.url_result(f'https://www.aparat.com/v/{x}?playlist={playlist_id}')},
|
'channel': ('username'),
|
||||||
), default=[]),
|
'channel_id': ('id'),
|
||||||
}
|
'channel_url': ('link', filter, {urljoin(base=url)}), # starts with a slash
|
||||||
|
'channel_follower_count': ('follower_cnt', {int_or_none}),
|
||||||
|
}), get_all=False))
|
||||||
|
|
||||||
if username := traverse_obj(
|
return self.playlist_result(traverse_obj(info, (
|
||||||
info, ('included', lambda _, v: v['type'] == 'channel', 'attributes', 'username'), get_all=False):
|
'included', lambda _, v: v['type'] == 'Video', 'attributes', 'uid',
|
||||||
user_info = self._download_json(
|
{lambda uid: self.url_result(f'https://www.aparat.com/v/{uid}?playlist={playlist_id}')},
|
||||||
f'https://www.aparat.com/api/fa/v1/user/user/information/username/{username}', playlist_id,
|
), default=[]), playlist_id, **info_dict)
|
||||||
fatal=False, note=f'Getting channel info ({username})', errnote=f'Failed to get channel info ({username})',
|
|
||||||
)
|
|
||||||
info_dict.update({
|
|
||||||
**traverse_obj(user_info, ('data', 'attributes', {
|
|
||||||
'channel_id': ('id', {str_or_none}),
|
|
||||||
'channel_follower_count': ('follower_cnt_num', {int_or_none}),
|
|
||||||
})),
|
|
||||||
'channel': username,
|
|
||||||
'channel_url': f'https://www.aparat.com/{username}',
|
|
||||||
})
|
|
||||||
|
|
||||||
return self.playlist_result(**info_dict)
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user