mirror of
https://github.com/aclist/dztui.git
synced 2026-11-12 04:50:37 +01:00
feat: get last updated timestamp
This commit is contained in:
1 parent
46117ecdda
commit
e3c1ef59ee
5 files changed
+57
-4
No files matched your search
@@ -2,6 +2,7 @@ import logging
|
||||
import re
|
||||
|
||||
from collections.abc import Iterator
|
||||
from datetime import date, datetime
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
from warnings import deprecated
|
||||
@@ -69,6 +70,28 @@ class ACF:
|
||||
except StopIteration:
|
||||
return acf
|
||||
|
||||
def search_key(self, key: str) -> str:
|
||||
return self.dict["AppState"][key]
|
||||
|
||||
def date_to_str(self, epoch: int) -> str | None:
|
||||
if epoch == 0:
|
||||
return None
|
||||
return datetime.fromtimestamp(epoch).isoformat(" ")
|
||||
|
||||
def get_date_by_key(self, key: str) -> str | None:
|
||||
try:
|
||||
stamp = int(self.search_key(key))
|
||||
return self.date_to_str(stamp)
|
||||
except Exception as e:
|
||||
logger.critical(e)
|
||||
return None
|
||||
|
||||
def get_last_updated(self) -> str | None:
|
||||
return self.get_date_by_key("LastUpdated")
|
||||
|
||||
def get_last_played(self) -> str:
|
||||
return self.get_date_by_key("LastPlayed")
|
||||
|
||||
def get_allows_downloads(self) -> int | None:
|
||||
try:
|
||||
# TODO: consider coercing strs to ints on initial import
|
||||
|
||||
Reference in new issue
Block a user