about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2015-01-02 21:02:34 +0100
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2015-01-02 21:02:34 +0100
commit817f786fbb05070a7ad23aec32293cfcdd072bf8 (patch)
tree32389b49da3649e6d89be79ac8a0cb5d2ea5a25c
parent62420c73cb16472ead562339e22b038fac7aa950 (diff)
downloadyoutube-dl-817f786fbb05070a7ad23aec32293cfcdd072bf8.tar.gz
youtube-dl-817f786fbb05070a7ad23aec32293cfcdd072bf8.tar.xz
youtube-dl-817f786fbb05070a7ad23aec32293cfcdd072bf8.zip
[canalplus] Raise an error if the video is georestricted (closes #4472)
-rw-r--r--youtube_dl/extractor/canalplus.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/youtube_dl/extractor/canalplus.py b/youtube_dl/extractor/canalplus.py
index 9873728df..11d18d74a 100644
--- a/youtube_dl/extractor/canalplus.py
+++ b/youtube_dl/extractor/canalplus.py
@@ -5,6 +5,8 @@ import re
 
 from .common import InfoExtractor
 from ..utils import (
+    ExtractorError,
+    HEADRequest,
     unified_strdate,
     url_basename,
     qualities,
@@ -76,6 +78,16 @@ class CanalplusIE(InfoExtractor):
 
         preference = qualities(['MOBILE', 'BAS_DEBIT', 'HAUT_DEBIT', 'HD', 'HLS', 'HDS'])
 
+        fmt_url = next(iter(media.find('VIDEOS'))).text
+        if '/geo' in fmt_url.lower():
+            response = self._request_webpage(
+                HEADRequest(fmt_url), video_id,
+                'Checking if the video is georestricted')
+            if '/blocage' in response.geturl():
+                raise ExtractorError(
+                    'The video is not available in your country',
+                    expected=True)
+
         formats = []
         for fmt in media.find('VIDEOS'):
             format_url = fmt.text