]>
Commit | Line | Data |
---|---|---|
923e79e2 S |
1 | # encoding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | import re | |
5 | ||
6 | from .common import InfoExtractor | |
4b5fe134 SS |
7 | from ..utils import ( |
8 | clean_html, | |
9 | determine_ext, | |
10 | unified_strdate, | |
11 | ) | |
923e79e2 S |
12 | |
13 | ||
14 | class NovaIE(InfoExtractor): | |
15 | IE_DESC = 'TN.cz, Prásk.tv, Nova.cz, Novaplus.cz, FANDA.tv, Krásná.cz and Doma.cz' | |
08b7968e | 16 | _VALID_URL = 'http://(?:[^.]+\.)?(?P<site>tv(?:noviny)?|tn|novaplus|vymena|fanda|krasna|doma|prask)\.nova\.cz/(?:[^/]+/)+(?P<id>[^/]+?)(?:\.html|/|$)' |
923e79e2 | 17 | _TESTS = [{ |
08b7968e | 18 | 'url': 'http://tvnoviny.nova.cz/clanek/novinky/co-na-sebe-sportaci-praskli-vime-jestli-pujde-hrdlicka-na-materskou.html?utm_source=tvnoviny&utm_medium=cpfooter&utm_campaign=novaplus', |
923e79e2 S |
19 | 'info_dict': { |
20 | 'id': '1608920', | |
21 | 'display_id': 'co-na-sebe-sportaci-praskli-vime-jestli-pujde-hrdlicka-na-materskou', | |
22 | 'ext': 'flv', | |
23 | 'title': 'Duel: Michal Hrdlička a Petr Suchoň', | |
24 | 'description': 'md5:d0cc509858eee1b1374111c588c6f5d5', | |
25 | 'thumbnail': 're:^https?://.*\.(?:jpg)', | |
26 | }, | |
27 | 'params': { | |
28 | # rtmp download | |
29 | 'skip_download': True, | |
30 | } | |
31 | }, { | |
08b7968e | 32 | 'url': 'http://tn.nova.cz/clanek/tajemstvi-ukryte-v-podzemi-specialni-nemocnice-v-prazske-krci.html#player_13260', |
923e79e2 S |
33 | 'md5': '1dd7b9d5ea27bc361f110cd855a19bd3', |
34 | 'info_dict': { | |
35 | 'id': '1757139', | |
36 | 'display_id': 'tajemstvi-ukryte-v-podzemi-specialni-nemocnice-v-prazske-krci', | |
37 | 'ext': 'mp4', | |
38 | 'title': 'Podzemní nemocnice v pražské Krči', | |
39 | 'description': 'md5:f0a42dd239c26f61c28f19e62d20ef53', | |
40 | 'thumbnail': 're:^https?://.*\.(?:jpg)', | |
41 | } | |
42 | }, { | |
08b7968e | 43 | 'url': 'http://novaplus.nova.cz/porad/policie-modrava/video/5591-policie-modrava-15-dil-blondynka-na-hrbitove', |
923e79e2 S |
44 | 'info_dict': { |
45 | 'id': '1756825', | |
46 | 'display_id': '5591-policie-modrava-15-dil-blondynka-na-hrbitove', | |
9464a194 | 47 | 'ext': 'mp4', |
923e79e2 | 48 | 'title': 'Policie Modrava - 15. díl - Blondýnka na hřbitově', |
fa971259 | 49 | 'description': 'md5:dc24e50be5908df83348e50d1431295e', # Make sure this description is clean of html tags |
923e79e2 S |
50 | 'thumbnail': 're:^https?://.*\.(?:jpg)', |
51 | }, | |
52 | 'params': { | |
53 | # rtmp download | |
54 | 'skip_download': True, | |
55 | } | |
fcb04bca SS |
56 | }, { |
57 | 'url': 'http://novaplus.nova.cz/porad/televizni-noviny/video/5585-televizni-noviny-30-5-2015/', | |
58 | 'info_dict': { | |
59 | 'id': '1756858', | |
60 | 'ext': 'mp4', | |
61 | 'title': 'Televizní noviny - 30. 5. 2015', | |
62 | 'thumbnail': 're:^https?://.*\.(?:jpg)', | |
63 | 'upload_date': '20150530', | |
64 | }, | |
65 | 'params': { | |
66 | # rtmp download | |
67 | 'skip_download': True, | |
68 | } | |
69 | }, { | |
70 | 'url': 'http://fanda.nova.cz/clanek/fun-and-games/krvavy-epos-zaklinac-3-divoky-hon-vychazi-vyhrajte-ho-pro-sebe.html', | |
71 | 'info_dict': { | |
72 | 'id': '1753621', | |
73 | 'ext': 'mp4', | |
74 | 'title': 'Zaklínač 3: Divoký hon', | |
75 | 'description': 're:.*Pokud se stejně jako my nemůžete.*', | |
76 | 'thumbnail': 're:https?://.*\.jpg(\?.*)?', | |
77 | 'upload_date': '20150521', | |
78 | }, | |
79 | 'params': { | |
80 | # rtmp download | |
81 | 'skip_download': True, | |
82 | } | |
923e79e2 S |
83 | }, { |
84 | 'url': 'http://sport.tn.nova.cz/clanek/sport/hokej/nhl/zivot-jde-dal-hodnotil-po-vyrazeni-z-playoff-jiri-sekac.html', | |
85 | 'only_matching': True, | |
86 | }, { | |
87 | 'url': 'http://fanda.nova.cz/clanek/fun-and-games/krvavy-epos-zaklinac-3-divoky-hon-vychazi-vyhrajte-ho-pro-sebe.html', | |
88 | 'only_matching': True, | |
89 | }, { | |
90 | 'url': 'http://doma.nova.cz/clanek/zdravi/prijdte-se-zapsat-do-registru-kostni-drene-jiz-ve-stredu-3-cervna.html', | |
91 | 'only_matching': True, | |
92 | }, { | |
93 | 'url': 'http://prask.nova.cz/clanek/novinky/co-si-na-sobe-nase-hvezdy-nechaly-pojistit.html', | |
94 | 'only_matching': True, | |
60158217 S |
95 | }, { |
96 | 'url': 'http://tv.nova.cz/clanek/novinky/zivot-je-zivot-bondovsky-trailer.html', | |
97 | 'only_matching': True, | |
923e79e2 S |
98 | }] |
99 | ||
100 | def _real_extract(self, url): | |
101 | mobj = re.match(self._VALID_URL, url) | |
102 | display_id = mobj.group('id') | |
103 | site = mobj.group('site') | |
104 | ||
105 | webpage = self._download_webpage(url, display_id) | |
106 | ||
107 | video_id = self._search_regex( | |
108 | [r"(?:media|video_id)\s*:\s*'(\d+)'", | |
109 | r'media=(\d+)', | |
110 | r'id="article_video_(\d+)"', | |
111 | r'id="player_(\d+)"'], | |
112 | webpage, 'video id') | |
113 | ||
114 | config_url = self._search_regex( | |
115 | r'src="(http://tn\.nova\.cz/bin/player/videojs/config\.php\?[^"]+)"', | |
116 | webpage, 'config url', default=None) | |
117 | ||
118 | if not config_url: | |
119 | DEFAULT_SITE_ID = '23000' | |
120 | SITES = { | |
121 | 'tvnoviny': DEFAULT_SITE_ID, | |
122 | 'novaplus': DEFAULT_SITE_ID, | |
123 | 'vymena': DEFAULT_SITE_ID, | |
124 | 'krasna': DEFAULT_SITE_ID, | |
125 | 'fanda': '30', | |
126 | 'tn': '30', | |
127 | 'doma': '30', | |
128 | } | |
129 | ||
130 | site_id = self._search_regex( | |
131 | r'site=(\d+)', webpage, 'site id', default=None) or SITES.get(site, DEFAULT_SITE_ID) | |
132 | ||
133 | config_url = ('http://tn.nova.cz/bin/player/videojs/config.php?site=%s&media=%s&jsVar=vjsconfig' | |
134 | % (site_id, video_id)) | |
135 | ||
136 | config = self._download_json( | |
137 | config_url, display_id, | |
138 | 'Downloading config JSON', | |
a00234f1 | 139 | transform_source=lambda s: s[s.index('{'):s.rindex('}') + 1]) |
923e79e2 S |
140 | |
141 | mediafile = config['mediafile'] | |
142 | video_url = mediafile['src'] | |
9464a194 | 143 | ext = determine_ext(video_url) |
b0cda32f | 144 | video_url = video_url.replace('&%s:' % ext, '') |
923e79e2 S |
145 | |
146 | title = mediafile.get('meta', {}).get('title') or self._og_search_title(webpage) | |
34c0f95d | 147 | description = clean_html(self._og_search_description(webpage, default=None)) |
923e79e2 S |
148 | thumbnail = config.get('poster') |
149 | ||
fcb04bca | 150 | if site == 'novaplus': |
4b5fe134 SS |
151 | upload_date = unified_strdate(self._search_regex( |
152 | r'(\d{1,2}-\d{1,2}-\d{4})$', display_id, 'upload date', default=None)) | |
153 | elif site == 'fanda': | |
154 | upload_date = unified_strdate(self._search_regex( | |
155 | r'<span class="date_time">(\d{1,2}\.\d{1,2}\.\d{4})', webpage, 'upload date', default=None)) | |
fcb04bca SS |
156 | else: |
157 | upload_date = None | |
158 | ||
923e79e2 S |
159 | return { |
160 | 'id': video_id, | |
161 | 'display_id': display_id, | |
162 | 'title': title, | |
163 | 'description': description, | |
fcb04bca | 164 | 'upload_date': upload_date, |
923e79e2 | 165 | 'thumbnail': thumbnail, |
9464a194 SS |
166 | 'url': video_url, |
167 | 'ext': ext, | |
923e79e2 | 168 | } |