[youtube] Fix extraction.
[youtube-dl] / youtube_dl / extractor / cammodels.py
index 4f1b88d14c80582b333dd5635dfcf66d0d661e2b..1eb81b75e95044d460d7f53e1d59e9ec174c6480 100644 (file)
@@ -2,10 +2,10 @@
 from __future__ import unicode_literals
 
 from .common import InfoExtractor
-from ..compat import compat_str
 from ..utils import (
     ExtractorError,
     int_or_none,
+    url_or_none,
 )
 
 
@@ -14,12 +14,14 @@ class CamModelsIE(InfoExtractor):
     _TESTS = [{
         'url': 'https://www.cammodels.com/cam/AutumnKnight/',
         'only_matching': True,
+        'age_limit': 18
     }]
 
     def _real_extract(self, url):
         user_id = self._match_id(url)
 
-        webpage = self._download_webpage(url, user_id)
+        webpage = self._download_webpage(
+            url, user_id, headers=self.geo_verification_headers())
 
         manifest_root = self._html_search_regex(
             r'manifestUrlRoot=([^&\']+)', webpage, 'manifest', default=None)
@@ -28,6 +30,7 @@ class CamModelsIE(InfoExtractor):
             ERRORS = (
                 ("I'm offline, but let's stay connected", 'This user is currently offline'),
                 ('in a private show', 'This user is in a private show'),
+                ('is currently performing LIVE', 'This model is currently performing live'),
             )
             for pattern, message in ERRORS:
                 if pattern in webpage:
@@ -54,8 +57,8 @@ class CamModelsIE(InfoExtractor):
             for media in encodings:
                 if not isinstance(media, dict):
                     continue
-                media_url = media.get('location')
-                if not media_url or not isinstance(media_url, compat_str):
+                media_url = url_or_none(media.get('location'))
+                if not media_url:
                     continue
 
                 format_id_list = [format_id]
@@ -91,4 +94,5 @@ class CamModelsIE(InfoExtractor):
             'title': self._live_title(user_id),
             'is_live': True,
             'formats': formats,
+            'age_limit': 18
         }