Added moment_info, #71
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
""" version info """
|
||||
|
||||
__version__ = "0.48.1"
|
||||
__version__ = "0.48.2"
|
||||
|
||||
Binary file not shown.
@@ -68,3 +68,19 @@ class MomentInfo:
|
||||
|
||||
self._photos = self._db.photos_by_uuid(photo_uuids)
|
||||
return self._photos
|
||||
|
||||
def asdict(self):
|
||||
"""Returns all moment info as dictionary"""
|
||||
return {
|
||||
"pk": self.pk,
|
||||
"location": self.location,
|
||||
"title": self.title,
|
||||
"subtitle": self.subtitle,
|
||||
"start_date": self.start_date.isoformat() if self.start_date else None,
|
||||
"end_date": self.end_date.isoformat() if self.end_date else None,
|
||||
"date": self.date.isoformat() if self.date else None,
|
||||
"modification_date": self.modification_date.isoformat()
|
||||
if self.modification_date
|
||||
else None,
|
||||
"photos": self.photos,
|
||||
}
|
||||
|
||||
@@ -479,7 +479,7 @@ class PhotoInfo:
|
||||
return self._faceinfo
|
||||
|
||||
@property
|
||||
def moment(self):
|
||||
def moment_info(self):
|
||||
"""Moment photo belongs to"""
|
||||
try:
|
||||
return self._moment
|
||||
|
||||
@@ -14,8 +14,8 @@ import tempfile
|
||||
from collections import OrderedDict
|
||||
from collections.abc import Iterable
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from pprint import pformat
|
||||
from typing import List
|
||||
from unicodedata import normalize
|
||||
|
||||
import bitmath
|
||||
import photoscript
|
||||
@@ -2566,8 +2566,16 @@ class PhotosDB:
|
||||
moment_info[date_name] = moment_date.astimezone(tz=tz)
|
||||
|
||||
# process title/subtitle
|
||||
moment_info["title"] = moment_info["title"] or ""
|
||||
moment_info["subtitle"] = moment_info["subtitle"] or ""
|
||||
# use unicodedata.normalize with KFKC instead of normalize_unicode as is done elsewhere
|
||||
# to replace non-breaking whitespace chars with spaces as Photos uses \xa0 as space in Moment titles, subtitles
|
||||
moment_info["title"] = (
|
||||
normalize("NFKC", moment_info["title"]) if moment_info["title"] else ""
|
||||
)
|
||||
moment_info["subtitle"] = (
|
||||
normalize("NFKC", moment_info["subtitle"])
|
||||
if moment_info["subtitle"]
|
||||
else ""
|
||||
)
|
||||
|
||||
self._db_moment_pk[moment_info["pk"]] = moment_info
|
||||
|
||||
|
||||
@@ -138,6 +138,7 @@ TEMPLATE_SUBSTITUTIONS = {
|
||||
"{exif.camera_make}": "Camera make from original photo's EXIF information as imported by Photos, e.g. 'Apple'",
|
||||
"{exif.camera_model}": "Camera model from original photo's EXIF information as imported by Photos, e.g. 'iPhone 6s'",
|
||||
"{exif.lens_model}": "Lens model from original photo's EXIF information as imported by Photos, e.g. 'iPhone 6s back camera 4.15mm f/2.2'",
|
||||
"{moment}": "The moment title of the photo",
|
||||
"{uuid}": "Photo's internal universally unique identifier (UUID) for the photo, a 36-character string unique to the photo, e.g. '128FB4C6-0B16-4E7D-9108-FB2E90DA1546'",
|
||||
"{id}": "A unique number for the photo based on its primary key in the Photos database. "
|
||||
+ "A sequential integer, e.g. 1, 2, 3...etc. Each asset associated with a photo (e.g. an image and Live Photo preview) will share the same id. "
|
||||
@@ -974,6 +975,8 @@ class PhotoTemplate:
|
||||
value = self.photo.exif_info.camera_model if self.photo.exif_info else None
|
||||
elif field == "exif.lens_model":
|
||||
value = self.photo.exif_info.lens_model if self.photo.exif_info else None
|
||||
elif field == "moment":
|
||||
value = self.photo.moment_info.title if self.photo.moment_info else None
|
||||
elif field == "uuid":
|
||||
value = self.photo.uuid
|
||||
elif field == "id":
|
||||
|
||||
Reference in New Issue
Block a user