summaryrefslogtreecommitdiffhomepage
path: root/youtube_dl/FileDownloader.py
diff options
context:
space:
mode:
authorJaime Marquínez Ferrándiz <[email protected]>2013-10-11 12:42:15 +0200
committerJaime Marquínez Ferrándiz <[email protected]>2013-10-11 12:42:15 +0200
commit9026dd3858050db071b15db90cd953f7ab3de6c3 (patch)
treec6dca23710d9b056eaa823dfb7cf1b12a9fb63e6 /youtube_dl/FileDownloader.py
parent81d7f1928cf548160a101f23c5571cce11403f8d (diff)
downloadyoutube-dl-9026dd3858050db071b15db90cd953f7ab3de6c3.tar.gz
youtube-dl-9026dd3858050db071b15db90cd953f7ab3de6c3.zip
Make sure it only runs rtmpdump one time in test mode and return True if the download can be resumed
Diffstat (limited to 'youtube_dl/FileDownloader.py')
-rw-r--r--youtube_dl/FileDownloader.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/youtube_dl/FileDownloader.py b/youtube_dl/FileDownloader.py
index 2cda5d52a..8ecabab1a 100644
--- a/youtube_dl/FileDownloader.py
+++ b/youtube_dl/FileDownloader.py
@@ -270,6 +270,7 @@ class FileDownloader(object):
def _download_with_rtmpdump(self, filename, url, player_url, page_url, play_path, tc_url):
self.report_destination(filename)
tmpfilename = self.temp_name(filename)
+ test = self.params.get('test', False)
# Check for rtmpdump first
try:
@@ -291,7 +292,7 @@ class FileDownloader(object):
basic_args += ['--playpath', play_path]
if tc_url is not None:
basic_args += ['--tcUrl', url]
- if self.params.get('test', False):
+ if test:
basic_args += ['--stop', '1']
args = basic_args + [[], ['--resume', '--skip', '1']][self.params.get('continuedl', False)]
if self.params.get('verbose', False):
@@ -302,7 +303,7 @@ class FileDownloader(object):
shell_quote = repr
self.to_screen(u'[debug] rtmpdump command line: ' + shell_quote(args))
retval = subprocess.call(args)
- while retval == 2 or retval == 1:
+ while (retval == 2 or retval == 1) and not test:
prevsize = os.path.getsize(encodeFilename(tmpfilename))
self.to_screen(u'\r[rtmpdump] %s bytes' % prevsize, skip_eol=True)
time.sleep(5.0) # This seems to be needed
@@ -315,7 +316,7 @@ class FileDownloader(object):
self.to_screen(u'\r[rtmpdump] Could not download the whole video. This can happen for some advertisements.')
retval = 0
break
- if retval == 0:
+ if retval == 0 or (test and retval == 2):
fsize = os.path.getsize(encodeFilename(tmpfilename))
self.to_screen(u'\r[rtmpdump] %s bytes' % fsize)
self.try_rename(tmpfilename, filename)