Improve rtmpdump support
authorRicardo Garcia <sarbalap+freshmeat@gmail.com>
Tue, 19 Jan 2010 19:04:56 +0000 (20:04 +0100)
committerRicardo Garcia <sarbalap+freshmeat@gmail.com>
Sun, 31 Oct 2010 10:25:09 +0000 (11:25 +0100)
youtube-dl

index fac624e06485a4b53a5bb012cf625db7db865c52..6b56f3f98f6b0e03c7d3b623ad3ff99591c2004c 100755 (executable)
@@ -413,11 +413,12 @@ class FileDownloader(object):
                # Download using rtmpdump. rtmpdump returns exit code 2 when
                # the connection was interrumpted and resuming appears to be
                # possible. This is part of rtmpdump's normal usage, AFAIK.
-               retval = subprocess.call(['rtmpdump', '-q', '-r', url, '-o', filename] + [[], ['-e']][self.params.get('continuedl', False)])
-               while retval == 2:
+               basic_args = ['rtmpdump', '-q', '-r', url, '-o', filename]
+               retval = subprocess.call(basic_args + [[], ['-e', '-k', '1']][self.params.get('continuedl', False)])
+               while retval == 2 or retval == 1:
                        self.to_stdout(u'\r[rtmpdump] %s bytes' % os.path.getsize(filename), skip_eol=True)
                        time.sleep(2.0) # This seems to be needed
-                       retval = subprocess.call(['rtmpdump', '-q', '-e', '-r', url, '-o', filename])
+                       retval = subprocess.call(basic_args + ['-e'] + [[], ['-k', '1']][retval == 1])
                if retval == 0:
                        self.to_stdout(u'\r[rtmpdump] %s bytes' % os.path.getsize(filename))
                        return True