Compare commits

...

9 Commits

Author SHA1 Message Date
Mozi
a9ed3fea3f
Merge d810fff277 into f919729538 2024-11-22 17:12:11 +00:00
Mozi
d810fff277 fix code style; fix channel follower count; fix test 2024-11-22 17:11:56 +00:00
Mozi
ad4b1615cc merge 'master' 2024-11-22 17:09:39 +00:00
Mozi
dc2c2f1267 imports 2024-11-16 07:46:11 +00:00
Mozi
1f13bd5eb1 merge to the correct 'master' !!! 2024-11-16 07:24:48 +00:00
Mozi
1db3eaa77e simplify function call in traversal 2024-11-16 07:20:51 +00:00
Mozi
5d01746c4c merge 'master' 2024-11-16 07:16:22 +00:00
Mozi
322acaef8a fix code style in _extractors.py
Co-authored-by: N/Ame <173015200+grqz@users.noreply.github.com>
2024-08-26 14:25:25 +00:00
Mozi
905672d378 [ie/aparat:playlist] Add extractor 2024-08-25 17:40:28 +00:00
2 changed files with 85 additions and 8 deletions

View File

@ -135,7 +135,10 @@
from .anvato import AnvatoIE from .anvato import AnvatoIE
from .aol import AolIE from .aol import AolIE
from .apa import APAIE from .apa import APAIE
from .aparat import AparatIE from .aparat import (
AparatIE,
AparatPlaylistIE,
)
from .appleconnect import AppleConnectIE from .appleconnect import AppleConnectIE
from .applepodcasts import ApplePodcastsIE from .applepodcasts import ApplePodcastsIE
from .appletrailers import ( from .appletrailers import (

View File

@ -1,11 +1,6 @@
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ( from ..utils import get_element_by_id, int_or_none, merge_dicts, mimetype2ext, str_or_none, url_or_none
get_element_by_id, from ..utils.traversal import traverse_obj
int_or_none,
merge_dicts,
mimetype2ext,
url_or_none,
)
class AparatIE(InfoExtractor): class AparatIE(InfoExtractor):
@ -24,6 +19,8 @@ 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
@ -86,3 +83,80 @@ def _real_extract(self, url):
'duration': int_or_none(options.get('duration')), 'duration': int_or_none(options.get('duration')),
'formats': formats, 'formats': formats,
}) })
class AparatPlaylistIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?aparat\.com/playlist/(?P<id>\d+)'
_TESTS = [{
'url': 'https://www.aparat.com/playlist/1001307',
'info_dict': {
'id': '1001307',
'title': 'مبانی یادگیری عمیق',
'description': '',
'thumbnails': 'count:2',
'channel': 'mrmohammadi_iust',
'channel_id': '6463423',
'channel_url': 'https://www.aparat.com/mrmohammadi_iust',
'channel_follower_count': int,
},
'playlist_mincount': 1,
'params': {
'skip_download': True,
},
}, {
'url': 'https://www.aparat.com/playlist/1234567',
'info_dict': {
'id': '1234567',
'title': 'ساخت اکانت',
'description': '',
'thumbnails': 'count:0',
'channel': 'reza.shadow',
'channel_id': '8159952',
'channel_url': 'https://www.aparat.com/reza.shadow',
'channel_follower_count': int,
},
'playlist_count': 0,
'params': {
'skip_download': True,
},
}, {
'url': 'https://www.aparat.com/playlist/1256882',
'only_matching': True,
}]
def _real_extract(self, url):
playlist_id = self._match_id(url)
info = self._download_json(
f'https://www.aparat.com/api/fa/v1/video/playlist/one/playlist_id/{playlist_id}',
playlist_id, note='Getting playlist info', errnote='Failed to get playlist info')
info_dict = {
**traverse_obj(info, ('data', 'attributes', {
'title': 'title',
'description': 'description',
'thumbnails': (('big_poster', 'small_poster'), all, ..., {url_or_none}, {lambda x: {'url': x}}),
}), default={}),
'id': playlist_id,
'entries': traverse_obj(info, (
'included', lambda _, v: v['type'] == 'Video', 'attributes', 'uid',
{lambda x: self.url_result(f'https://www.aparat.com/v/{x}?playlist={playlist_id}')},
), default=[]),
}
if username := traverse_obj(
info, ('included', lambda _, v: v['type'] == 'channel', 'attributes', 'username'), get_all=False):
user_info = self._download_json(
f'https://www.aparat.com/api/fa/v1/user/user/information/username/{username}', playlist_id,
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)