From: Oleg Broytman Date: Sun, 5 Jun 2016 22:07:53 +0000 (+0300) Subject: Set timestamp for the downloaded book X-Git-Tag: 0.0.11~3 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=b0c1d9a111696fd1f4b8d6d79e472047d53c8957;p=m_librarian.git Set timestamp for the downloaded book --- diff --git a/m_librarian/download.py b/m_librarian/download.py index 817f736..361f7aa 100755 --- a/m_librarian/download.py +++ b/m_librarian/download.py @@ -1,6 +1,7 @@ #! /usr/bin/env python import os +from time import mktime from shutil import copyfileobj from zipfile import ZipFile from .config import get_config @@ -11,7 +12,7 @@ __all__ = ['download'] _library_path = None -def download(archive, filename, path=None): +def download(archive, filename, date, path=None): if path is None: global _library_path if _library_path is None: @@ -25,3 +26,5 @@ def download(archive, filename, path=None): outfile.close() infile.close() zf.close() + dt = mktime(date.timetuple()) + os.utime(filename, (dt, dt)) diff --git a/scripts/ml-search.py b/scripts/ml-search.py index 18004fd..b257084 100755 --- a/scripts/ml-search.py +++ b/scripts/ml-search.py @@ -147,7 +147,7 @@ def _search_books(case_sensitive, search_type, args): sys.exit(1) book = books[0] download(book.archive, '%s.%s' % (book.file, book.extension.name), - args.path) + book.date, args.path) return count = 0 for book in books: