Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

YoutubeDL: Make the decision about removing the original file after each... #2442

Closed
wants to merge 1 commit into from

3 participants

@jaimeMF
Collaborator

... postprocessor is run (fixes #2261)

If one of the processors said the file should be kept, it wouldn't pay
attention to the response from the following processors. This was wrong if the
'keep_video' option was False, if the first extractor modifies the original file
and then we extract its audio we don't want to keep the original video file.

I think that's how we should handle the keep_video option, but I want that someone else reviews this change.

@jaimeMF jaimeMF YoutubeDL: Make the decision about removing the original file after e…
…ach postprocessor is run (fixes #2261)

If one of the processors said the file should be kept, it wouldn't pay
attention to the response from the following processors. This was wrong if the
'keep_video' option was False, if the first extractor modifies the original file
and then we extract its audio we don't want to keep the original video file.
927cc5a
@phihag
Collaborator

LGTM, feel free to merge. @jaimeMF, can you also have a look at the somewhat related #3829?

@jaimeMF
Collaborator

Merged in f3ff1a3

@jaimeMF jaimeMF closed this
@jaimeMF jaimeMF deleted the jaimeMF:pp-keep_video-rework branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 23, 2014
  1. @jaimeMF

    YoutubeDL: Make the decision about removing the original file after e…

    jaimeMF authored
    …ach postprocessor is run (fixes #2261)
    
    If one of the processors said the file should be kept, it wouldn't pay
    attention to the response from the following processors. This was wrong if the
    'keep_video' option was False, if the first extractor modifies the original file
    and then we extract its audio we don't want to keep the original video file.
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 8 deletions.
  1. +9 −8 youtube_dl/YoutubeDL.py
View
17 youtube_dl/YoutubeDL.py
@@ -1006,14 +1006,15 @@ def post_process(self, filename, ie_info):
"""Run all the postprocessors on the given file."""
info = dict(ie_info)
info['filepath'] = filename
- keep_video = None
pps_chain = []
if ie_info.get('__postprocessors') is not None:
pps_chain.extend(ie_info['__postprocessors'])
pps_chain.extend(self._pps)
for pp in pps_chain:
+ keep_video = None
+ old_filename = info['filepath']
try:
- keep_video_wish, new_info = pp.run(info)
+ keep_video_wish, info = pp.run(info)
if keep_video_wish is not None:
if keep_video_wish:
keep_video = keep_video_wish
@@ -1022,12 +1023,12 @@ def post_process(self, filename, ie_info):
keep_video = keep_video_wish
except PostProcessingError as e:
self.report_error(e.msg)
- if keep_video is False and not self.params.get('keepvideo', False):
- try:
- self.to_screen('Deleting original file %s (pass -k to keep)' % filename)
- os.remove(encodeFilename(filename))
- except (IOError, OSError):
- self.report_warning('Unable to remove downloaded video file')
+ if keep_video is False and not self.params.get('keepvideo', False):
+ try:
+ self.to_screen('Deleting original file %s (pass -k to keep)' % old_filename)
+ os.remove(encodeFilename(old_filename))
+ except (IOError, OSError):
+ self.report_warning('Unable to remove downloaded video file')
def _make_archive_id(self, info_dict):
# Future-proof against any change in case
Something went wrong with that request. Please try again.