mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 18:41:29 +00:00
Updated to stamp extracted audio file with HTTP last modified date.
This commit is contained in:
parent
9b4556c469
commit
36597dc40f
18
youtube-dl
18
youtube-dl
|
@ -625,11 +625,12 @@ class FileDownloader(object):
|
||||||
return
|
return
|
||||||
filetime = timeconvert(timestr)
|
filetime = timeconvert(timestr)
|
||||||
if filetime is None:
|
if filetime is None:
|
||||||
return
|
return filetime
|
||||||
try:
|
try:
|
||||||
os.utime(filename, (time.time(), filetime))
|
os.utime(filename, (time.time(), filetime))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
return filetime
|
||||||
|
|
||||||
def report_writedescription(self, descfn):
|
def report_writedescription(self, descfn):
|
||||||
""" Report that the description file is being written """
|
""" Report that the description file is being written """
|
||||||
|
@ -772,7 +773,8 @@ class FileDownloader(object):
|
||||||
|
|
||||||
if not self.params.get('skip_download', False):
|
if not self.params.get('skip_download', False):
|
||||||
try:
|
try:
|
||||||
success = self._do_download(filename, info_dict['url'].encode('utf-8'), info_dict.get('player_url', None))
|
success,add_data = self._do_download(filename, info_dict['url'].encode('utf-8'), info_dict.get('player_url', None))
|
||||||
|
info_dict.update(add_data)
|
||||||
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:
|
||||||
|
@ -992,10 +994,11 @@ class FileDownloader(object):
|
||||||
self.try_rename(tmpfilename, filename)
|
self.try_rename(tmpfilename, filename)
|
||||||
|
|
||||||
# Update file modification time
|
# Update file modification time
|
||||||
|
filetime = None
|
||||||
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': filetime}
|
||||||
|
|
||||||
|
|
||||||
class InfoExtractor(object):
|
class InfoExtractor(object):
|
||||||
|
@ -3355,6 +3358,13 @@ 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.
|
||||||
|
if information.get('filetime') is not None:
|
||||||
|
try:
|
||||||
|
os.utime(new_path, (time.time(), information['filetime']))
|
||||||
|
except:
|
||||||
|
self._downloader.to_stderr(u'WARNING: Cannot update utime of audio file')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.remove(path)
|
os.remove(path)
|
||||||
except (IOError, OSError):
|
except (IOError, OSError):
|
||||||
|
|
Loading…
Reference in a new issue