[postprocessor:metadata] implement 'mtime' option (#2307)

This commit is contained in:
Mike Fährmann
2022-02-22 23:02:13 +01:00
parent 7aa2e2cd84
commit 7958995398
4 changed files with 33 additions and 12 deletions

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2017-2021 Mike Fährmann
# Copyright 2017-2022 Mike Fährmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
@@ -12,6 +12,7 @@ import re
import os
import sys
import json
import time
import random
import sqlite3
import binascii
@@ -20,6 +21,7 @@ import functools
import itertools
import urllib.parse
from http.cookiejar import Cookie
from email.utils import mktime_tz, parsedate_tz
from . import text, exception
@@ -272,6 +274,15 @@ def remove_directory(path):
pass
def set_mtime(path, mtime):
try:
if isinstance(mtime, str):
mtime = mktime_tz(parsedate_tz(mtime))
os.utime(path, (time.time(), mtime))
except Exception:
pass
def load_cookiestxt(fp):
"""Parse a Netscape cookies.txt file and return a list of its Cookies"""
cookies = []