2 from __future__ import unicode_literals
6 from .common import InfoExtractor
13 class NovaIE(InfoExtractor):
14 IE_DESC = 'TN.cz, Prásk.tv, Nova.cz, Novaplus.cz, FANDA.tv, Krásná.cz and Doma.cz'
15 _VALID_URL = r'https?://(?:[^.]+\.)?(?P<site>tv(?:noviny)?|tn|novaplus|vymena|fanda|krasna|doma|prask)\.nova\.cz/(?:[^/]+/)+(?P<id>[^/]+?)(?:\.html|/|$)'
17 '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',
20 'display_id': 'co-na-sebe-sportaci-praskli-vime-jestli-pujde-hrdlicka-na-materskou',
22 'title': 'Duel: Michal Hrdlička a Petr Suchoň',
23 'description': 'md5:d0cc509858eee1b1374111c588c6f5d5',
24 'thumbnail': r're:^https?://.*\.(?:jpg)',
28 'skip_download': True,
31 'url': 'http://tn.nova.cz/clanek/tajemstvi-ukryte-v-podzemi-specialni-nemocnice-v-prazske-krci.html#player_13260',
32 'md5': '1dd7b9d5ea27bc361f110cd855a19bd3',
35 'display_id': 'tajemstvi-ukryte-v-podzemi-specialni-nemocnice-v-prazske-krci',
37 'title': 'Podzemní nemocnice v pražské Krči',
38 'description': 'md5:f0a42dd239c26f61c28f19e62d20ef53',
39 'thumbnail': r're:^https?://.*\.(?:jpg)',
42 'url': 'http://novaplus.nova.cz/porad/policie-modrava/video/5591-policie-modrava-15-dil-blondynka-na-hrbitove',
45 'display_id': '5591-policie-modrava-15-dil-blondynka-na-hrbitove',
47 'title': 'Policie Modrava - 15. díl - Blondýnka na hřbitově',
48 'description': 'md5:dc24e50be5908df83348e50d1431295e', # Make sure this description is clean of html tags
49 'thumbnail': r're:^https?://.*\.(?:jpg)',
53 'skip_download': True,
56 'url': 'http://novaplus.nova.cz/porad/televizni-noviny/video/5585-televizni-noviny-30-5-2015/',
60 'title': 'Televizní noviny - 30. 5. 2015',
61 'thumbnail': r're:^https?://.*\.(?:jpg)',
62 'upload_date': '20150530',
66 'skip_download': True,
69 'url': 'http://fanda.nova.cz/clanek/fun-and-games/krvavy-epos-zaklinac-3-divoky-hon-vychazi-vyhrajte-ho-pro-sebe.html',
73 'title': 'Zaklínač 3: Divoký hon',
74 'description': 're:.*Pokud se stejně jako my nemůžete.*',
75 'thumbnail': r're:https?://.*\.jpg(\?.*)?',
76 'upload_date': '20150521',
80 'skip_download': True,
83 'url': 'http://sport.tn.nova.cz/clanek/sport/hokej/nhl/zivot-jde-dal-hodnotil-po-vyrazeni-z-playoff-jiri-sekac.html',
84 'only_matching': True,
86 'url': 'http://fanda.nova.cz/clanek/fun-and-games/krvavy-epos-zaklinac-3-divoky-hon-vychazi-vyhrajte-ho-pro-sebe.html',
87 'only_matching': True,
89 'url': 'http://doma.nova.cz/clanek/zdravi/prijdte-se-zapsat-do-registru-kostni-drene-jiz-ve-stredu-3-cervna.html',
90 'only_matching': True,
92 'url': 'http://prask.nova.cz/clanek/novinky/co-si-na-sobe-nase-hvezdy-nechaly-pojistit.html',
93 'only_matching': True,
95 'url': 'http://tv.nova.cz/clanek/novinky/zivot-je-zivot-bondovsky-trailer.html',
96 'only_matching': True,
99 def _real_extract(self, url):
100 mobj = re.match(self._VALID_URL, url)
101 display_id = mobj.group('id')
102 site = mobj.group('site')
104 webpage = self._download_webpage(url, display_id)
106 video_id = self._search_regex(
107 [r"(?:media|video_id)\s*:\s*'(\d+)'",
109 r'id="article_video_(\d+)"',
110 r'id="player_(\d+)"'],
113 config_url = self._search_regex(
114 r'src="(http://tn\.nova\.cz/bin/player/videojs/config\.php\?[^"]+)"',
115 webpage, 'config url', default=None)
118 DEFAULT_SITE_ID = '23000'
120 'tvnoviny': DEFAULT_SITE_ID,
121 'novaplus': DEFAULT_SITE_ID,
122 'vymena': DEFAULT_SITE_ID,
123 'krasna': DEFAULT_SITE_ID,
129 site_id = self._search_regex(
130 r'site=(\d+)', webpage, 'site id', default=None) or SITES.get(site, DEFAULT_SITE_ID)
132 config_url = ('http://tn.nova.cz/bin/player/videojs/config.php?site=%s&media=%s&jsVar=vjsconfig'
133 % (site_id, video_id))
135 config = self._download_json(
136 config_url, display_id,
137 'Downloading config JSON',
138 transform_source=lambda s: s[s.index('{'):s.rindex('}') + 1])
140 mediafile = config['mediafile']
141 video_url = mediafile['src']
143 m = re.search(r'^(?P<url>rtmpe?://[^/]+/(?P<app>[^/]+?))/&*(?P<playpath>.+)$', video_url)
146 'url': m.group('url'),
147 'app': m.group('app'),
148 'play_path': m.group('playpath'),
149 'player_path': 'http://tvnoviny.nova.cz/static/shared/app/videojs/video-js.swf',
156 self._sort_formats(formats)
158 title = mediafile.get('meta', {}).get('title') or self._og_search_title(webpage)
159 description = clean_html(self._og_search_description(webpage, default=None))
160 thumbnail = config.get('poster')
162 if site == 'novaplus':
163 upload_date = unified_strdate(self._search_regex(
164 r'(\d{1,2}-\d{1,2}-\d{4})$', display_id, 'upload date', default=None))
165 elif site == 'fanda':
166 upload_date = unified_strdate(self._search_regex(
167 r'<span class="date_time">(\d{1,2}\.\d{1,2}\.\d{4})', webpage, 'upload date', default=None))
173 'display_id': display_id,
175 'description': description,
176 'upload_date': upload_date,
177 'thumbnail': thumbnail,