1
0
mirror of https://github.com/instaloader/instaloader.git synced 2024-07-07 11:42:38 +02:00

Checks if caption is not None before normalization (#1475)

This commit is contained in:
MiguelX413 2022-04-18 07:49:34 +00:00 committed by GitHub
parent 218d88fc6d
commit 0704602e50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -365,10 +365,16 @@ class Post:
@property
def caption(self) -> Optional[str]:
"""Caption."""
def _normalize(string: Optional[str]) -> Optional[str]:
if string is not None:
return normalize("NFC", string)
else:
return None
if "edge_media_to_caption" in self._node and self._node["edge_media_to_caption"]["edges"]:
return normalize("NFC", self._node["edge_media_to_caption"]["edges"][0]["node"]["text"])
return _normalize(self._node["edge_media_to_caption"]["edges"][0]["node"]["text"])
elif "caption" in self._node:
return normalize("NFC", self._node["caption"])
return _normalize(self._node["caption"])
return None
@property