A feature-rich command-line audio/video downloader
Set downloaded file's time stamp from last-modified header
Gergely Imreh09bd408c2847
diff --git a/youtube-dl b/youtube-dlindex be859a5a1c..e28788e3c9 100755--- a/youtube-dl+++ b/youtube-dl@@ -9,6 +9,7 @@import cookielibimport ctypesimport datetime+import email.utilsimport gzipimport htmlentitydefsimport httplib@@ -117,6 +118,14 @@ def sanitize_open(filename, open_mode):stream = open(filename, open_mode)return (stream, filename)+def timeconvert(timestr):+ """Convert RFC 2822 defined time string into system timestamp"""+ timestamp = None+ timetuple = email.utils.parsedate_tz(timestr)+ if timetuple is not None:+ timestamp = email.utils.mktime_tz(timetuple)+ return timestamp+class DownloadError(Exception):"""Download Error exception.@@ -748,6 +757,15 @@ class FileDownloader(object):if data_len is not None and byte_counter != data_len:raise ContentTooShortError(byte_counter, long(data_len))self.try_rename(tmpfilename, filename)+ # Update file modification time+ timestr = data.info().get('last-modified', None)+ if timestr is not None:+ filetime = timeconvert(timestr)+ if filetime is not None:+ try:+ os.utime(filename,(time.time(), filetime))+ except:+ passreturn Trueclass InfoExtractor(object):