]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/epicon.py
[cleanup] Add more ruff rules (#10149)
[yt-dlp.git] / yt_dlp / extractor / epicon.py
CommitLineData
7a45a159
A
1import re
2
3from .common import InfoExtractor
4from ..utils import ExtractorError
5
6
7class EpiconIE(InfoExtractor):
73f035e1 8 _VALID_URL = r'https?://(?:www\.)?epicon\.in/(?:documentaries|movies|tv-shows/[^/?#]+/[^/?#]+)/(?P<id>[^/?#]+)'
7a45a159
A
9 _TESTS = [{
10 'url': 'https://www.epicon.in/documentaries/air-battle-of-srinagar',
11 'info_dict': {
12 'id': 'air-battle-of-srinagar',
13 'ext': 'mp4',
14 'title': 'Air Battle of Srinagar',
15 'description': 'md5:c4de2013af9bc05ae4392e4115d518d7',
16 'thumbnail': r're:^https?://.*\.jpg$',
add96eb9 17 },
7a45a159
A
18 }, {
19 'url': 'https://www.epicon.in/movies/krit',
20 'info_dict': {
21 'id': 'krit',
22 'ext': 'mp4',
23 'title': 'Krit',
24 'description': 'md5:c12b35dad915d48ccff7f013c79bab4a',
25 'thumbnail': r're:^https?://.*\.jpg$',
add96eb9 26 },
7a45a159
A
27 }, {
28 'url': 'https://www.epicon.in/tv-shows/paapnaashini-ganga/season-1/vardaan',
29 'info_dict': {
30 'id': 'vardaan',
31 'ext': 'mp4',
32 'title': 'Paapnaashini Ganga - Season 1 - Ep 1 - VARDAAN',
33 'description': 'md5:f517058c3d0402398eefa6242f4dd6ae',
34 'thumbnail': r're:^https?://.*\.jpg$',
add96eb9 35 },
7a45a159
A
36 }, {
37 'url': 'https://www.epicon.in/movies/jayadev',
38 'info_dict': {
39 'id': 'jayadev',
40 'ext': 'mp4',
41 'title': 'Jayadev',
42 'description': 'md5:09e349eecd8e585a3b6466904f19df6c',
43 'thumbnail': r're:^https?://.*\.jpg$',
add96eb9 44 },
7a45a159
A
45 }]
46
47 def _real_extract(self, url):
add96eb9 48 video_id = self._match_id(url)
49 webpage = self._download_webpage(url, video_id)
7a45a159
A
50 cid = self._search_regex(r'class=\"mylist-icon\ iconclick\"\ id=\"(\d+)', webpage, 'cid')
51 headers = {'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'}
52 data = f'cid={cid}&action=st&type=video'.encode()
add96eb9 53 data_json = self._parse_json(
54 self._download_json('https://www.epicon.in/ajaxplayer/', video_id, headers=headers, data=data), video_id)
7a45a159
A
55
56 if not data_json['success']:
57 raise ExtractorError(data_json['message'], expected=True)
58
59 title = self._search_regex(r'setplaytitle=\"([^\"]+)', webpage, 'title')
60 description = self._og_search_description(webpage) or None
61 thumbnail = self._og_search_thumbnail(webpage) or None
add96eb9 62 formats = self._extract_m3u8_formats(data_json['url']['video_url'], video_id)
7a45a159
A
63
64 subtitles = {}
65 for subtitle in data_json.get('subtitles', []):
66 sub_url = subtitle.get('file')
67 if not sub_url:
68 continue
69 subtitles.setdefault(subtitle.get('lang', 'English'), []).append({
70 'url': self._proto_relative_url(sub_url),
71 })
72
73 return {
add96eb9 74 'id': video_id,
7a45a159
A
75 'formats': formats,
76 'title': title,
77 'description': description,
78 'thumbnail': thumbnail,
79 'subtitles': subtitles,
80 }
81
82
83class EpiconSeriesIE(InfoExtractor):
73f035e1 84 _VALID_URL = r'(?!.*season)https?://(?:www\.)?epicon\.in/tv-shows/(?P<id>[^/?#]+)'
7a45a159
A
85 _TESTS = [{
86 'url': 'https://www.epicon.in/tv-shows/1-of-something',
87 'playlist_mincount': 5,
88 'info_dict': {
89 'id': '1-of-something',
90 },
91 }, {
92 'url': 'https://www.epicon.in/tv-shows/eco-india-english',
93 'playlist_mincount': 76,
94 'info_dict': {
95 'id': 'eco-india-english',
96 },
97 }, {
98 'url': 'https://www.epicon.in/tv-shows/s/',
99 'playlist_mincount': 25,
100 'info_dict': {
101 'id': 's',
102 },
103 }, {
104 'url': 'https://www.epicon.in/tv-shows/ekaant',
105 'playlist_mincount': 38,
106 'info_dict': {
107 'id': 'ekaant',
108 },
109 }]
110
111 def _real_extract(self, url):
add96eb9 112 playlist_id = self._match_id(url)
113 webpage = self._download_webpage(url, playlist_id)
114 episodes = re.findall(rf'ct-tray-url=\"(tv-shows/{playlist_id}/[^\"]+)', webpage)
115 entries = [self.url_result(f'https://www.epicon.in/{episode}', EpiconIE) for episode in episodes]
116 return self.playlist_result(entries, playlist_id=playlist_id)