Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 39 additions & 36 deletions google_takeout_parser/parse_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,39 +291,42 @@ def _parse_keep(p: Path) -> Iterator[Res[Keep]]:
json_data = _read_json_data(p)
# For google keep, each note is stored as a separate json file,
# so technically there is always just one yield value
yield Keep(
title=json_data["title"],
created_dt=datetime.fromtimestamp(
json_data["createdTimestampUsec"] / 1_000_000, tz=timezone.utc
),
updated_dt=datetime.fromtimestamp(
json_data["userEditedTimestampUsec"] / 1_000_000, tz=timezone.utc
),
listContent=[
KeepListContent(
textHtml=content["textHtml"],
text=content["text"],
isChecked=content["isChecked"]
) for content in json_data.get("listContent", [])
],
textContent=(
json_data["textContent"]
if "textContent" in json_data else None
),
textContentHtml=(
json_data["textContentHtml"]
if "textContentHtml" in json_data else None
),
color=json_data["color"],
annotations=[
KeepAnnotation(
description=annotation["description"],
source=annotation["source"],
title=annotation["title"],
url=annotation["url"],
) for annotation in json_data.get("annotations", [])
],
isTrashed=json_data["isTrashed"],
isPinned=json_data["isPinned"],
isArchived=json_data["isArchived"]
)
try:
yield Keep(
title=json_data["title"],
created_dt=datetime.fromtimestamp(
json_data["createdTimestampUsec"] / 1_000_000, tz=timezone.utc
),
updated_dt=datetime.fromtimestamp(
json_data["userEditedTimestampUsec"] / 1_000_000, tz=timezone.utc
),
listContent=[
KeepListContent(
textHtml=content["textHtml"],
text=content["text"],
isChecked=content["isChecked"]
) for content in json_data.get("listContent", [])
],
textContent=(
json_data["textContent"]
if "textContent" in json_data else None
),
textContentHtml=(
json_data["textContentHtml"]
if "textContentHtml" in json_data else None
),
color=json_data["color"],
annotations=[
KeepAnnotation(
description=annotation["description"],
source=annotation["source"],
title=annotation["title"],
url=annotation["url"],
) for annotation in json_data.get("annotations", [])
],
isTrashed=json_data["isTrashed"],
isPinned=json_data["isPinned"],
isArchived=json_data["isArchived"]
)
except Exception as e:
yield e