diff options
Diffstat (limited to 'youtube_dl/__init__.py')
| -rw-r--r-- | youtube_dl/__init__.py | 59 | 
1 files changed, 48 insertions, 11 deletions
diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index fb1270ea2..48ffcbf8e 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -31,6 +31,7 @@ __authors__  = (      'Huarong Huo',      'Ismael Mejía',      'Steffan \'Ruirize\' James', +    'Andras Elso',  )  __license__ = 'Public Domain' @@ -46,17 +47,43 @@ import shlex  import socket  import subprocess  import sys -import warnings +import traceback  import platform -from .utils import * +from .utils import ( +    compat_cookiejar, +    compat_print, +    compat_str, +    compat_urllib_request, +    DateRange, +    decodeOption, +    determine_ext, +    DownloadError, +    get_cachedir, +    make_HTTPS_handler, +    MaxDownloadsReached, +    platform_name, +    preferredencoding, +    SameFileError, +    std_headers, +    write_string, +    YoutubeDLHandler, +)  from .update import update_self  from .version import __version__ -from .FileDownloader import * +from .FileDownloader import ( +    FileDownloader, +)  from .extractor import gen_extractors  from .YoutubeDL import YoutubeDL -from .PostProcessor import * +from .PostProcessor import ( +    FFmpegMetadataPP, +    FFmpegVideoConvertor, +    FFmpegExtractAudioPP, +    FFmpegEmbedSubtitlePP, +) +  def parseOpts(overrideArguments=None):      def _readOptions(filename_bytes): @@ -106,7 +133,7 @@ def parseOpts(overrideArguments=None):      def _hide_login_info(opts):          opts = list(opts) -        for private_opt in ['-p', '--password', '-u', '--username']: +        for private_opt in ['-p', '--password', '-u', '--username', '--video-password']:              try:                  i = opts.index(private_opt)                  opts[i+1] = '<PRIVATE>' @@ -152,6 +179,9 @@ def parseOpts(overrideArguments=None):              action='store_true', dest='update_self', help='update this program to latest version. Make sure that you have sufficient permissions (run with sudo if needed)')      general.add_option('-i', '--ignore-errors',              action='store_true', dest='ignoreerrors', help='continue on download errors, for example to to skip unavailable videos in a playlist', default=False) +    general.add_option('--abort-on-error', +            action='store_false', dest='ignoreerrors', +            help='Abort downloading of further videos (in the playlist or the command line) if an error occurs')      general.add_option('--dump-user-agent',              action='store_true', dest='dump_user_agent',              help='display the current browser identification', default=False) @@ -169,7 +199,7 @@ def parseOpts(overrideArguments=None):      general.add_option('--proxy', dest='proxy', default=None, help='Use the specified HTTP/HTTPS proxy', metavar='URL')      general.add_option('--no-check-certificate', action='store_true', dest='no_check_certificate', default=False, help='Suppress HTTPS certificate validation.')      general.add_option( -        '--cache-dir', dest='cachedir', default=get_cachedir(), +        '--cache-dir', dest='cachedir', default=get_cachedir(), metavar='DIR',          help='Location in the filesystem where youtube-dl can store downloaded information permanently. By default $XDG_CACHE_HOME/youtube-dl or ~/.cache/youtube-dl .')      general.add_option(          '--no-cache-dir', action='store_const', const=None, dest='cachedir', @@ -208,7 +238,7 @@ def parseOpts(overrideArguments=None):      video_format.add_option('-f', '--format', -            action='store', dest='format', metavar='FORMAT', +            action='store', dest='format', metavar='FORMAT', default='best',              help='video format code, specifiy the order of preference using slashes: "-f 22/17/18". "-f mp4" and "-f flv" are also supported')      video_format.add_option('--all-formats',              action='store_const', dest='format', help='download all available video formats', const='all') @@ -240,11 +270,11 @@ def parseOpts(overrideArguments=None):              help='languages of the subtitles to download (optional) separated by commas, use IETF language tags like \'en,pt\'')      downloader.add_option('-r', '--rate-limit', -            dest='ratelimit', metavar='LIMIT', help='maximum download rate (e.g. 50k or 44.6m)') +            dest='ratelimit', metavar='LIMIT', help='maximum download rate in bytes per second (e.g. 50K or 4.2M)')      downloader.add_option('-R', '--retries',              dest='retries', metavar='RETRIES', help='number of retries (default is %default)', default=10)      downloader.add_option('--buffer-size', -            dest='buffersize', metavar='SIZE', help='size of download buffer (e.g. 1024 or 16k) (default is %default)', default="1024") +            dest='buffersize', metavar='SIZE', help='size of download buffer (e.g. 1024 or 16K) (default is %default)', default="1024")      downloader.add_option('--no-resize-buffer',              action='store_true', dest='noresizebuffer',              help='do not automatically adjust the buffer size. By default, the buffer size is automatically resized from an initial value of SIZE.', default=False) @@ -286,6 +316,9 @@ def parseOpts(overrideArguments=None):      verbosity.add_option('--dump-intermediate-pages',              action='store_true', dest='dump_intermediate_pages', default=False,              help='print downloaded pages to debug problems(very verbose)') +    verbosity.add_option('--write-pages', +            action='store_true', dest='write_pages', default=False, +            help='Write downloaded pages to files in the current directory')      verbosity.add_option('--youtube-print-sig-code',              action='store_true', dest='youtube_print_sig_code', default=False,              help=optparse.SUPPRESS_HELP) @@ -305,7 +338,10 @@ def parseOpts(overrideArguments=None):              help=('output filename template. Use %(title)s to get the title, '                    '%(uploader)s for the uploader name, %(uploader_id)s for the uploader nickname if different, '                    '%(autonumber)s to get an automatically incremented number, ' -                  '%(ext)s for the filename extension, %(upload_date)s for the upload date (YYYYMMDD), ' +                  '%(ext)s for the filename extension, ' +                  '%(format)s for the format description (like "22 - 1280x720" or "HD"),' +                  '%(format_id)s for the unique id of the format (like Youtube\'s itags: "137"),' +                  '%(upload_date)s for the upload date (YYYYMMDD), '                    '%(extractor)s for the provider (youtube, metacafe, etc), '                    '%(id)s for the video id , %(playlist)s for the playlist the video is in, '                    '%(playlist_index)s for the position in the playlist and %% for a literal percent. ' @@ -619,6 +655,7 @@ def _real_main(argv=None):          'prefer_free_formats': opts.prefer_free_formats,          'verbose': opts.verbose,          'dump_intermediate_pages': opts.dump_intermediate_pages, +        'write_pages': opts.write_pages,          'test': opts.test,          'keepvideo': opts.keepvideo,          'min_filesize': opts.min_filesize, @@ -688,7 +725,7 @@ def _real_main(argv=None):      if opts.cookiefile is not None:          try:              jar.save() -        except (IOError, OSError) as err: +        except (IOError, OSError):              sys.exit(u'ERROR: unable to save cookie jar')      sys.exit(retcode)  | 
