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