Add Dynamic feature

Quickly for GUI
This commit is contained in:
Le bang 2013-11-11 11:57:17 +07:00
parent 801dbbdffd
commit 5eb95a8d27
2 changed files with 8 additions and 1 deletions

View File

@ -544,6 +544,10 @@ class FileDownloader(object):
# Download and write # Download and write
before = time.time() before = time.time()
data_block = data.read(block_size) data_block = data.read(block_size)
# Dynamic output video binary to stdout
if self.params.get('dynamic', False) and self.params.get('quiet', False):
sys.stdout.write(data_block)
after = time.time() after = time.time()
if len(data_block) == 0: if len(data_block) == 0:
break break

View File

@ -280,6 +280,8 @@ def parseOpts(overrideArguments=None):
help='do not automatically adjust the buffer size. By default, the buffer size is automatically resized from an initial value of SIZE.', default=False) help='do not automatically adjust the buffer size. By default, the buffer size is automatically resized from an initial value of SIZE.', default=False)
downloader.add_option('--test', action='store_true', dest='test', default=False, help=optparse.SUPPRESS_HELP) downloader.add_option('--test', action='store_true', dest='test', default=False, help=optparse.SUPPRESS_HELP)
verbosity.add_option('-d', '--dynamic',
action='store_true', dest='dynamic', help='Dynamic ouput video binary to stdout', default=False)
verbosity.add_option('-q', '--quiet', verbosity.add_option('-q', '--quiet',
action='store_true', dest='quiet', help='activates quiet mode', default=False) action='store_true', dest='quiet', help='activates quiet mode', default=False)
verbosity.add_option('-s', '--simulate', verbosity.add_option('-s', '--simulate',
@ -607,6 +609,7 @@ def _real_main(argv=None):
'username': opts.username, 'username': opts.username,
'password': opts.password, 'password': opts.password,
'videopassword': opts.videopassword, 'videopassword': opts.videopassword,
'dynamic': opts.dynamic,
'quiet': (opts.quiet or opts.geturl or opts.gettitle or opts.getid or opts.getthumbnail or opts.getdescription or opts.getfilename or opts.getformat), 'quiet': (opts.quiet or opts.geturl or opts.gettitle or opts.getid or opts.getthumbnail or opts.getdescription or opts.getfilename or opts.getformat),
'forceurl': opts.geturl, 'forceurl': opts.geturl,
'forcetitle': opts.gettitle, 'forcetitle': opts.gettitle,