youtube-dl

Another place where youtube-dl lives on
git clone git://git.oshgnacknak.de/youtube-dl.git
Log | Files | Refs | README | LICENSE

commit dd29eb7f816bae7cf7807db9f26b7f5621b8d557
parent bca788ab1d477abfc29edb29480075ed10cace25
Author: Sergey M․ <dstftw@gmail.com>
Date:   Wed,  8 Apr 2015 21:40:31 +0600

[postprocessor/common:postprocessor/ffmpeg] Generalize utime

Diffstat:
Myoutube_dl/postprocessor/common.py | 13++++++++++++-
Myoutube_dl/postprocessor/ffmpeg.py | 12++++--------
2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/youtube_dl/postprocessor/common.py b/youtube_dl/postprocessor/common.py @@ -1,6 +1,11 @@ from __future__ import unicode_literals -from ..utils import PostProcessingError +import os + +from ..utils import ( + PostProcessingError, + encodeFilename, +) class PostProcessor(object): @@ -46,6 +51,12 @@ class PostProcessor(object): """ return None, information # by default, keep file and do nothing + def try_utime(self, path, atime, mtime, errnote='Cannot update utime of file'): + try: + os.utime(encodeFilename(path), (atime, mtime)) + except Exception: + self._downloader.report_warning(errnote) + class AudioConversionError(PostProcessingError): pass diff --git a/youtube_dl/postprocessor/ffmpeg.py b/youtube_dl/postprocessor/ffmpeg.py @@ -146,10 +146,7 @@ class FFmpegPostProcessor(PostProcessor): stderr = stderr.decode('utf-8', 'replace') msg = stderr.strip().split('\n')[-1] raise FFmpegPostProcessorError(msg) - try: - os.utime(encodeFilename(out_path), (oldest_mtime, oldest_mtime)) - except Exception: - self._downloader.report_warning('Cannot update utime of file') + self.try_utime(out_path, oldest_mtime, oldest_mtime) if self._deletetempfiles: for ipath in input_paths: @@ -284,10 +281,9 @@ class FFmpegExtractAudioPP(FFmpegPostProcessor): # Try to update the date time for extracted audio file. if information.get('filetime') is not None: - try: - os.utime(encodeFilename(new_path), (time.time(), information['filetime'])) - except Exception: - self._downloader.report_warning('Cannot update utime of audio file') + self.try_utime( + new_path, time.time(), information['filetime'], + errnote='Cannot update utime of audio file') information['filepath'] = new_path return self._nopostoverwrites, information