summary refs log tree commit diff
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2013-12-16 03:34:46 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2013-12-16 03:34:46 +0100
commitf8b56e95b82d9cb783c5a789b6b2770efff57b73 (patch)
treecd9b8e3100f6d37f45ddad4fad4c60ccfe00b5c9
parent5fe18bdbde749267c35bb360a3a0699e555a3fcf (diff)
downloadyoutube-dl-f8b56e95b82d9cb783c5a789b6b2770efff57b73.tar.gz
youtube-dl-f8b56e95b82d9cb783c5a789b6b2770efff57b73.tar.xz
youtube-dl-f8b56e95b82d9cb783c5a789b6b2770efff57b73.zip
[theplatform] Detect geoblocked content
-rw-r--r--youtube_dl/extractor/theplatform.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/youtube_dl/extractor/theplatform.py b/youtube_dl/extractor/theplatform.py
index 61452e47d..650d7517f 100644
--- a/youtube_dl/extractor/theplatform.py
+++ b/youtube_dl/extractor/theplatform.py
@@ -3,6 +3,7 @@ import json
 
 from .common import InfoExtractor
 from ..utils import (
+    ExtractorError,
     xpath_with_ns,
 )
 
@@ -32,6 +33,17 @@ class ThePlatformIE(InfoExtractor):
         smil_url = ('http://link.theplatform.com/s/dJ5BDC/{0}/meta.smil?'
             'format=smil&mbr=true'.format(video_id))
         meta = self._download_xml(smil_url, video_id)
+
+        try:
+            error_msg = next(
+                n.attrib['abstract']
+                for n in meta.findall(_x('.//smil:ref'))
+                if n.attrib['title'] == u'Geographic Restriction')
+        except StopIteration:
+            pass
+        else:
+            raise ExtractorError(error_msg, expected=True)
+
         info_url = 'http://link.theplatform.com/s/dJ5BDC/{0}?format=preview'.format(video_id)
         info_json = self._download_webpage(info_url, video_id)
         info = json.loads(info_json)