mirror of
https://github.com/l1ving/youtube-dl
synced 2025-02-09 16:22:50 +08:00
Updated to stamp extracted audio file with HTTP last modified date.
This commit is contained in:
parent
349714d255
commit
9f71ed55eb
14
youtube-dl
14
youtube-dl
@ -480,6 +480,7 @@ class FileDownloader(object):
|
|||||||
os.utime(filename,(time.time(), filetime))
|
os.utime(filename,(time.time(), filetime))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
return filetime
|
||||||
|
|
||||||
def report_destination(self, filename):
|
def report_destination(self, filename):
|
||||||
"""Report destination filename."""
|
"""Report destination filename."""
|
||||||
@ -568,7 +569,7 @@ class FileDownloader(object):
|
|||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
success = self._do_download(filename, info_dict['url'].encode('utf-8'), info_dict.get('player_url', None))
|
success, filetime = self._do_download(filename, info_dict['url'].encode('utf-8'), info_dict.get('player_url', None))
|
||||||
except (OSError, IOError), err:
|
except (OSError, IOError), err:
|
||||||
raise UnavailableVideoError
|
raise UnavailableVideoError
|
||||||
except (urllib2.URLError, httplib.HTTPException, socket.error), err:
|
except (urllib2.URLError, httplib.HTTPException, socket.error), err:
|
||||||
@ -580,6 +581,7 @@ class FileDownloader(object):
|
|||||||
|
|
||||||
if success:
|
if success:
|
||||||
try:
|
try:
|
||||||
|
info_dict['filetime'] = filetime
|
||||||
self.post_process(filename, info_dict)
|
self.post_process(filename, info_dict)
|
||||||
except (PostProcessingError), err:
|
except (PostProcessingError), err:
|
||||||
self.trouble(u'ERROR: postprocessing: %s' % str(err))
|
self.trouble(u'ERROR: postprocessing: %s' % str(err))
|
||||||
@ -780,9 +782,9 @@ class FileDownloader(object):
|
|||||||
|
|
||||||
# Update file modification time
|
# Update file modification time
|
||||||
if self.params.get('updatetime', True):
|
if self.params.get('updatetime', True):
|
||||||
self.try_utime(filename, data.info().get('last-modified', None))
|
filetime = self.try_utime(filename, data.info().get('last-modified', None))
|
||||||
|
|
||||||
return True
|
return True, filetime
|
||||||
|
|
||||||
class InfoExtractor(object):
|
class InfoExtractor(object):
|
||||||
"""Information Extractor class.
|
"""Information Extractor class.
|
||||||
@ -2682,6 +2684,12 @@ class FFmpegExtractAudioPP(PostProcessor):
|
|||||||
self._downloader.to_stderr(u'WARNING: error running ffmpeg')
|
self._downloader.to_stderr(u'WARNING: error running ffmpeg')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
# Try to update the date time for extracted audio file.
|
||||||
|
try:
|
||||||
|
os.utime(new_path,(time.time(), information['filetime']))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.remove(path)
|
os.remove(path)
|
||||||
except (IOError, OSError):
|
except (IOError, OSError):
|
||||||
|
Loading…
Reference in New Issue
Block a user