sebsync 1.0a2__tar.gz → 1.0a3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6,7 +6,7 @@ import xml.etree.ElementTree as ElementTree
|
|
|
6
6
|
import zipfile
|
|
7
7
|
|
|
8
8
|
from dataclasses import dataclass
|
|
9
|
-
from datetime import datetime
|
|
9
|
+
from datetime import datetime, timezone
|
|
10
10
|
from pathlib import Path
|
|
11
11
|
from requests.auth import HTTPBasicAuth
|
|
12
12
|
|
|
@@ -46,6 +46,16 @@ def _if_exists(path: Path) -> Path | None:
|
|
|
46
46
|
return path if path.exists() else None
|
|
47
47
|
|
|
48
48
|
|
|
49
|
+
def _fromisoformat(text: str) -> datetime:
|
|
50
|
+
"""Convert RFC 3339 string into datetime; compatible with Python 3.10."""
|
|
51
|
+
if not text.endswith("Z"):
|
|
52
|
+
raise ValueError("expecting RFC 3339 formatted string")
|
|
53
|
+
d = datetime.fromisoformat(text.rstrip("Z"))
|
|
54
|
+
return datetime(
|
|
55
|
+
d.year, d.month, d.day, d.hour, d.minute, d.second, d.microsecond, timezone.utc
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
|
|
49
59
|
def get_standard_ebooks(opds: str, email: str) -> dict[str, StandardEbook]:
|
|
50
60
|
"""Return Standard Ebooks metadata for EPUBs from the OPDS catalog."""
|
|
51
61
|
ns = {"atom": "http://www.w3.org/2005/Atom", "dc": "http://purl.org/dc/terms/"}
|
|
@@ -61,7 +71,7 @@ def get_standard_ebooks(opds: str, email: str) -> dict[str, StandardEbook]:
|
|
|
61
71
|
href=entry.find(".//atom:link[@title='Recommended compatible epub']", ns).attrib[
|
|
62
72
|
"href"
|
|
63
73
|
],
|
|
64
|
-
updated=
|
|
74
|
+
updated=_fromisoformat(entry.find("atom:updated", ns).text),
|
|
65
75
|
)
|
|
66
76
|
ebooks[ebook.id] = ebook
|
|
67
77
|
return ebooks
|
|
@@ -91,7 +101,7 @@ def get_local_ebooks(dir: Path) -> dict[str, LocalEbook]:
|
|
|
91
101
|
id=id.text,
|
|
92
102
|
title=metadata.find(".//dc:title", ns).text,
|
|
93
103
|
path=path,
|
|
94
|
-
modified=
|
|
104
|
+
modified=_fromisoformat(modified.text),
|
|
95
105
|
)
|
|
96
106
|
ebooks[ebook.id] = ebook
|
|
97
107
|
return ebooks
|
|
File without changes
|
|
File without changes
|
|
File without changes
|