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