aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/PostProcessor.py
diff options
context:
space:
mode:
authorBarbu Paul - Gheorghe <barbu.paul.gheorghe@gmail.com>2012-12-23 19:51:41 +0200
committerBarbu Paul - Gheorghe <barbu.paul.gheorghe@gmail.com>2012-12-23 19:51:41 +0200
commit0c0074328b2b896317bf4e33378fc587f0d3dfe1 (patch)
tree48fa90b2df609f0cb2fc8b7714a7e19df5d49442 /youtube_dl/PostProcessor.py
parentf0648fc18c91fde0c2db2e52c1cf78fe6bf3bbc4 (diff)
modified FFmpegExtractAudioPP to accept whether it should overwrite post-processed files or not
Diffstat (limited to 'youtube_dl/PostProcessor.py')
-rw-r--r--youtube_dl/PostProcessor.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/youtube_dl/PostProcessor.py b/youtube_dl/PostProcessor.py
index cc7789e3b..e0b071a9c 100644
--- a/youtube_dl/PostProcessor.py
+++ b/youtube_dl/PostProcessor.py
@@ -62,13 +62,14 @@ class AudioConversionError(BaseException):
self.message = message
class FFmpegExtractAudioPP(PostProcessor):
- def __init__(self, downloader=None, preferredcodec=None, preferredquality=None, keepvideo=False):
+ def __init__(self, downloader=None, preferredcodec=None, preferredquality=None, keepvideo=False, nopostoverwrites=False):
PostProcessor.__init__(self, downloader)
if preferredcodec is None:
preferredcodec = 'best'
self._preferredcodec = preferredcodec
self._preferredquality = preferredquality
self._keepvideo = keepvideo
+ self._nopostoverwrites = nopostoverwrites
self._exes = self.detect_executables()
@staticmethod
@@ -102,12 +103,16 @@ class FFmpegExtractAudioPP(PostProcessor):
def run_ffmpeg(self, path, out_path, codec, more_opts):
if not self._exes['ffmpeg'] and not self._exes['avconv']:
- raise AudioConversionError('ffmpeg or avconv not found. Please install one.')
+ raise AudioConversionError('ffmpeg or avconv not found. Please install one.')
if codec is None:
acodec_opts = []
else:
acodec_opts = ['-acodec', codec]
- cmd = ([self._exes['avconv'] or self._exes['ffmpeg'], '-y', '-i', encodeFilename(path), '-vn']
+ if self._nopostoverwrites:
+ overwrite_opts = '-n'
+ else:
+ overwrite_opts = '-y'
+ cmd = ([self._exes['avconv'] or self._exes['ffmpeg'], overwrite_opts, '-i', encodeFilename(path), '-vn']
+ acodec_opts + more_opts +
['--', encodeFilename(out_path)])
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)