]>
Commit | Line | Data |
---|---|---|
856150d0 YCH |
1 | from .common import InfoExtractor |
2 | ||
3 | ||
4 | class TelewebionIE(InfoExtractor): | |
92519402 | 5 | _VALID_URL = r'https?://(?:www\.)?telewebion\.com/#!/episode/(?P<id>\d+)' |
856150d0 YCH |
6 | |
7 | _TEST = { | |
8 | 'url': 'http://www.telewebion.com/#!/episode/1263668/', | |
9 | 'info_dict': { | |
10 | 'id': '1263668', | |
11 | 'ext': 'mp4', | |
12 | 'title': 'قرعه\u200cکشی لیگ قهرمانان اروپا', | |
ec85ded8 | 13 | 'thumbnail': r're:^https?://.*\.jpg', |
856150d0 YCH |
14 | 'view_count': int, |
15 | }, | |
16 | 'params': { | |
17 | # m3u8 download | |
18 | 'skip_download': True, | |
19 | }, | |
20 | } | |
21 | ||
22 | def _real_extract(self, url): | |
23 | video_id = self._match_id(url) | |
24 | ||
25 | secure_token = self._download_webpage( | |
26 | 'http://m.s2.telewebion.com/op/op?action=getSecurityToken', video_id) | |
27 | episode_details = self._download_json( | |
28 | 'http://m.s2.telewebion.com/op/op', video_id, | |
29 | query={'action': 'getEpisodeDetails', 'episode_id': video_id}) | |
30 | ||
31 | m3u8_url = 'http://m.s1.telewebion.com/smil/%s.m3u8?filepath=%s&m3u8=1&secure_token=%s' % ( | |
32 | video_id, episode_details['file_path'], secure_token) | |
33 | formats = self._extract_m3u8_formats( | |
34 | m3u8_url, video_id, ext='mp4', m3u8_id='hls') | |
35 | ||
36 | picture_paths = [ | |
37 | episode_details.get('picture_path'), | |
38 | episode_details.get('large_picture_path'), | |
39 | ] | |
40 | ||
41 | thumbnails = [{ | |
42 | 'url': picture_path, | |
43 | 'preference': idx, | |
44 | } for idx, picture_path in enumerate(picture_paths) if picture_path is not None] | |
45 | ||
46 | return { | |
47 | 'id': video_id, | |
48 | 'title': episode_details['title'], | |
49 | 'formats': formats, | |
50 | 'thumbnails': thumbnails, | |
51 | 'view_count': episode_details.get('view_count'), | |
52 | } |