]>
Commit | Line | Data |
---|---|---|
bfe96d7b | 1 | from .common import InfoExtractor |
dfbc7f7f | 2 | from ..utils import remove_start |
bfe96d7b PH |
3 | |
4 | ||
5 | class PressTVIE(InfoExtractor): | |
dfbc7f7f | 6 | _VALID_URL = r'https?://(?:www\.)?presstv\.ir/[^/]+/(?P<y>\d+)/(?P<m>\d+)/(?P<d>\d+)/(?P<id>\d+)/(?P<display_id>[^/]+)?' |
bfe96d7b PH |
7 | |
8 | _TEST = { | |
95153a96 PH |
9 | 'url': 'http://www.presstv.ir/Detail/2016/04/09/459911/Australian-sewerage-treatment-facility-/', |
10 | 'md5': '5d7e3195a447cb13e9267e931d8dd5a5', | |
bfe96d7b | 11 | 'info_dict': { |
95153a96 | 12 | 'id': '459911', |
dfbc7f7f | 13 | 'display_id': 'Australian-sewerage-treatment-facility-', |
bfe96d7b | 14 | 'ext': 'mp4', |
95153a96 PH |
15 | 'title': 'Organic mattresses used to clean waste water', |
16 | 'upload_date': '20160409', | |
ec85ded8 | 17 | 'thumbnail': r're:^https?://.*\.jpg', |
de728757 | 18 | 'description': 'md5:20002e654bbafb6908395a5c0cfcd125' |
bfe96d7b PH |
19 | } |
20 | } | |
21 | ||
22 | def _real_extract(self, url): | |
5ad28e7f | 23 | mobj = self._match_valid_url(url) |
dfbc7f7f YCH |
24 | video_id = mobj.group('id') |
25 | display_id = mobj.group('display_id') or video_id | |
26 | ||
27 | webpage = self._download_webpage(url, display_id) | |
bfe96d7b PH |
28 | |
29 | # extract video URL from webpage | |
dfbc7f7f | 30 | video_url = self._hidden_inputs(webpage)['inpPlayback'] |
bfe96d7b PH |
31 | |
32 | # build list of available formats | |
33 | # specified in http://www.presstv.ir/Scripts/playback.js | |
34 | base_url = 'http://192.99.219.222:82/presstv' | |
de728757 | 35 | _formats = [ |
dfbc7f7f YCH |
36 | (180, '_low200.mp4'), |
37 | (360, '_low400.mp4'), | |
38 | (720, '_low800.mp4'), | |
39 | (1080, '.mp4') | |
bfe96d7b | 40 | ] |
de728757 | 41 | |
dfbc7f7f YCH |
42 | formats = [{ |
43 | 'url': base_url + video_url[:-4] + extension, | |
44 | 'format_id': '%dp' % height, | |
45 | 'height': height, | |
46 | } for height, extension in _formats] | |
bfe96d7b PH |
47 | |
48 | # extract video metadata | |
dfbc7f7f YCH |
49 | title = remove_start( |
50 | self._html_search_meta('title', webpage, fatal=True), 'PressTV-') | |
bfe96d7b | 51 | |
de728757 PH |
52 | thumbnail = self._og_search_thumbnail(webpage) |
53 | description = self._og_search_description(webpage) | |
bfe96d7b | 54 | |
de728757 | 55 | upload_date = '%04d%02d%02d' % ( |
dfbc7f7f YCH |
56 | int(mobj.group('y')), |
57 | int(mobj.group('m')), | |
58 | int(mobj.group('d')), | |
de728757 | 59 | ) |
bfe96d7b PH |
60 | |
61 | return { | |
62 | 'id': video_id, | |
dfbc7f7f | 63 | 'display_id': display_id, |
bfe96d7b PH |
64 | 'title': title, |
65 | 'formats': formats, | |
66 | 'thumbnail': thumbnail, | |
67 | 'upload_date': upload_date, | |
68 | 'description': description | |
69 | } |