Merge pull request #801 from expleo/add_referer_support
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Fri, 26 Apr 2013 17:25:17 +0000 (19:25 +0200)
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Fri, 26 Apr 2013 17:34:32 +0000 (19:34 +0200)
README.md
youtube_dl/InfoExtractors.py
youtube_dl/__init__.py

index 0ab4b660cee8eec837cff27038d58fd09bdd95fd..d3073e641c3260900c313f59b92995d4d38647a2 100644 (file)
--- a/README.md
+++ b/README.md
@@ -27,6 +27,8 @@ which means you can modify it, redistribute it or use it however you like.
                                from an initial value of SIZE.
     --dump-user-agent          display the current browser identification
     --user-agent UA            specify a custom user agent
+    --referer REF              specify a custom referer, use if the video access
+                               is restricted to one domain
     --list-extractors          List all supported extractors and the URLs they
                                would handle
 
index 4d145dfa101b0118ccc15a6d81d4098568ab8276..3450f0d17e19d95d67645a50c79f0680b05379cc 100755 (executable)
@@ -1093,7 +1093,10 @@ class VimeoIE(InfoExtractor):
             config = webpage.split(' = {config:')[1].split(',assets:')[0]
             config = json.loads(config)
         except:
-            self._downloader.report_error(u'unable to extract info section')
+            if re.search('The creator of this video has not given you permission to embed it on this domain.', webpage):
+                self._downloader.report_error(u'The author has restricted the access to this video, try with the "--referer" option')
+            else:
+                self._downloader.report_error(u'unable to extract info section')
             return
 
         # Extract title
index 74375175dd1ebca987de37ceef7af30b34ca5de0..d491402c6a9702c57dbbd4122924b22f2ede2177 100644 (file)
@@ -140,6 +140,9 @@ def parseOpts(overrideArguments=None):
             help='display the current browser identification', default=False)
     general.add_option('--user-agent',
             dest='user_agent', help='specify a custom user agent', metavar='UA')
+    general.add_option('--referer',
+            dest='referer', help='specify a custom referer, use if the video access is restricted to one domain',
+            metavar='REF', default=None)
     general.add_option('--list-extractors',
             action='store_true', dest='list_extractors',
             help='List all supported extractors and the URLs they would handle', default=False)
@@ -342,6 +345,10 @@ def _real_main(argv=None):
     # Set user agent
     if opts.user_agent is not None:
         std_headers['User-Agent'] = opts.user_agent
+    
+    # Set referer
+    if opts.referer is not None:
+        std_headers['Referer'] = opts.referer
 
     # Dump user agent
     if opts.dump_user_agent: