]>
Commit | Line | Data |
---|---|---|
7a45a159 A |
1 | import re |
2 | ||
3 | from .common import InfoExtractor | |
4 | from ..utils import ExtractorError | |
5 | ||
6 | ||
7 | class 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$', | |
17 | } | |
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$', | |
26 | } | |
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$', | |
35 | } | |
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$', | |
44 | } | |
45 | }] | |
46 | ||
47 | def _real_extract(self, url): | |
48 | id = self._match_id(url) | |
49 | webpage = self._download_webpage(url, id) | |
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() | |
53 | data_json = self._parse_json(self._download_json('https://www.epicon.in/ajaxplayer/', id, headers=headers, data=data), id) | |
54 | ||
55 | if not data_json['success']: | |
56 | raise ExtractorError(data_json['message'], expected=True) | |
57 | ||
58 | title = self._search_regex(r'setplaytitle=\"([^\"]+)', webpage, 'title') | |
59 | description = self._og_search_description(webpage) or None | |
60 | thumbnail = self._og_search_thumbnail(webpage) or None | |
61 | formats = self._extract_m3u8_formats(data_json['url']['video_url'], id) | |
7a45a159 A |
62 | |
63 | subtitles = {} | |
64 | for subtitle in data_json.get('subtitles', []): | |
65 | sub_url = subtitle.get('file') | |
66 | if not sub_url: | |
67 | continue | |
68 | subtitles.setdefault(subtitle.get('lang', 'English'), []).append({ | |
69 | 'url': self._proto_relative_url(sub_url), | |
70 | }) | |
71 | ||
72 | return { | |
73 | 'id': id, | |
74 | 'formats': formats, | |
75 | 'title': title, | |
76 | 'description': description, | |
77 | 'thumbnail': thumbnail, | |
78 | 'subtitles': subtitles, | |
79 | } | |
80 | ||
81 | ||
82 | class EpiconSeriesIE(InfoExtractor): | |
73f035e1 | 83 | _VALID_URL = r'(?!.*season)https?://(?:www\.)?epicon\.in/tv-shows/(?P<id>[^/?#]+)' |
7a45a159 A |
84 | _TESTS = [{ |
85 | 'url': 'https://www.epicon.in/tv-shows/1-of-something', | |
86 | 'playlist_mincount': 5, | |
87 | 'info_dict': { | |
88 | 'id': '1-of-something', | |
89 | }, | |
90 | }, { | |
91 | 'url': 'https://www.epicon.in/tv-shows/eco-india-english', | |
92 | 'playlist_mincount': 76, | |
93 | 'info_dict': { | |
94 | 'id': 'eco-india-english', | |
95 | }, | |
96 | }, { | |
97 | 'url': 'https://www.epicon.in/tv-shows/s/', | |
98 | 'playlist_mincount': 25, | |
99 | 'info_dict': { | |
100 | 'id': 's', | |
101 | }, | |
102 | }, { | |
103 | 'url': 'https://www.epicon.in/tv-shows/ekaant', | |
104 | 'playlist_mincount': 38, | |
105 | 'info_dict': { | |
106 | 'id': 'ekaant', | |
107 | }, | |
108 | }] | |
109 | ||
110 | def _real_extract(self, url): | |
111 | id = self._match_id(url) | |
112 | webpage = self._download_webpage(url, id) | |
113 | episodes = re.findall(r'ct-tray-url=\"(tv-shows/%s/[^\"]+)' % id, webpage) | |
114 | entries = [self.url_result('https://www.epicon.in/%s' % episode, ie=EpiconIE.ie_key()) for episode in episodes] | |
115 | return self.playlist_result(entries, playlist_id=id) |