-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add date to ExifInfo * Fix test for timezone * Added photos_datetime_local * Converted albuminfo to new datetime methods * Converted comments/likes to new datetime methods * Converted comments/likes to new datetime methods * Converted iPhoto code to new date methods * Converted iPhoto code to new date methods * Refactored date code in ShareInfo * added .workingon * Refactored date code in FingerprintQuery, added tests * Fix test for linux * Refactored PhotosDB date code, updated tests * Added date_original * Test updates * test updates * test updates * More test fixes * Test updates * Test updates * Removed dt_to_local * Removed dt_to_local * Initial reset implementation * Refactored to use utitools * Removed ubuntu tests * Updated makelive version
- Loading branch information
Showing
107 changed files
with
4,657 additions
and
3,879 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ venv/ | |
.python-version | ||
cov.xml | ||
pyrightconfig.json | ||
.workingon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,77 @@ | ||
""" ExifInfo class to expose EXIF info from the library """ | ||
|
||
from __future__ import annotations | ||
|
||
import datetime | ||
from dataclasses import dataclass | ||
from typing import Any | ||
|
||
from osxphotos.photos_datetime import photos_datetime | ||
|
||
__all__ = ["ExifInfo"] | ||
__all__ = ["ExifInfo", "exifinfo_factory"] | ||
|
||
|
||
@dataclass(frozen=True) | ||
class ExifInfo: | ||
"""EXIF info associated with a photo from the Photos library""" | ||
|
||
flash_fired: bool | ||
iso: int | ||
metering_mode: int | ||
sample_rate: int | ||
track_format: int | ||
white_balance: int | ||
aperture: float | ||
bit_rate: float | ||
duration: float | ||
exposure_bias: float | ||
focal_length: float | ||
fps: float | ||
latitude: float | ||
longitude: float | ||
shutter_speed: float | ||
camera_make: str | ||
camera_model: str | ||
codec: str | ||
lens_model: str | ||
"""Original EXIF info associated with a photo from the Photos library""" | ||
|
||
flash_fired: bool | None = None | ||
iso: int | None = None | ||
metering_mode: int | None = None | ||
sample_rate: int | None = None | ||
track_format: int | None = None | ||
white_balance: int | None = None | ||
aperture: float | None = None | ||
bit_rate: float | None = None | ||
duration: float | None = None | ||
exposure_bias: float | None = None | ||
focal_length: float | None = None | ||
fps: float | None = None | ||
latitude: float | None = None | ||
longitude: float | None = None | ||
shutter_speed: float | None = None | ||
camera_make: str | None = None | ||
camera_model: str | None = None | ||
codec: str | None = None | ||
lens_model: str | None = None | ||
date: datetime.datetime | None = None | ||
tzoffset: int | None = None | ||
tzname: str | None = None | ||
|
||
|
||
def exifinfo_factory(data: dict[str, Any] | None) -> ExifInfo: | ||
"""Create an ExifInfo object from a dictionary of EXIF data""" | ||
if data is None: | ||
return ExifInfo() | ||
|
||
exif_info = ExifInfo( | ||
iso=data["ZISO"], | ||
flash_fired=True if data["ZFLASHFIRED"] == 1 else False, | ||
metering_mode=data["ZMETERINGMODE"], | ||
sample_rate=data["ZSAMPLERATE"], | ||
track_format=data["ZTRACKFORMAT"], | ||
white_balance=data["ZWHITEBALANCE"], | ||
aperture=data["ZAPERTURE"], | ||
bit_rate=data["ZBITRATE"], | ||
duration=data["ZDURATION"], | ||
exposure_bias=data["ZEXPOSUREBIAS"], | ||
focal_length=data["ZFOCALLENGTH"], | ||
fps=data["ZFPS"], | ||
latitude=data["ZLATITUDE"], | ||
longitude=data["ZLONGITUDE"], | ||
shutter_speed=data["ZSHUTTERSPEED"], | ||
camera_make=data["ZCAMERAMAKE"], | ||
camera_model=data["ZCAMERAMODEL"], | ||
codec=data["ZCODEC"], | ||
lens_model=data["ZLENSMODEL"], | ||
# ZDATECREATED, ZTIMEZONEOFFSET, ZTIMEZONENAME added in Ventura / Photos 8 so may not be present | ||
tzoffset=data.get("ZTIMEZONEOFFSET"), | ||
tzname=data.get("ZTIMEZONENAME"), | ||
date=photos_datetime( | ||
data.get("ZDATECREATED"), | ||
data.get("ZTIMEZONEOFFSET"), | ||
data.get("ZTIMEZONENAME"), | ||
default=False, | ||
), | ||
) | ||
return exif_info |
Oops, something went wrong.