diff options
author | Sergey M․ <dstftw@gmail.com> | 2017-04-29 04:33:35 +0700 |
---|---|---|
committer | Sergey M․ <dstftw@gmail.com> | 2017-04-29 04:33:35 +0700 |
commit | e7db6759e4c4ca5099a997285642e60b84eee2c6 (patch) | |
tree | 3d41be639c4c8fc209ee86ea995ba7ac9bc7e4b9 | |
parent | b364c87c423cbc031cd64566a1b283097b560d59 (diff) |
[downloader/external] Properly handle live stream downloading cancellation (closes #8932)
-rw-r--r-- | youtube_dl/downloader/external.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/youtube_dl/downloader/external.py b/youtube_dl/downloader/external.py index e13cf547d..e78169a0d 100644 --- a/youtube_dl/downloader/external.py +++ b/youtube_dl/downloader/external.py @@ -29,7 +29,17 @@ class ExternalFD(FileDownloader): self.report_destination(filename) tmpfilename = self.temp_name(filename) - retval = self._call_downloader(tmpfilename, info_dict) + try: + retval = self._call_downloader(tmpfilename, info_dict) + except KeyboardInterrupt: + if not info_dict.get('is_live'): + raise + # Live stream downloading cancellation should be considered as + # correct and expected termination thus all postprocessing + # should take place + retval = 0 + self.to_screen('[%s] Interrupted by user' % self.get_basename()) + if retval == 0: fsize = os.path.getsize(encodeFilename(tmpfilename)) self.to_screen('\r[%s] Downloaded %s bytes' % (self.get_basename(), fsize)) |