mirror of
https://github.com/l1ving/youtube-dl
synced 2025-02-05 00:52:53 +08:00
Added --get-filesize option
This commit is contained in:
parent
c7f0177fa7
commit
cc93a9a1af
@ -170,6 +170,7 @@ which means you can modify it, redistribute it or use it however you like.
|
||||
--get-duration simulate, quiet but print video length
|
||||
--get-filename simulate, quiet but print output filename
|
||||
--get-format simulate, quiet but print output format
|
||||
--get-filesize simulate, quiet but print video filesize
|
||||
-j, --dump-json simulate, quiet but print JSON information
|
||||
--newline output progress bar as new lines
|
||||
--no-progress do not print progress bar
|
||||
|
@ -159,7 +159,7 @@ class YoutubeDL(object):
|
||||
The following parameters are not used by YoutubeDL itself, they are used by
|
||||
the FileDownloader:
|
||||
nopart, updatetime, buffersize, ratelimit, min_filesize, max_filesize, test,
|
||||
noresizebuffer, retries, continuedl, noprogress, consoletitle
|
||||
noresizebuffer, retries, continuedl, noprogress, consoletitle, get_filesize
|
||||
|
||||
The following options are used by the post processors:
|
||||
prefer_ffmpeg: If True, use ffmpeg instead of avconv if both are available,
|
||||
|
@ -377,6 +377,9 @@ def parseOpts(overrideArguments=None):
|
||||
verbosity.add_option('--get-format',
|
||||
action='store_true', dest='getformat',
|
||||
help='simulate, quiet but print output format', default=False)
|
||||
verbosity.add_option('--get-filesize',
|
||||
action='store_true', dest='get_filesize',
|
||||
help='simulate, quiet but print video filesize', default=False)
|
||||
verbosity.add_option('-j', '--dump-json',
|
||||
action='store_true', dest='dumpjson',
|
||||
help='simulate, quiet but print JSON information', default=False)
|
||||
@ -685,7 +688,7 @@ def _real_main(argv=None):
|
||||
'username': opts.username,
|
||||
'password': opts.password,
|
||||
'videopassword': opts.videopassword,
|
||||
'quiet': (opts.quiet or any_printing),
|
||||
'quiet': (opts.quiet or any_printing or opts.get_filesize),
|
||||
'forceurl': opts.geturl,
|
||||
'forcetitle': opts.gettitle,
|
||||
'forceid': opts.getid,
|
||||
@ -740,6 +743,7 @@ def _real_main(argv=None):
|
||||
'keepvideo': opts.keepvideo,
|
||||
'min_filesize': opts.min_filesize,
|
||||
'max_filesize': opts.max_filesize,
|
||||
'get_filesize': opts.get_filesize,
|
||||
'min_views': opts.min_views,
|
||||
'max_views': opts.max_views,
|
||||
'daterange': date,
|
||||
|
@ -37,6 +37,7 @@ class FileDownloader(object):
|
||||
test: Download only first bytes to test the downloader.
|
||||
min_filesize: Skip files smaller than this size
|
||||
max_filesize: Skip files larger than this size
|
||||
get_filesize: Simulate quietly and print video filesize
|
||||
|
||||
Subclasses of this one must re-define the real_download method.
|
||||
"""
|
||||
|
@ -97,6 +97,9 @@ class HttpFD(FileDownloader):
|
||||
return False
|
||||
|
||||
data_len = data.info().get('Content-length', None)
|
||||
if self.params.get('get_filesize', False):
|
||||
print data_len
|
||||
return True
|
||||
if data_len is not None:
|
||||
data_len = int(data_len) + resume_len
|
||||
min_data_len = self.params.get("min_filesize", None)
|
||||
|
Loading…
Reference in New Issue
Block a user