From 42c767c7a542166d55628162e6428d79eb9fd867 Mon Sep 17 00:00:00 2001 From: mimvahedi Date: Wed, 13 Dec 2023 00:24:16 +0330 Subject: [PATCH] [alaa] Add playlist extractor --- youtube_dl/extractor/alaa.py | 20 ++++++++++++++++++++ youtube_dl/extractor/extractors.py | 5 ++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/alaa.py b/youtube_dl/extractor/alaa.py index 27ad73d4e..ab49d08d7 100644 --- a/youtube_dl/extractor/alaa.py +++ b/youtube_dl/extractor/alaa.py @@ -50,3 +50,23 @@ class AlaaIE(InfoExtractor): 'thumbnail': url_or_none(video_image), 'duration': int_or_none(parse_duration(video_details.get('duration') + ":00")) } + + +class AlaaPlaylistIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?alaatv.com/set/(?P[0-9]+)' + + _TEST = { + 'url': 'https://alaatv.com/set/181', + 'info_dict': { + 'title': 'صفر تا صد فیزیک یازدهم - فرشید داداشی', + 'id': '181', + }, + 'playlist_count': 81, + } + + def _real_extract(self, url): + set_id = self._match_id(url) + set_data = self._download_json('https://alaatv.com/api/v2/set/{0}'.format(set_id), set_id) + set_title = set_data['data']['title'] + set_content = map(lambda x: x['url']['web'], set_data['data']['content']) + return self.playlist_result(set_content, set_id, set_title) diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 451e20161..c7686dc90 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -39,7 +39,10 @@ from .aenetworks import ( from .afreecatv import AfreecaTVIE from .airmozilla import AirMozillaIE from .aljazeera import AlJazeeraIE -from .alaa import AlaaIE +from .alaa import ( + AlaaIE, + AlaaPlaylistIE +) from .alphaporno import AlphaPornoIE from .amara import AmaraIE from .amcnetworks import AMCNetworksIE