[played] Capture and output error message
authorSergey M․ <dstftw@gmail.com>
Tue, 4 Nov 2014 10:34:53 +0000 (17:34 +0700)
committerSergey M․ <dstftw@gmail.com>
Tue, 4 Nov 2014 10:34:53 +0000 (17:34 +0700)
youtube_dl/extractor/played.py

index 645a1e06dc8f3678b30d4e41b38ea13396c7a3e0..17880471d9d160f6d3315ca9c6eadeada8ce91a7 100644 (file)
@@ -6,6 +6,7 @@ import os.path
 
 from .common import InfoExtractor
 from ..utils import (
+    ExtractorError,
     compat_urllib_parse,
     compat_urllib_request,
 )
@@ -29,6 +30,12 @@ class PlayedIE(InfoExtractor):
         video_id = self._match_id(url)
 
         orig_webpage = self._download_webpage(url, video_id)
+
+        m_error = re.search(
+            r'(?s)Reason for deletion:.*?<b class="err"[^>]*>(?P<msg>[^<]+)</b>', orig_webpage)
+        if m_error:
+            raise ExtractorError(m_error.group('msg'), expected=True)
+
         fields = re.findall(
             r'type="hidden" name="([^"]+)"\s+value="([^"]+)">', orig_webpage)
         data = dict(fields)