]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/nova.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..utils
import determine_ext
10 class NovaIE(InfoExtractor
):
11 IE_DESC
= 'TN.cz, Prásk.tv, Nova.cz, Novaplus.cz, FANDA.tv, Krásná.cz and Doma.cz'
12 _VALID_URL
= 'http://(?:[^.]+\.)?(?P<site>tv(?:noviny)?|tn|novaplus|vymena|fanda|krasna|doma|prask)\.nova\.cz/(?:[^/]+/)+(?P<id>[^/]+?)(?:\.html|/?)$'
14 'url': 'http://tvnoviny.nova.cz/clanek/novinky/co-na-sebe-sportaci-praskli-vime-jestli-pujde-hrdlicka-na-materskou.html',
17 'display_id': 'co-na-sebe-sportaci-praskli-vime-jestli-pujde-hrdlicka-na-materskou',
19 'title': 'Duel: Michal Hrdlička a Petr Suchoň',
20 'description': 'md5:d0cc509858eee1b1374111c588c6f5d5',
21 'thumbnail': 're:^https?://.*\.(?:jpg)',
25 'skip_download': True,
28 'url': 'http://tn.nova.cz/clanek/tajemstvi-ukryte-v-podzemi-specialni-nemocnice-v-prazske-krci.html',
29 'md5': '1dd7b9d5ea27bc361f110cd855a19bd3',
32 'display_id': 'tajemstvi-ukryte-v-podzemi-specialni-nemocnice-v-prazske-krci',
34 'title': 'Podzemní nemocnice v pražské Krči',
35 'description': 'md5:f0a42dd239c26f61c28f19e62d20ef53',
36 'thumbnail': 're:^https?://.*\.(?:jpg)',
39 'url': 'http://novaplus.nova.cz/porad/policie-modrava/video/5591-policie-modrava-15-dil-blondynka-na-hrbitove/',
42 'display_id': '5591-policie-modrava-15-dil-blondynka-na-hrbitove',
44 'title': 'Policie Modrava - 15. díl - Blondýnka na hřbitově',
45 'description': 'md5:d804ba6b30bc7da2705b1fea961bddfe',
46 'thumbnail': 're:^https?://.*\.(?:jpg)',
50 'skip_download': True,
53 'url': 'http://novaplus.nova.cz/porad/televizni-noviny/video/5585-televizni-noviny-30-5-2015/',
57 'title': 'Televizní noviny - 30. 5. 2015',
58 'thumbnail': 're:^https?://.*\.(?:jpg)',
59 'upload_date': '20150530',
63 'skip_download': True,
66 'url': 'http://fanda.nova.cz/clanek/fun-and-games/krvavy-epos-zaklinac-3-divoky-hon-vychazi-vyhrajte-ho-pro-sebe.html',
70 'title': 'Zaklínač 3: Divoký hon',
71 'description': 're:.*Pokud se stejně jako my nemůžete.*',
72 'thumbnail': 're:https?://.*\.jpg(\?.*)?',
73 'upload_date': '20150521',
77 'skip_download': True,
80 'url': 'http://sport.tn.nova.cz/clanek/sport/hokej/nhl/zivot-jde-dal-hodnotil-po-vyrazeni-z-playoff-jiri-sekac.html',
81 'only_matching': True,
83 'url': 'http://fanda.nova.cz/clanek/fun-and-games/krvavy-epos-zaklinac-3-divoky-hon-vychazi-vyhrajte-ho-pro-sebe.html',
84 'only_matching': True,
86 'url': 'http://doma.nova.cz/clanek/zdravi/prijdte-se-zapsat-do-registru-kostni-drene-jiz-ve-stredu-3-cervna.html',
87 'only_matching': True,
89 'url': 'http://prask.nova.cz/clanek/novinky/co-si-na-sobe-nase-hvezdy-nechaly-pojistit.html',
90 'only_matching': True,
92 'url': 'http://tv.nova.cz/clanek/novinky/zivot-je-zivot-bondovsky-trailer.html',
93 'only_matching': True,
96 def _real_extract(self
, url
):
97 mobj
= re
.match(self
._VALID
_URL
, url
)
98 display_id
= mobj
.group('id')
99 site
= mobj
.group('site')
101 webpage
= self
._download
_webpage
(url
, display_id
)
103 video_id
= self
._search
_regex
(
104 [r
"(?:media|video_id)\s*:\s*'(\d+)'",
106 r
'id="article_video_(\d+)"',
107 r
'id="player_(\d+)"'],
110 config_url
= self
._search
_regex
(
111 r
'src="(http://tn\.nova\.cz/bin/player/videojs/config\.php\?[^"]+)"',
112 webpage
, 'config url', default
=None)
115 DEFAULT_SITE_ID
= '23000'
117 'tvnoviny': DEFAULT_SITE_ID
,
118 'novaplus': DEFAULT_SITE_ID
,
119 'vymena': DEFAULT_SITE_ID
,
120 'krasna': DEFAULT_SITE_ID
,
126 site_id
= self
._search
_regex
(
127 r
'site=(\d+)', webpage
, 'site id', default
=None) or SITES
.get(site
, DEFAULT_SITE_ID
)
129 config_url
= ('http://tn.nova.cz/bin/player/videojs/config.php?site=%s&media=%s&jsVar=vjsconfig'
130 % (site_id
, video_id
))
132 config
= self
._download
_json
(
133 config_url
, display_id
,
134 'Downloading config JSON',
135 transform_source
=lambda s
: re
.sub(r
'var\s+[\da-zA-Z_]+\s*=\s*({.+?});', r
'\1', s
))
137 mediafile
= config
['mediafile']
138 video_url
= mediafile
['src']
139 ext
= determine_ext(video_url
)
140 video_url
= video_url
.replace('&{}:'.format(ext
), '')
142 title
= mediafile
.get('meta', {}).get('title') or self
._og
_search
_title
(webpage
)
143 description
= self
._og
_search
_description
(webpage
)
144 thumbnail
= config
.get('poster')
147 if site
== 'novaplus':
148 mobj
= re
.search(r
'(?P<day>\d{1,2})-(?P<month>\d{1,2})-(?P<year>\d{4})$', display_id
)
151 r
'<span class="date_time">(?P<day>\d{1,2})\.(?P<month>\d{1,2})\.(?P<year>\d{4})\b', webpage
)
153 upload_date
= '{}{:02d}{:02d}'.format(mobj
.group('year'), int(mobj
.group('month')), int(mobj
.group('day')))
159 'display_id': display_id
,
161 'description': description
,
162 'upload_date': upload_date
,
163 'thumbnail': thumbnail
,