Compare commits

..

1 Commits

Author SHA1 Message Date
msramalho
345e03e916 enables option to toggle db api writes 2023-12-13 12:54:12 +00:00
3 changed files with 6 additions and 12 deletions

View File

@@ -7,8 +7,6 @@ from dataclasses_json import dataclass_json, config
import datetime import datetime
from urllib.parse import urlparse from urllib.parse import urlparse
from dateutil.parser import parse as parse_dt from dateutil.parser import parse as parse_dt
from loguru import logger
from .media import Media from .media import Media
from .context import ArchivingContext from .context import ArchivingContext
@@ -108,15 +106,10 @@ class Metadata:
def get_timestamp(self, utc=True, iso=True) -> datetime.datetime: def get_timestamp(self, utc=True, iso=True) -> datetime.datetime:
ts = self.get("timestamp") ts = self.get("timestamp")
if not ts: return if not ts: return
try: if type(ts) == float: ts = datetime.datetime.fromtimestamp(ts)
if type(ts) == str: ts = datetime.datetime.fromisoformat(ts) if utc: ts = ts.replace(tzinfo=datetime.timezone.utc)
if type(ts) == float: ts = datetime.datetime.fromtimestamp(ts) if iso: return ts.isoformat()
if utc: ts = ts.replace(tzinfo=datetime.timezone.utc) return ts
if iso: return ts.isoformat()
return ts
except Exception as e:
logger.error(f"Unable to parse timestamp {ts}: {e}")
return
def add_media(self, media: Media, id: str = None) -> Metadata: def add_media(self, media: Media, id: str = None) -> Metadata:
# adds a new media, optionally including an id # adds a new media, optionally including an id

View File

@@ -18,6 +18,7 @@ class AAApiDb(Database):
self.allow_rearchive = bool(self.allow_rearchive) self.allow_rearchive = bool(self.allow_rearchive)
self.store_results = bool(self.store_results) self.store_results = bool(self.store_results)
self.assert_valid_string("api_endpoint") self.assert_valid_string("api_endpoint")
self.assert_valid_string("api_secret")
@staticmethod @staticmethod
def configs() -> dict: def configs() -> dict:

View File

@@ -3,7 +3,7 @@ _MAJOR = "0"
_MINOR = "7" _MINOR = "7"
# On main and in a nightly release the patch should be one ahead of the last # On main and in a nightly release the patch should be one ahead of the last
# released build. # released build.
_PATCH = "10" _PATCH = "7"
# This is mainly for nightly builds which have the suffix ".dev$DATE". See # This is mainly for nightly builds which have the suffix ".dev$DATE". See
# https://semver.org/#is-v123-a-semantic-version for the semantics. # https://semver.org/#is-v123-a-semantic-version for the semantics.
_SUFFIX = "" _SUFFIX = ""