Browse Source

[snagfilms:embed] Capture geolocation restriction error

Sergey M․ 10 years ago
parent
commit
9fbfc9bd4d
1 changed files with 7 additions and 1 deletions
  1. 7 1
      youtube_dl/extractor/snagfilms.py

+ 7 - 1
youtube_dl/extractor/snagfilms.py

@@ -4,6 +4,7 @@ import re
 
 
 from .common import InfoExtractor
 from .common import InfoExtractor
 from ..utils import (
 from ..utils import (
+    ExtractorError,
     clean_html,
     clean_html,
     determine_ext,
     determine_ext,
     int_or_none,
     int_or_none,
@@ -30,7 +31,8 @@ class SnagFilmsEmbedIE(InfoExtractor):
     @staticmethod
     @staticmethod
     def _extract_url(webpage):
     def _extract_url(webpage):
         mobj = re.search(
         mobj = re.search(
-            r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:embed\.)?snagfilms\.com/embed/player.+?)\1', webpage)
+            r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:embed\.)?snagfilms\.com/embed/player.+?)\1',
+            webpage)
         if mobj:
         if mobj:
             return mobj.group('url')
             return mobj.group('url')
 
 
@@ -39,6 +41,10 @@ class SnagFilmsEmbedIE(InfoExtractor):
 
 
         webpage = self._download_webpage(url, video_id)
         webpage = self._download_webpage(url, video_id)
 
 
+        if '>This film is not playable in your area.<' in webpage:
+            raise ExtractorError(
+                'This film is not playable in your area.', expected=True)
+
         formats = []
         formats = []
         for source in self._parse_json(js_to_json(self._search_regex(
         for source in self._parse_json(js_to_json(self._search_regex(
                 r'(?s)sources:\s*(\[.+?\]),', webpage, 'json')), video_id):
                 r'(?s)sources:\s*(\[.+?\]),', webpage, 'json')), video_id):