Added support for custom user agents.
[youtube-dl] / youtube_dl / __init__.py
index 827b58264fc9af28bd971c305381673e575b1b1a..d457d6b8226b4ae6ee9f91ed4fd31d5f32cc696d 100644 (file)
@@ -190,6 +190,8 @@ def parseOpts():
        general.add_option('--dump-user-agent',
                        action='store_true', dest='dump_user_agent',
                        help='display the current browser identification', default=False)
+       general.add_option('--user-agent',
+                       action='store', dest='useragent', help='specify a custom user agent')
        general.add_option('--list-extractors',
                        action='store_true', dest='list_extractors',
                        help='List all supported extractors and the URLs they would handle', default=False)
@@ -293,11 +295,11 @@ def parseOpts():
 
 
        postproc.add_option('--extract-audio', action='store_true', dest='extractaudio', default=False,
-                       help='convert video files to audio-only files (requires ffmpeg and ffprobe)')
+                       help='convert video files to audio-only files (requires ffmpeg or avconv and ffprobe or avprobe)')
        postproc.add_option('--audio-format', metavar='FORMAT', dest='audioformat', default='best',
                        help='"best", "aac", "vorbis", "mp3", "m4a", or "wav"; best by default')
        postproc.add_option('--audio-quality', metavar='QUALITY', dest='audioquality', default='128K',
-                       help='ffmpeg audio bitrate specification, 128k by default')
+                       help='ffmpeg/avconv audio bitrate specification, 128k by default')
        postproc.add_option('-k', '--keep-video', action='store_true', dest='keepvideo', default=False,
                        help='keeps the video file on disk after the post-processing; the video is erased by default')
 
@@ -338,6 +340,7 @@ def gen_extractors():
                YahooSearchIE(),
                DepositFilesIE(),
                FacebookIE(),
+               BlipTVUserIE(),
                BlipTVIE(),
                VimeoIE(),
                MyVideoIE(),
@@ -367,7 +370,10 @@ def _real_main():
                                jar.load()
                except (IOError, OSError), err:
                        sys.exit(u'ERROR: unable to open cookie file')
-
+       # Set user agent
+       if opts.useragent is not None:
+               std_headers['User-Agent'] = opts.useragent
+               
        # Dump user agent
        if opts.dump_user_agent:
                print std_headers['User-Agent']