Merge branch '_ceskatelevize' of https://github.com/pulpe/youtube-dl into pulpe-_cesk...
[youtube-dl] / youtube_dl / extractor / ceskatelevize.py
index 8a36bd9808e9b9582695d7a4a057124dc9864be4..59f2a8e451953b45d84957369a2d8b0a2d029ae4 100644 (file)
@@ -3,13 +3,13 @@ from __future__ import unicode_literals
 
 import re
 import json
-from urllib import unquote
 
 from .common import InfoExtractor
 from ..utils import (
     compat_urllib_request,
     compat_urllib_parse,
-    compat_urllib_parse_urlparse
+    compat_urllib_parse_urlparse,
+    ExtractorError,
 )
 
 
@@ -50,6 +50,10 @@ class CeskaTelevizeIE(InfoExtractor):
 
         webpage = self._download_webpage(url, video_id)
 
+        if '<p class="title">Chyba konfigurace prohlížeče.</p>' not in webpage:
+            msg = self._html_search_regex(r'<p class="title">(.+?)</p>', webpage, 'error-message')
+            raise ExtractorError(msg.replace('<br />', ' '))
+
         typ = self._html_search_regex(r'getPlaylistUrl\(\[\{"type":"(.+?)","id":".+?"\}\],', webpage, 'type')
         episode_id = self._html_search_regex(r'getPlaylistUrl\(\[\{"type":".+?","id":"(.+?)"\}\],', webpage, 'episode_id')
 
@@ -70,7 +74,7 @@ class CeskaTelevizeIE(InfoExtractor):
 
         playlistpage = self._download_webpage(req, video_id)
 
-        req = compat_urllib_request.Request(unquote(json.loads(playlistpage)['url']))
+        req = compat_urllib_request.Request(compat_urllib_parse.unquote(json.loads(playlistpage)['url']))
         req.add_header('Referer', url)
 
         playlist = self._download_xml(req, video_id)