Compare commits
75 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf9961e203 | ||
|
|
c63b08694e | ||
|
|
30b0c13b33 | ||
|
|
1977578cfd | ||
|
|
44a46cb652 | ||
|
|
7ed8c7e583 | ||
|
|
0064304574 | ||
|
|
179997aa96 | ||
|
|
889c878138 | ||
|
|
2bac3a9c3e | ||
|
|
3a1a4ad991 | ||
|
|
2190628e82 | ||
|
|
bb8e164f21 | ||
|
|
7ccfe26e37 | ||
|
|
2c80226ec8 | ||
|
|
492e1edb7f | ||
|
|
72c6a165c7 | ||
|
|
e9aa289e8a | ||
|
|
1fd73e5351 | ||
|
|
8de871ccf1 | ||
|
|
0473b45631 | ||
|
|
6b541b83ad | ||
|
|
633f3a92fa | ||
|
|
de0b4fa11f | ||
|
|
269a2dfa9e | ||
|
|
986010ec5f | ||
|
|
e062582d14 | ||
|
|
d30314bedc | ||
|
|
7dfd24cb96 | ||
|
|
fcb015dd4a | ||
|
|
d2338992a2 | ||
|
|
234db3fb54 | ||
|
|
55d4be6892 | ||
|
|
922634ab3e | ||
|
|
f0aa69d8bb | ||
|
|
ee8053d867 | ||
|
|
253901281d | ||
|
|
051da093ea | ||
|
|
fd5b16578c | ||
|
|
ca3da647f2 | ||
|
|
0c85298c03 | ||
|
|
b4b58d3b00 | ||
|
|
ed543aa2d0 | ||
|
|
1b0c91db97 | ||
|
|
dd3914328b | ||
|
|
4b4252a73c | ||
|
|
956cecfa30 | ||
|
|
6f88f19950 | ||
|
|
ce4f3c4c0b | ||
|
|
3993cf220d | ||
|
|
2ae41a5a7a | ||
|
|
519a6b0035 | ||
|
|
a4b4f1c288 | ||
|
|
f668ecf0c4 | ||
|
|
058b56092f | ||
|
|
d2b7783125 | ||
|
|
f4a743468d | ||
|
|
adac985309 | ||
|
|
4939324d2f | ||
|
|
1a3b4c2afe | ||
|
|
1b16a39cef | ||
|
|
0d31a152be | ||
|
|
34fbd87fc6 | ||
|
|
3ddfea6a3d | ||
|
|
8b59615ff7 | ||
|
|
c590a16d70 | ||
|
|
36ce86c4a6 | ||
|
|
93d22c646f | ||
|
|
77000d85c6 | ||
|
|
005f821501 | ||
|
|
622f8952b7 | ||
|
|
b7816be459 | ||
|
|
e7099d250b | ||
|
|
2c4d0f4546 | ||
|
|
84954f4551 |
@@ -262,7 +262,8 @@
|
||||
"bug",
|
||||
"ideas",
|
||||
"test",
|
||||
"code"
|
||||
"code",
|
||||
"doc"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -529,10 +530,76 @@
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/2597142?v=4",
|
||||
"profile": "https://github.com/pekingduck",
|
||||
"contributions": [
|
||||
"ideas"
|
||||
"ideas",
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "cclauss",
|
||||
"name": "Christian Clauss",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/3709715?v=4",
|
||||
"profile": "https://www.patreon.com/cclauss",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "dvdkon",
|
||||
"name": "dvdkon",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/3526303?v=4",
|
||||
"profile": "https://github.com/dvdkon",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "wernerzj",
|
||||
"name": "wernerzj",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/130370930?v=4",
|
||||
"profile": "https://github.com/wernerzj",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "rajscode",
|
||||
"name": "rajscode",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/99123253?v=4",
|
||||
"profile": "https://github.com/rajscode",
|
||||
"contributions": [
|
||||
"bug",
|
||||
"doc"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "MaxLyt",
|
||||
"name": "MaxLyt",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/136200430?v=4",
|
||||
"profile": "https://github.com/MaxLyt",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "ces3001",
|
||||
"name": "ces3001",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/23762610?v=4",
|
||||
"profile": "https://github.com/ces3001",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "msolo",
|
||||
"name": "msolo",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/5078276?v=4",
|
||||
"profile": "https://github.com/msolo",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
}
|
||||
],
|
||||
"contributorsPerLine": 7,
|
||||
"skipCi": true
|
||||
"skipCi": true,
|
||||
"commitType": "docs"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[bumpversion]
|
||||
current_version = 0.58.2
|
||||
current_version = 0.60.7
|
||||
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)
|
||||
serialize = {major}.{minor}.{patch}
|
||||
|
||||
|
||||
14
.github/workflows/tests.yml
vendored
14
.github/workflows/tests.yml
vendored
@@ -3,15 +3,23 @@ name: Tests
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
ruff: # https://beta.ruff.rs
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- run: pip install --user ruff # Lint Python twice: 1. Whole repo, 2. Exclude tests/
|
||||
- run: ruff --format=github --line-length=7228 --target-version=py39
|
||||
--ignore=E402,E712,E721,E722,E741,F401,F403,F405,F541,F601,F811,F822,F841 .
|
||||
- run: ruff --format=github --line-length=366 --target-version=py39
|
||||
--exclude=tests/ --ignore=E402,E722,E741,F401,F403,F405,F541,F822,F841 .
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
if: "!contains(github.event.head_commit.message, '[skip ci]')"
|
||||
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
|
||||
strategy:
|
||||
max-parallel: 4
|
||||
matrix:
|
||||
os: [macos-latest]
|
||||
os: [macos-latest, ubuntu-latest]
|
||||
python-version: ['3.9', '3.10', '3.11']
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
|
||||
142
API_README.md
142
API_README.md
@@ -23,6 +23,7 @@ In addition to a command line interface, OSXPhotos provides a access to a Python
|
||||
* [CommentInfo](#commentinfo)
|
||||
* [LikeInfo](#likeinfo)
|
||||
* [AdjustmentsInfo](#adjustmentsinfo)
|
||||
* [PhotoTables](#phototables)
|
||||
* [Raw Photos](#raw-photos)
|
||||
* [Template System](#template-system)
|
||||
* [ExifTool](#exiftoolExifTool)
|
||||
@@ -338,10 +339,7 @@ to your function. You can then do whatever you want with the photos.
|
||||
from __future__ import annotations
|
||||
|
||||
import osxphotos
|
||||
from osxphotos.cli import (
|
||||
selection_command,
|
||||
verbose,
|
||||
)
|
||||
from osxphotos.cli import selection_command, verbose
|
||||
|
||||
|
||||
@selection_command
|
||||
@@ -376,6 +374,72 @@ if __name__ == "__main__":
|
||||
```
|
||||
<!--[[[end]]]-->
|
||||
|
||||
## Concurrency
|
||||
|
||||
OSXPhotos is not currently compatible with multiprocessing as the `PhotosDB` class cannot be pickled which required
|
||||
when sharing data between processes. Photos can be exported concurrently using separate threads, however, this is
|
||||
only compatible with Python 3.11 and later. See [issue #999](https://github.com/RhetTbull/osxphotos/issues/999).
|
||||
The reason for this is that internally, `PhotoExporter` uses a sqlite `ExportDB` database for managing the export,
|
||||
even if you don't specify an export database. (In the case where you don't specify an export database, a temporary
|
||||
in-memory database is created and then discard.) The python implementation of sqlite3 is not fully thread safe on
|
||||
Python < 3.11.
|
||||
|
||||
For example, the following code will work on Python >= 3.11. This code is available in the `examples` directory as
|
||||
[concurrent_export.py](https://github.com/RhetTbull/osxphotos/blob/main/examples/concurrent_export.py).
|
||||
|
||||
```python
|
||||
"""Example for concurrent export of photos using osxphotos.PhotoExporter.export()
|
||||
|
||||
Note: concurrent export can only be used on Python 3.11 and later due to the way
|
||||
python's sqlite3 module is implemented. See https://docs.python.org/3/library/sqlite3.html#sqlite3.threadsafety
|
||||
for more information.
|
||||
"""
|
||||
|
||||
import concurrent.futures
|
||||
import os
|
||||
import time
|
||||
|
||||
import click
|
||||
|
||||
import osxphotos
|
||||
from osxphotos.cli import echo, query_command, verbose
|
||||
|
||||
|
||||
@query_command()
|
||||
@click.option(
|
||||
"--workers",
|
||||
metavar="WORKERS",
|
||||
help="Maximum number of worker threads to use for export. "
|
||||
"If not specified, it will default to the number of processors on the machine, multiplied by 5.",
|
||||
type=int,
|
||||
)
|
||||
@click.argument(
|
||||
"export_dir",
|
||||
type=click.Path(exists=True, file_okay=False, dir_okay=True, writable=True),
|
||||
)
|
||||
def export(workers, export_dir, photos: list[osxphotos.PhotoInfo], **kwargs):
|
||||
"""Export photos"""
|
||||
workers = workers or os.cpu_count() * 5
|
||||
echo(f"Exporting {len(photos)} photos to {export_dir} using {workers} workers")
|
||||
start_t = time.perf_counter()
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=workers) as executor:
|
||||
futures = [
|
||||
executor.submit(p.export, export_dir, f"{p.uuid}_{p.original_filename}")
|
||||
for p in photos
|
||||
]
|
||||
exported = []
|
||||
for future in concurrent.futures.as_completed(futures):
|
||||
exported.extend(future.result())
|
||||
end_t = time.perf_counter()
|
||||
echo(
|
||||
f"Exported {len(exported)} photos to {export_dir} in {end_t-start_t:.4f} seconds"
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
export()
|
||||
```
|
||||
|
||||
## Package Interface
|
||||
|
||||
### PhotosDB
|
||||
@@ -1115,6 +1179,15 @@ Returns True if photo is a [cloud asset](#iscloudasset) and is synched to iCloud
|
||||
|
||||
**Note**: Applies to master (original) photo only. It's possible for the master to be in iCloud but a local edited version is not yet synched to iCloud. `incloud` provides status of only the master photo. osxphotos does not yet provide a means to determine if the edited version is in iCloud. If you need this feature, please open an [issue](https://github.com/RhetTbull/osxphotos/issues).
|
||||
|
||||
#### `syndicated`
|
||||
|
||||
Return true if photo was shared via syndication (e.g. via Messages, etc.); these are photos that appear in "Shared with you" album. Photos 8+ only; returns None if not Photos 8+.
|
||||
|
||||
#### `saved_to_library`
|
||||
|
||||
Return True if syndicated photo has been saved to library; returns False if photo is not syndicated or has not been saved to the library.
|
||||
Syndicated photos are photos that appear in "Shared with you" album. Photos 8+ only; returns None if not Photos 8+.
|
||||
|
||||
#### `uti`
|
||||
|
||||
Returns Uniform Type Identifier (UTI) for the current version of the image, for example: 'public.jpeg' or 'com.apple. quicktime-movie'. If the image has been edited, `uti` will return the UTI for the edited image, otherwise it will return the UTI for the original image.
|
||||
@@ -1328,6 +1401,12 @@ Returns a unique fingerprint for the original photo file. This is a hash of the
|
||||
|
||||
Returns a unique digest of the photo's properties and metadata; useful for detecting changes in any property/metadata of the photo.
|
||||
|
||||
#### `tables()`
|
||||
|
||||
Returns a PhotoTables object which provides access to the underlying SQLite database tables for the photo.
|
||||
See [PhotoTables](#phototables) for more details. This is useful for debugging or developing new features but
|
||||
is not intended for general use.
|
||||
|
||||
#### `json()`
|
||||
|
||||
Returns a JSON representation of all photo info.
|
||||
@@ -1523,12 +1602,14 @@ Returns full name of the album owner (person who shared the album) for shared al
|
||||
|
||||
**Note**: *Only valid on Photos 5 / MacOS 10.15+; on Photos <= 4, returns None.
|
||||
|
||||
#### `asdict()`
|
||||
|
||||
Returns a dictionary representation of the AlbumInfo object.
|
||||
|
||||
### ImportInfo
|
||||
|
||||
PhotosDB.import_info returns a list of ImportInfo objects. Each ImportInfo object represents an import session in the library. PhotoInfo.import_info returns a single ImportInfo object representing the import session for the photo (or `None` if no associated import session).
|
||||
|
||||
**Note**: Photos 5+ only. Not implemented for Photos version <= 4.
|
||||
|
||||
#### `uuid`
|
||||
|
||||
Returns the universally unique identifier (uuid) of the import session. This is how Photos keeps track of individual objects within the database.
|
||||
@@ -1543,12 +1624,18 @@ Returns the creation date as a timezone aware datetime.datetime object of the im
|
||||
|
||||
#### `start_date`
|
||||
|
||||
Returns the start date as a timezone aware datetime.datetime object for when the import session bega.
|
||||
Returns the start date as a timezone aware datetime.datetime object for when the import session began.
|
||||
|
||||
#### `end_date`
|
||||
|
||||
Returns the end date as a timezone aware datetime.datetime object for when the import session completed.
|
||||
|
||||
**Note**: On Photos <=4, `start_date` and `end_date` will be the same as `creation_date`.
|
||||
|
||||
#### `asdict()`
|
||||
|
||||
Returns a dictionary representation of the import session.
|
||||
|
||||
### ProjectInfo
|
||||
|
||||
PhotosDB.projcet_info returns a list of ProjectInfo objects. Each ProjectInfo object represents a project in the library. PhotoInfo.project_info returns a list of ProjectInfo objects for each project the photo is contained in.
|
||||
@@ -1571,6 +1658,10 @@ Returns a list of [PhotoInfo](#photoinfo) objects representing each photo contai
|
||||
|
||||
Returns the creation date as a timezone aware datetime.datetime object of the project.
|
||||
|
||||
#### `asdict()`
|
||||
|
||||
Returns a dictionary representation of the ProjectInfo object.
|
||||
|
||||
### MomentInfo
|
||||
|
||||
PhotoInfo.moment_info return the MomentInfo object for the photo. The MomentInfo object contains information about the photo's moment as assigned by Photos. The MomentInfo object contains the following properties:
|
||||
@@ -1661,6 +1752,10 @@ Returns album sort order (as `AlbumSortOrder` enum). On Photos <=4, always retu
|
||||
|
||||
Returns index of photo in album (based on album sort order).
|
||||
|
||||
#### `asdict()`
|
||||
|
||||
Returns a dictionary representation of the FolderInfo object.
|
||||
|
||||
**Note**: FolderInfo and AlbumInfo objects effectively work as a linked list. The children of a folder are contained in `subfolders` and `album_info` and the parent object of both `AlbumInfo` and `FolderInfo` is represented by `parent`. For example:
|
||||
|
||||
```pycon
|
||||
@@ -2074,6 +2169,37 @@ Returns a JSON representation of the FaceInfo instance.
|
||||
* `adj_version_info`: version info for the application which made the adjustments to the photo decoded from the adjustments data.
|
||||
* `asdict()`: dict representation of the AdjustmentsInfo object; contains all properties with exception of `plist`.
|
||||
|
||||
### PhotoTables
|
||||
|
||||
[PhotoInfo.tables](#tables) returns a PhotoTables object that contains information about the tables in the Photos database that contain information about the photo.
|
||||
The following properties are available:
|
||||
|
||||
* `ZASSET`
|
||||
* `ZADDITIONALASSETATTRIBUTES`
|
||||
* `ZDETECTEDFACE`
|
||||
* `ZPERSON`
|
||||
|
||||
Each of these properties returns a `Table` object that provides access to the row(s) in the table that correspond to the photo.
|
||||
|
||||
The Table object has dynamically created properties that correspond to the associated column in the table and return a tuple of values for that column.
|
||||
|
||||
```pycon
|
||||
>>> photo.tables().ZADDITIONALASSETATTRIBUTES.ZTITLE
|
||||
("St. James's Park",)
|
||||
```
|
||||
|
||||
The Table object also provides a `rows()` method which returns a list a of tuples for the matching rows in the table
|
||||
and a `rows_dict()` method which returns a list of dicts for the matching rows in the table.
|
||||
|
||||
```pycon
|
||||
|
||||
>>> photo.tables().ZASSET.rows()
|
||||
[(6, 3, 35, 0, 0, 0, 0, 0, 0, None, None, None, None, None, 0, 0, 1, 0, 0, 0, 0, -100, 0, 1, 0, 1356, 0, 0, 0, 0, 0, 0, 0, 1, 6192599813128215, 1, 2814835671629878, 1, 0, 3, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 2047, 7, None, 8, None, None, None, None, None, None, None, None, 3, 6, 6, 6, None, 6, 4, None, None, 8, 4, None, 2, None, 3, None, 3, None, None, 585926209.859624, 596906868.198932, 689981763.374756, None, None, None, 0.5, 561129492.501, 0.0, 596906868.198932, None, 0.03816793893129771, None, 51.50357167, -0.1318055, 689982854.802854, 0.6494140625, 0.0, 561129492.501, None, None, None, None, None, None, None, 'D', 'DC99FBDD-7A52-4100-A5BB-344131646C30.jpeg', None, 'sRGB IEC61966-2.1', 'public.jpeg', 'DC99FBDD-7A52-4100-A5BB-344131646C30', b'Ki\t@\x01\x00\x00\x00\td\tH\x01\x00\x00\x00\x93\\\tL\x01\x00\x00\x00\x1aK\x0c\x03\x0c\xa8q\x92\x00\x12C\x0c\x03\x0c"\r\x90\x00\x00<\x0c\x03\x08"\x19\x80\x00', b'\xca\xebV\tu\xc0I@/j\xf7\xab\x00\xdf\xc0\xbf\xcd\xcc\xcc\xcc\xcc\xcc\x04@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')]
|
||||
|
||||
>>> photo.tables().ZASSET.rows_dict()
|
||||
[{'Z_PK': 6, 'Z_ENT': 3, 'Z_OPT': 35, 'ZACTIVELIBRARYSCOPEPARTICIPATIONSTATE': 0, 'ZAVALANCHEPICKTYPE': 0, 'ZBUNDLESCOPE': 0, 'ZCAMERAPROCESSINGADJUSTMENTSTATE': 0, 'ZCLOUDDELETESTATE': 0, 'ZCLOUDDOWNLOADREQUESTS': 0, 'ZCLOUDHASCOMMENTSBYME': None, 'ZCLOUDHASCOMMENTSCONVERSATION': None, 'ZCLOUDHASUNSEENCOMMENTS': None, 'ZCLOUDISDELETABLE': None, 'ZCLOUDISMYASSET': None, 'ZCLOUDLOCALSTATE': 0, 'ZCLOUDPLACEHOLDERKIND': 0, 'ZCOMPLETE': 1, 'ZDEFERREDPROCESSINGNEEDED': 0, 'ZDEPTHTYPE': 0, 'ZDERIVEDCAMERACAPTUREDEVICE': 0, 'ZDUPLICATEASSETVISIBILITYSTATE': 0, 'ZFACEAREAPOINTS': -100, 'ZFAVORITE': 0, 'ZHASADJUSTMENTS': 1, 'ZHDRTYPE': 0, 'ZHEIGHT': 1356, 'ZHIDDEN': 0, 'ZHIGHFRAMERATESTATE': 0, 'ZISMAGICCARPET': 0, 'ZKIND': 0, 'ZKINDSUBTYPE': 0, 'ZLIBRARYSCOPESHARESTATE': 0, 'ZMONOSKITYPE': 0, 'ZORIENTATION': 1, 'ZPACKEDACCEPTABLECROPRECT': 6192599813128215, 'ZPACKEDBADGEATTRIBUTES': 1, 'ZPACKEDPREFERREDCROPRECT': 2814835671629878, 'ZPLAYBACKSTYLE': 1, 'ZPLAYBACKVARIATION': 0, 'ZSAVEDASSETTYPE': 3, 'ZSEARCHINDEXREBUILDSTATE': 0, 'ZSYNDICATIONSTATE': 0, 'ZTHUMBNAILINDEX': 5, 'ZTRASHEDSTATE': 0, 'ZVIDEOCPDURATIONVALUE': 0, 'ZVIDEOCPVISIBILITYSTATE': 0, 'ZVIDEODEFERREDPROCESSINGNEEDED': 0, 'ZVIDEOKEYFRAMETIMESCALE': 0, 'ZVIDEOKEYFRAMEVALUE': 0, 'ZVISIBILITYSTATE': 0, 'ZWIDTH': 2047, 'ZADDITIONALATTRIBUTES': 7, 'ZCLOUDFEEDASSETSENTRY': None, 'ZCOMPUTEDATTRIBUTES': 8, 'ZCONVERSATION': None, 'ZDAYGROUPHIGHLIGHTBEINGASSETS': None, 'ZDAYGROUPHIGHLIGHTBEINGEXTENDEDASSETS': None, 'ZDAYGROUPHIGHLIGHTBEINGKEYASSETPRIVATE': None, 'ZDAYGROUPHIGHLIGHTBEINGKEYASSETSHARED': None, 'ZDAYGROUPHIGHLIGHTBEINGSUMMARYASSETS': None, 'ZDUPLICATEMETADATAMATCHINGALBUM': None, 'ZDUPLICATEPERCEPTUALMATCHINGALBUM': None, 'ZEXTENDEDATTRIBUTES': 3, 'ZHIGHLIGHTBEINGASSETS': 6, 'ZHIGHLIGHTBEINGEXTENDEDASSETS': 6, 'ZHIGHLIGHTBEINGKEYASSETPRIVATE': 6, 'ZHIGHLIGHTBEINGKEYASSETSHARED': None, 'ZHIGHLIGHTBEINGSUMMARYASSETS': 6, 'ZIMPORTSESSION': 4, 'ZLIBRARYSCOPE': None, 'ZMASTER': None, 'ZMEDIAANALYSISATTRIBUTES': 8, 'ZMOMENT': 4, 'ZMOMENTSHARE': None, 'ZMONTHHIGHLIGHTBEINGKEYASSETPRIVATE': 2, 'ZMONTHHIGHLIGHTBEINGKEYASSETSHARED': None, 'ZPHOTOANALYSISATTRIBUTES': 3, 'ZTRASHEDBYPARTICIPANT': None, 'ZYEARHIGHLIGHTBEINGKEYASSETPRIVATE': 3, 'ZYEARHIGHLIGHTBEINGKEYASSETSHARED': None, 'Z_FOK_CLOUDFEEDASSETSENTRY': None, 'ZADDEDDATE': 585926209.859624, 'ZADJUSTMENTTIMESTAMP': 596906868.198932, 'ZANALYSISSTATEMODIFICATIONDATE': 689981763.374756, 'ZCLOUDBATCHPUBLISHDATE': None, 'ZCLOUDLASTVIEWEDCOMMENTDATE': None, 'ZCLOUDSERVERPUBLISHDATE': None, 'ZCURATIONSCORE': 0.5, 'ZDATECREATED': 561129492.501, 'ZDURATION': 0.0, 'ZFACEADJUSTMENTVERSION': 596906868.198932, 'ZHDRGAIN': None, 'ZHIGHLIGHTVISIBILITYSCORE': 0.03816793893129771, 'ZLASTSHAREDDATE': None, 'ZLATITUDE': 51.50357167, 'ZLONGITUDE': -0.1318055, 'ZMODIFICATIONDATE': 689982854.802854, 'ZOVERALLAESTHETICSCORE': 0.6494140625, 'ZPROMOTIONSCORE': 0.0, 'ZSORTTOKEN': 561129492.501, 'ZTRASHEDDATE': None, 'ZAVALANCHEUUID': None, 'ZCLOUDASSETGUID': None, 'ZCLOUDBATCHID': None, 'ZCLOUDCOLLECTIONGUID': None, 'ZCLOUDOWNERHASHEDPERSONID': None, 'ZDELETEREASON': None, 'ZDIRECTORY': 'D', 'ZFILENAME': 'DC99FBDD-7A52-4100-A5BB-344131646C30.jpeg', 'ZMEDIAGROUPUUID': None, 'ZORIGINALCOLORSPACE': 'sRGB IEC61966-2.1', 'ZUNIFORMTYPEIDENTIFIER': 'public.jpeg', 'ZUUID': 'DC99FBDD-7A52-4100-A5BB-344131646C30', 'ZIMAGEREQUESTHINTS': b'Ki\t@\x01\x00\x00\x00\td\tH\x01\x00\x00\x00\x93\\\tL\x01\x00\x00\x00\x1aK\x0c\x03\x0c\xa8q\x92\x00\x12C\x0c\x03\x0c"\r\x90\x00\x00<\x0c\x03\x08"\x19\x80\x00', 'ZLOCATIONDATA': b'\xca\xebV\tu\xc0I@/j\xf7\xab\x00\xdf\xc0\xbf\xcd\xcc\xcc\xcc\xcc\xcc\x04@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'}]
|
||||
```
|
||||
|
||||
### Raw Photos
|
||||
|
||||
Handling raw photos in `osxphotos` requires a bit of extra work. Raw photos in Photos can be imported in two different ways: 1) a single raw photo with no associated JPEG image is imported 2) a raw+JPEG pair is imported -- two separate images with same file stem (e.g. `IMG_0001.CR2` and `IMG_001.JPG`) are imported.
|
||||
@@ -2373,7 +2499,7 @@ cog.out(get_template_field_table())
|
||||
|{cr}|A carriage return: '\r'|
|
||||
|{crlf}|A carriage return + line feed: '\r\n'|
|
||||
|{tab}|:A tab: '\t'|
|
||||
|{osxphotos_version}|The osxphotos version, e.g. '0.58.2'|
|
||||
|{osxphotos_version}|The osxphotos version, e.g. '0.60.7'|
|
||||
|{osxphotos_cmd_line}|The full command line used to run osxphotos|
|
||||
|{album}|Album(s) photo is contained in|
|
||||
|{folder_album}|Folder path + album photo is contained in. e.g. 'Folder/Subfolder/Album' or just 'Album' if no enclosing folder|
|
||||
|
||||
257
CHANGELOG.md
257
CHANGELOG.md
@@ -2,6 +2,242 @@
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [v0.60.6](https://github.com/RhetTbull/osxphotos/compare/v0.60.5...v0.60.6)
|
||||
|
||||
Remove --library/--db from import command
|
||||
|
||||
### [v0.60.6] - 2023-07-02
|
||||
|
||||
#### Added
|
||||
|
||||
#### Removed
|
||||
|
||||
- Removed `--library/--db` options from `osxphotos import` as import does not allow user to specify a library; the last used library is always used for import
|
||||
|
||||
#### Changed
|
||||
|
||||
#### Contributors
|
||||
|
||||
- [@RhetTbull](https://github.com/RhetTbull) - Code and documentation
|
||||
- [@msolo](https://github.com/msolo) - Bug report for `osxphotos import`
|
||||
|
||||
## [v0.60.5](https://github.com/RhetTbull/osxphotos/compare/v0.60.4...v0.60.5)
|
||||
|
||||
Unicode Fixes
|
||||
|
||||
### [v0.60.5] - 2023-06-24
|
||||
|
||||
#### Added
|
||||
|
||||
- Added `--count`to query to print count of query results and exit (#1098)
|
||||
|
||||
#### Removed
|
||||
|
||||
#### Changed
|
||||
|
||||
#### Fixed
|
||||
|
||||
- Normalize unicode for `osxphotos import` to avoid duplicate keywords and albums (#1087)
|
||||
|
||||
#### Contributors
|
||||
|
||||
- [@RhetTbull](https://github.com/RhetTbull/osxphotos) - code & testing
|
||||
- [@oPromessa](https://github.com/oPromessa) - for finding and documenting the unicode bugs
|
||||
|
||||
## [v0.60.4](https://github.com/RhetTbull/osxphotos/compare/v0.60.3...v0.60.4)
|
||||
|
||||
Updated testing / compatibility matrix to include macOS 13.4.
|
||||
|
||||
### [v0.60.4] - 2023-06-18
|
||||
|
||||
#### Fixed
|
||||
|
||||
#### Added
|
||||
|
||||
#### Removed
|
||||
|
||||
#### Changed
|
||||
|
||||
#### Contributors
|
||||
|
||||
- [@RhetTbull](https://github.com/RhetTbull/osxphotos) - code & testing
|
||||
|
||||
## [v0.60.3](https://github.com/RhetTbull/osxphotos/compare/v0.60.2...v0.60.3)
|
||||
|
||||
Ventura introduced a "shared with you" album which shows photos shared via Messages (and possible other apps). These show up in the Photos library in the
|
||||
"Shared with you" album but the images are stored in a different location that regular images so osxphotos could not previously access the images.
|
||||
It can now do so.
|
||||
|
||||
### [v0.60.3] 2023-06-18
|
||||
|
||||
#### Fixed
|
||||
|
||||
#### Added
|
||||
|
||||
- `PhotoInfo.syndicated` property to identify syndicated photos.
|
||||
- `PhotoInfo.saved_to_library` property to identify syndicated photos that have been saved to the library.
|
||||
- `--syndicated`/`--not-syndicated`, `--saved-to-library`/`--not-saved-to-library` query options.
|
||||
- `find()` function in `osxphotos repl` to search for files in the active Photos library directory.
|
||||
|
||||
#### Removed
|
||||
|
||||
#### Changed
|
||||
|
||||
#### Contributors
|
||||
|
||||
- [@RhetTbull](https://github.com/RhetTbull) for code.
|
||||
|
||||
## [v0.60.2](https://github.com/RhetTbull/osxphotos/compare/v0.60.1...v0.60.2)
|
||||
|
||||
Performance Improvements for --download-missing
|
||||
|
||||
### [v0.60.2] - 2023-06-17
|
||||
|
||||
#### Fixed
|
||||
|
||||
- Performance improvements for `osxphotos export` when used with `--download-missing` or `--sidecar XMP` options. (#1086)
|
||||
|
||||
#### Added
|
||||
|
||||
#### Changed
|
||||
|
||||
#### Contributors
|
||||
|
||||
- [@RhetTbull](https://github.com/RhetTbull) for code changes.
|
||||
- [@MaxLyt](https://github.com/MaxLyt) for finding the issue.
|
||||
|
||||
## [v0.60.1](https://github.com/RhetTbull/osxphotos/compare/v0.60.0...v0.60.1)
|
||||
|
||||
Hot fix for a bug with in-memory database and --dry-run.
|
||||
|
||||
### 14 May 2023
|
||||
|
||||
#### Fixed
|
||||
|
||||
- Fixed crash with --dry-run with large export database (#1071)
|
||||
|
||||
#### Contributors
|
||||
|
||||
- @RhetTbull for code changes.
|
||||
- @rajscode for identifying the bug and filing a detailed bug report.
|
||||
|
||||
## [v0.60.0](https://github.com/RhetTbull/osxphotos/compare/v0.59.3...v0.60.0)
|
||||
|
||||
Linux Support: adds support for using a subset of osxphotos capabilities on Linux.
|
||||
|
||||
### 07 May 2023
|
||||
|
||||
#### Added
|
||||
|
||||
- osxphotos now supports Linux (tested on Ubuntu 22.04); some commands are macOS only and will not be available (nor shown) on Linux. Huge thank you to [@dvdkon](https://github.com/dvdkon) for doing the Linux port!
|
||||
- Added `PhotoTables` API and `tables` property to `PhotoInfo` to access underlying SQL tables for a photo.
|
||||
|
||||
#### Changed
|
||||
|
||||
- Added macOS 13.3 to supported versions table.
|
||||
|
||||
#### Contributors
|
||||
|
||||
- @dvdkon for Linux port.
|
||||
- @RhetTbull for code changes.
|
||||
- @pekingduck for bug report.
|
||||
- @cclause for updating ruff test runner.
|
||||
|
||||
## [v0.59.3](https://github.com/RhetTbull/osxphotos/compare/v0.59.2...v0.59.3)
|
||||
|
||||
Bug fixes for memory leak, crash during export
|
||||
|
||||
### 10 April 2023
|
||||
|
||||
#### Fixed
|
||||
|
||||
- Fixed memory leak in export (#1047)
|
||||
- Fixed crash during export (#1046)
|
||||
- Fixed large crash log size (#1048)
|
||||
|
||||
#### Changed
|
||||
|
||||
- Added better help for no selection with --selected (#1036)
|
||||
- Changed PhotoInfo.asdict() and PhotoInfo.json() to allow deep or shallow option (#1038)
|
||||
- Updated development docs (#1043)
|
||||
|
||||
#### Contributors
|
||||
|
||||
- @RhetTbull for code changes
|
||||
- @wernerzj for finding bug with memory leak
|
||||
- @rajscode for finding export crash
|
||||
- @oPromessa for development docs fix
|
||||
|
||||
## [v0.59.2](https://github.com/RhetTbull/osxphotos/compare/v0.59.1...v0.59.2)
|
||||
|
||||
Bug Fix for Export
|
||||
|
||||
### 08 April 2023
|
||||
|
||||
#### Fixed
|
||||
|
||||
- Fixed error on export when photo belonged to a project (#999)
|
||||
- Fixed large increase in export database size (#999)
|
||||
|
||||
#### Changed
|
||||
|
||||
- Added indent, shallow args to PhotoInfo.json() (#1038)
|
||||
|
||||
#### Contributors
|
||||
|
||||
- @RhetTbull for code
|
||||
- @oPromessa for finding bugs, running tests
|
||||
|
||||
## [v0.59.1](https://github.com/RhetTbull/osxphotos/compare/v0.59.0...v0.59.1)
|
||||
|
||||
Performance Boost
|
||||
|
||||
### 2 April 2023
|
||||
|
||||
#### Changed
|
||||
|
||||
- Removed lock files from export code (speed boost for NAS export, see #999); will need to eventually add this back for multithreaded export
|
||||
- Optimized some code in export CLI to speed export
|
||||
- Some linting fixed for move to ruff
|
||||
-
|
||||
|
||||
#### Contributors
|
||||
|
||||
- [@RhetTbull](https://github.com/RhetTbull) for code changes.
|
||||
- [@cclauss](https://github.com/cclauss) for linting fixes
|
||||
|
||||
## [v0.59.0](https://github.com/RhetTbull/osxphotos/compare/v0.58.2...v0.59.0)
|
||||
|
||||
### 1 April 2023
|
||||
|
||||
#### Added
|
||||
|
||||
- `PhotoInfo.export()` and `PhotoExporter.export()` now support exporting in concurrent threads on Python 3.11+. This applies only to the API. The `osxphotos export` CLI does not yet support concurrent export. See #999.
|
||||
|
||||
See example code in [concurrent_export.py](https://github.com/RhetTbull/osxphotos/blob/main/examples/concurrent_export.py).
|
||||
|
||||
#### Contributors
|
||||
|
||||
- [@RhetTbull](https://github.com/RhetTbull) for code changes.
|
||||
- [@eecue](https://github.com/eecue) for testing and helping pinpoint the issues.
|
||||
|
||||
## [v0.58.2](https://github.com/RhetTbull/osxphotos/compare/v0.58.1...v0.58.2)
|
||||
|
||||
### 14 March 2023
|
||||
|
||||
#### Changed
|
||||
|
||||
- batch-edit no longer overwrites keywords but instead merges new keywords with existing keywords
|
||||
|
||||
#### Added
|
||||
|
||||
- added --replace-keywords flag to `osxphotos batch-edit` to force replacement of keywords
|
||||
|
||||
#### Contributors
|
||||
|
||||
- [@RhetTbull](https://github.com/RhetTbull) for code changes.
|
||||
- [@pekingduck](https://github.com/pekingduck) for pointing out the deisgn flaw in `batch-edit --keywords` logic
|
||||
|
||||
## [v0.58.1](https://github.com/RhetTbull/osxphotos/compare/v0.58.0...v0.58.1)
|
||||
|
||||
### 09 March 2023
|
||||
@@ -64,15 +300,15 @@ All notable changes to this project will be documented in this file.
|
||||
|
||||
#### Added
|
||||
|
||||
- `--migrate-photos-library` option added to `osxphotos exportdb` to migrate the export database from one Photos library to another. This is useful when moving to a new computer but maintaining the existing osxphotos export. Thanks to @swduncan for the idea. (#990)
|
||||
- `--migrate-photos-library` option added to `osxphotos exportdb` to migrate the export database from one Photos library to another. This is useful when moving to a new computer but maintaining the existing osxphotos export. Thanks to @swduncan for the idea. (#990)
|
||||
|
||||
#### Fixed
|
||||
|
||||
- Fixed a bug in `osxphotos export --cleanup` to handle files which could not be deleted. Thanks to @oPromessa for finding this and suggesting the fix. (#987)
|
||||
- Fixed a bug in `osxphotos export --cleanup` to handle files which could not be deleted. Thanks to @oPromessa for finding this and suggesting the fix. (#987)
|
||||
|
||||
#### Internal
|
||||
|
||||
- Fixed a bug that caused `rich_echo()` to not display rich text if `--verbose` wasn't specified.
|
||||
- Fixed a bug that caused `rich_echo()` to not display rich text if `--verbose` wasn't specified.
|
||||
|
||||
#### Contributors To This Release
|
||||
|
||||
@@ -80,10 +316,10 @@ All notable changes to this project will be documented in this file.
|
||||
- [@Promessa](https://github.com/promessa) who found the cleanup bug and suggested a code fix.
|
||||
- [@swduncan](https://github.com/swduncan) who suggested the library migrate use case.
|
||||
|
||||
|
||||
## [v0.57.1](https://github.com/RhetTbull/osxphotos/compare/v0.57.0...v0.57.1)
|
||||
|
||||
### 12 February 2023
|
||||
|
||||
### Added show command, bug fix, refactoring
|
||||
|
||||
A bug fix and some refactoring to prepare for adding a parallel export mode. Also added `osxphotos show` command.
|
||||
@@ -106,7 +342,6 @@ A bug fix and some refactoring to prepare for adding a parallel export mode. Als
|
||||
- [@RhetTbull](https://github.com/RhetTbull)
|
||||
- [@aa599](https://github.com/aa599) for reporting the timezone bug and suggesting change to `--uuid-from-file`
|
||||
|
||||
|
||||
## [v0.57.0](https://github.com/RhetTbull/osxphotos/compare/v0.56.7...v0.57.0)
|
||||
|
||||
### 5 February 2023
|
||||
@@ -138,7 +373,7 @@ for building simple command line tools.
|
||||
|
||||
#### Contributors
|
||||
|
||||
- @RhetTbull
|
||||
- @RhetTbull
|
||||
|
||||
## [v0.56.7](https://github.com/RhetTbull/osxphotos/compare/v0.56.6...v0.56.7)
|
||||
|
||||
@@ -165,7 +400,6 @@ for building simple command line tools.
|
||||
- @pweaver - thanks for finding the bug with `--dry-run` and `--finder-tag-keywords`
|
||||
- @eecue for providing testing data
|
||||
|
||||
|
||||
## [v0.56.6](https://github.com/RhetTbull/osxphotos/compare/v0.56.5...v0.56.6)
|
||||
|
||||
### 22 January 2023
|
||||
@@ -214,7 +448,6 @@ for building simple command line tools.
|
||||
- Thanks to @djbeadle for idea of adding SearchInfo.source
|
||||
- Thanks for @oPromessa for testing `import` speed-ups and providing test data
|
||||
|
||||
|
||||
### [v0.56.3](https://github.com/RhetTbull/osxphotos/compare/v0.56.2...v0.56.3)
|
||||
|
||||
### 16 January 2023
|
||||
@@ -251,7 +484,7 @@ for building simple command line tools.
|
||||
|
||||
#### Contributors to this release
|
||||
|
||||
- @RhetTbull - Added AI scores to `osxphotos inspect`
|
||||
- @RhetTbull - Added AI scores to `osxphotos inspect`
|
||||
- @mave2k - Documentation fixes
|
||||
- @oPromessa - Bug fix for metadata in `osxphotos import`
|
||||
|
||||
@@ -265,7 +498,6 @@ for building simple command line tools.
|
||||
|
||||
- Added new `osxphotos sync` command to sync metadata between libraries (#887)
|
||||
|
||||
|
||||
## [v0.56.0](https://github.com/RhetTbull/osxphotos/compare/v0.55.7...v0.56.0)
|
||||
|
||||
### 13 January 2023
|
||||
@@ -278,6 +510,7 @@ for building simple command line tools.
|
||||
- Added PhotoInfo.fingerprint (#900)
|
||||
|
||||
#### Changed
|
||||
|
||||
- Added --profile, --watch, --breakpoint, --debug as global options; previously these worked only with export
|
||||
|
||||
#### New Contributors
|
||||
@@ -285,6 +518,7 @@ for building simple command line tools.
|
||||
- Added @oPromessa as a contributor for code
|
||||
- Added @johnsturgeon as a contributor for bug, and doc
|
||||
- Added @qkeddy as a contributor for ideas, and data
|
||||
|
||||
## [v0.55.7](https://github.com/RhetTbull/osxphotos/compare/v0.55.6...v0.55.7)
|
||||
|
||||
### 1 January 2023
|
||||
@@ -303,6 +537,7 @@ for building simple command line tools.
|
||||
### Updates for timewarp and export when reading/writing QuickTime dates
|
||||
|
||||
#### Changed
|
||||
|
||||
- Added QuickTime:ContentCreateDate as a source for `osxphotos timewarp`
|
||||
- Write QuickTime:ContentCreateDate when exporting with --exiftool for `osxphotos export`
|
||||
|
||||
@@ -2092,7 +2327,7 @@ Thanks to @PetrochukM for identifying this and providing code!
|
||||
- doc: start with examples before the export reference [`7c7bf1b`](https://github.com/RhetTbull/osxphotos/commit/7c7bf1be6b6382a995a4e17906adfd8720d0a1c3)
|
||||
- Updated dependencies in README.md [`b1cab32`](https://github.com/RhetTbull/osxphotos/commit/b1cab32ff4c7b65ae4c9a5a9a11c175dbd487c0a)
|
||||
- remove extra spaces [`a59bb5b`](https://github.com/RhetTbull/osxphotos/commit/a59bb5b02f10fa554dae346a7271be37f50d8bcc)
|
||||
- Adding back dependency https://github.com/RhetTbull/PhotoScript) [`7c8bfc8`](https://github.com/RhetTbull/osxphotos/commit/7c8bfc811ab3a93dabadf1655f7d0e217d6c7b01)
|
||||
- Adding back dependency <https://github.com/RhetTbull/PhotoScript>) [`7c8bfc8`](https://github.com/RhetTbull/osxphotos/commit/7c8bfc811ab3a93dabadf1655f7d0e217d6c7b01)
|
||||
|
||||
## [v0.39.6](https://github.com/RhetTbull/osxphotos/compare/v0.39.5...v0.39.6)
|
||||
|
||||
|
||||
105
README.md
105
README.md
@@ -7,10 +7,10 @@
|
||||
[](https://pepy.tech/project/osxphotos)
|
||||
[](https://www.reddit.com/r/osxphotos/)
|
||||
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
||||
[](#contributors)
|
||||
[](#contributors)
|
||||
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
||||
|
||||
OSXPhotos provides the ability to interact with and query Apple's Photos.app library on macOS. You can query the Photos library database — for example, file name, file path, and metadata such as keywords/tags, persons/faces, albums, etc. You can also easily export both the original and edited photos.
|
||||
OSXPhotos provides the ability to interact with and query Apple's Photos.app library on macOS and Linux. You can query the Photos library database — for example, file name, file path, and metadata such as keywords/tags, persons/faces, albums, etc. You can also easily export both the original and edited photos.
|
||||
|
||||
<p align="center"><img src="docs/screencast/demo.gif?raw=true" width="713" height="430"/></p>
|
||||
|
||||
@@ -33,20 +33,24 @@ OSXPhotos provides the ability to interact with and query Apple's Photos.app lib
|
||||
|
||||
## Supported operating systems
|
||||
|
||||
Only works on macOS (aka Mac OS X). Tested on macOS Sierra (10.12.6) through macOS Monterey (12.0.1). Tested on both x86 and Apple silicon (M1).
|
||||
Tested on Ubuntu Linux and macOS. Many features are only available on macOS.
|
||||
|
||||
On Linux, macOS-specific features of the CLI will not be available (these will not be shown in the help output).
|
||||
The export and query CLI commands as well as the Python API will work on Linux which enables you to export photos
|
||||
from a Photos library on a Linux machine.
|
||||
|
||||
Tested on macOS Sierra (10.12.6) through macOS Ventura (13.3). Tested on both x86 and Apple silicon (M1).
|
||||
|
||||
| macOS Version | macOS name | Photos.app version |
|
||||
| ----------------- |------------|:-------------------|
|
||||
| 13.0 | Ventura | 8.0 ✅ * |
|
||||
| 12.0 - 12.6 | Monterey | 7.0 ✅ * |
|
||||
| 13.0 - 13.4 | Ventura | 8.0 ✅ |
|
||||
| 12.0 - 12.6 | Monterey | 7.0 ✅ |
|
||||
| 10.16, 11.0-11.4 | Big Sur | 6.0 ✅ |
|
||||
| 10.15.1 - 10.15.7 | Catalina | 5.0 ✅ |
|
||||
| 10.14.5, 10.14.6 | Mojave | 4.0 ✅ |
|
||||
| 10.13.6 | High Sierra| 3.0 ✅ |
|
||||
| 10.12.6 | Sierra | 2.0 ✅ |
|
||||
|
||||
\* Some features may not be fully supported on Monterey and Ventura. Notably, `--use-photokit` and `--download-missing` may or may not work depending on your configuration; this is a known issue that will be fixed if I can find a solution. Many users successfully use OSXPhotos on Monterey without problem.
|
||||
|
||||
This package will read Photos databases for any supported version on any supported macOS version. E.g. you can read a database created with Photos 5.0 on MacOS 10.15 on a machine running macOS 10.12 and vice versa.
|
||||
|
||||
Requires python >= `3.9`.
|
||||
@@ -70,6 +74,14 @@ Once you've installed osxphotos with pipx, to upgrade to the latest version:
|
||||
|
||||
pipx upgrade osxphotos
|
||||
|
||||
**Note**: When installing other packages with homebrew, homebrew may update the version of Python installed which would then cause any app (including osxphotos) installed with `pipx` to fail. If this happens, the easiest fix is to reinstall osxphotos with:
|
||||
|
||||
pipx reinstall osxphotos
|
||||
|
||||
Alternatively, you can reinstall all apps installed with `pipx` with:
|
||||
|
||||
pipx reinstall-all
|
||||
|
||||
### Installation using pip
|
||||
|
||||
You can also install directly from [pypi](https://pypi.org/project/osxphotos/):
|
||||
@@ -128,15 +140,8 @@ Usage: osxphotos [OPTIONS] COMMAND [ARGS]...
|
||||
osxphotos: the multi-tool for your Photos library
|
||||
|
||||
Options:
|
||||
-v, --version Show the version and exit.
|
||||
--library, --db PHOTOS_LIBRARY_PATH
|
||||
Specify path to Photos library. If not
|
||||
provided, will attempt to find the library to
|
||||
use in the following order: 1. last opened
|
||||
library, 2. system library, 3.
|
||||
~/Pictures/Photos Library.photoslibrary
|
||||
--json Print output in JSON format.
|
||||
-h, --help Show this message and exit.
|
||||
-v, --version Show the version and exit.
|
||||
-h, --help Show this message and exit.
|
||||
|
||||
Commands:
|
||||
about Print information about osxphotos including license.
|
||||
@@ -865,6 +870,16 @@ Options:
|
||||
been synched)
|
||||
--not-incloud Search for photos that are not in iCloud (have
|
||||
not been synched)
|
||||
--syndicated Search for photos that have been shared via
|
||||
syndication ('Shared with You' album via
|
||||
Messages, etc.)
|
||||
--not-syndicated Search for photos that have not been shared
|
||||
via syndication ('Shared with You' album via
|
||||
Messages, etc.)
|
||||
--saved-to-library Search for syndicated photos that have saved
|
||||
to the library
|
||||
--not-saved-to-library Search for syndicated photos that have not
|
||||
saved to the library
|
||||
--regex REGEX TEMPLATE Search for photos where TEMPLATE matches
|
||||
regular expression REGEX. For example, to find
|
||||
photos in an album that begins with 'Beach': '
|
||||
@@ -1051,6 +1066,14 @@ Options:
|
||||
export all burst images; only the primary
|
||||
photo will be exported--associated burst
|
||||
images will be skipped.
|
||||
--export-aae Also export an adjustments file detailing
|
||||
edits made to the original. The resulting file
|
||||
is named photoname.AAE. Note that to import
|
||||
these files back to Photos succesfully, you
|
||||
also need to export the edited photo and match
|
||||
the filename format Photos.app expects:
|
||||
--filename 'IMG_{edited_version?E,}{id:04d}'
|
||||
--edited-suffix ''
|
||||
--sidecar FORMAT Create sidecar for each photo exported; valid
|
||||
FORMAT values: xmp, json, exiftool; --sidecar
|
||||
xmp: create XMP sidecar used by Digikam, Adobe
|
||||
@@ -1440,22 +1463,23 @@ option to re-export the entire library thus rebuilding the
|
||||
|
||||
Extended Attributes
|
||||
|
||||
Some options (currently '--finder-tag-template', '--finder-tag-keywords',
|
||||
'-xattr-template') write additional metadata accessible by Spotlight to
|
||||
facilitate searching. For example, --finder-tag-keyword writes all keywords
|
||||
(including any specified by '--keyword-template' or other options) to Finder
|
||||
tags that are searchable in Spotlight using the syntax: 'tag:tagname'. For
|
||||
example, if you have images with keyword "Travel" then using '--finder-tag-
|
||||
keywords' you could quickly find those images in the Finder by typing
|
||||
'tag:Travel' in the Spotlight search bar. Finder tags are written to the
|
||||
'com.apple.metadata:_kMDItemUserTags' extended attribute. Unlike EXIF
|
||||
metadata, extended attributes do not modify the actual file; the metadata is
|
||||
written to extended attributes associated with the file and the Spotlight
|
||||
metadata database. Most cloud storage services do not synch extended
|
||||
attributes. Dropbox does sync them and any changes to a file's extended
|
||||
attributes will cause Dropbox to re-sync the files.
|
||||
Some options (currently '--finder-tag-template', '--finder-tag-keywords',
|
||||
'-xattr-template') write additional metadata accessible by Spotlight
|
||||
to facilitate searching. For example, --finder-tag-keyword writes all
|
||||
keywords (including any specified by '--keyword-template' or other
|
||||
options) to Finder tags that are searchable in Spotlight using the syntax:
|
||||
'tag:tagname'. For example, if you have images with keyword "Travel"
|
||||
then using '--finder-tag-keywords' you could quickly find those images
|
||||
in the Finder by typing 'tag:Travel' in the Spotlight search bar.
|
||||
Finder tags are written to the 'com.apple.metadata:_kMDItemUserTags'
|
||||
extended attribute. Unlike EXIF metadata, extended attributes do not
|
||||
modify the actual file; the metadata is written to extended attributes
|
||||
associated with the file and the Spotlight metadata database. Most
|
||||
cloud storage services do not synch extended attributes. Dropbox does
|
||||
sync them and any changes to a file's extended attributes will cause
|
||||
Dropbox to re-sync the files.
|
||||
|
||||
The following attributes may be used with '--xattr-template':
|
||||
The following attributes may be used with '--xattr-template':
|
||||
|
||||
|
||||
Attribute Description
|
||||
@@ -2094,7 +2118,7 @@ Substitution Description
|
||||
{cr} A carriage return: '\r'
|
||||
{crlf} A carriage return + line feed: '\r\n'
|
||||
{tab} :A tab: '\t'
|
||||
{osxphotos_version} The osxphotos version, e.g. '0.58.2'
|
||||
{osxphotos_version} The osxphotos version, e.g. '0.60.7'
|
||||
{osxphotos_cmd_line} The full command line used to run osxphotos
|
||||
|
||||
The following substitutions may result in multiple values. Thus if specified
|
||||
@@ -2581,7 +2605,7 @@ The following template field substitutions are availabe for use the templating s
|
||||
|{cr}|A carriage return: '\r'|
|
||||
|{crlf}|A carriage return + line feed: '\r\n'|
|
||||
|{tab}|:A tab: '\t'|
|
||||
|{osxphotos_version}|The osxphotos version, e.g. '0.58.2'|
|
||||
|{osxphotos_version}|The osxphotos version, e.g. '0.60.7'|
|
||||
|{osxphotos_cmd_line}|The full command line used to run osxphotos|
|
||||
|{album}|Album(s) photo is contained in|
|
||||
|{folder_album}|Folder path + album photo is contained in. e.g. 'Folder/Subfolder/Album' or just 'Album' if no enclosing folder|
|
||||
@@ -2621,7 +2645,7 @@ I'll gladly consider pull requests for bug fixes or feature implementations.
|
||||
|
||||
If you have an interesting example that shows usage of this package, submit an issue or pull request and i'll include it or link to it.
|
||||
|
||||
Testing against "real world" Photos libraries would be especially helpful. If you discover issues in testing against your Photos libraries, please open an issue. I've done extensive testing against my own Photos library but that's a since data point and I'm certain there are issues lurking in various edge cases I haven't discovered yet.
|
||||
Testing against "real world" Photos libraries would be especially helpful. If you discover issues in testing against your Photos libraries, please open an issue. I've done extensive testing against my own Photos library but that's a single data point and I'm certain there are issues lurking in various edge cases I haven't discovered yet.
|
||||
|
||||
### Contributors ✨
|
||||
|
||||
@@ -2665,7 +2689,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/mkirkland4874"><img src="https://avatars.githubusercontent.com/u/36466711?v=4?s=75" width="75px;" alt="mkirkland4874"/><br /><sub><b>mkirkland4874</b></sub></a><br /><a href="https://github.com/RhetTbull/osxphotos/issues?q=author%3Amkirkland4874" title="Bug reports">🐛</a> <a href="#example-mkirkland4874" title="Examples">💡</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/jcommisso07"><img src="https://avatars.githubusercontent.com/u/3111054?v=4?s=75" width="75px;" alt="Joseph Commisso"/><br /><sub><b>Joseph Commisso</b></sub></a><br /><a href="#data-jcommisso07" title="Data">🔣</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/dssinger"><img src="https://avatars.githubusercontent.com/u/1817903?v=4?s=75" width="75px;" alt="David Singer"/><br /><sub><b>David Singer</b></sub></a><br /><a href="https://github.com/RhetTbull/osxphotos/issues?q=author%3Adssinger" title="Bug reports">🐛</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/oPromessa"><img src="https://avatars.githubusercontent.com/u/21261491?v=4?s=75" width="75px;" alt="oPromessa"/><br /><sub><b>oPromessa</b></sub></a><br /><a href="https://github.com/RhetTbull/osxphotos/issues?q=author%3AoPromessa" title="Bug reports">🐛</a> <a href="#ideas-oPromessa" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/RhetTbull/osxphotos/commits?author=oPromessa" title="Tests">⚠️</a> <a href="https://github.com/RhetTbull/osxphotos/commits?author=oPromessa" title="Code">💻</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/oPromessa"><img src="https://avatars.githubusercontent.com/u/21261491?v=4?s=75" width="75px;" alt="oPromessa"/><br /><sub><b>oPromessa</b></sub></a><br /><a href="https://github.com/RhetTbull/osxphotos/issues?q=author%3AoPromessa" title="Bug reports">🐛</a> <a href="#ideas-oPromessa" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/RhetTbull/osxphotos/commits?author=oPromessa" title="Tests">⚠️</a> <a href="https://github.com/RhetTbull/osxphotos/commits?author=oPromessa" title="Code">💻</a> <a href="https://github.com/RhetTbull/osxphotos/commits?author=oPromessa" title="Documentation">📖</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="http://spencerchang.me"><img src="https://avatars.githubusercontent.com/u/14796580?v=4?s=75" width="75px;" alt="Spencer Chang"/><br /><sub><b>Spencer Chang</b></sub></a><br /><a href="https://github.com/RhetTbull/osxphotos/issues?q=author%3Aspencerc99" title="Bug reports">🐛</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -2701,7 +2725,16 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/aa599"><img src="https://avatars.githubusercontent.com/u/37746269?v=4?s=75" width="75px;" alt="aa599"/><br /><sub><b>aa599</b></sub></a><br /><a href="https://github.com/RhetTbull/osxphotos/issues?q=author%3Aaa599" title="Bug reports">🐛</a> <a href="#ideas-aa599" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/swduncan"><img src="https://avatars.githubusercontent.com/u/2053195?v=4?s=75" width="75px;" alt="Steve Duncan"/><br /><sub><b>Steve Duncan</b></sub></a><br /><a href="#ideas-swduncan" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="http://www.projany.com"><img src="https://avatars.githubusercontent.com/u/15144745?v=4?s=75" width="75px;" alt="Ian Moir"/><br /><sub><b>Ian Moir</b></sub></a><br /><a href="https://github.com/RhetTbull/osxphotos/issues?q=author%3Aianmmoir" title="Bug reports">🐛</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/pekingduck"><img src="https://avatars.githubusercontent.com/u/2597142?v=4?s=75" width="75px;" alt="Peking Duck"/><br /><sub><b>Peking Duck</b></sub></a><br /><a href="#ideas-pekingduck" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/pekingduck"><img src="https://avatars.githubusercontent.com/u/2597142?v=4?s=75" width="75px;" alt="Peking Duck"/><br /><sub><b>Peking Duck</b></sub></a><br /><a href="#ideas-pekingduck" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/RhetTbull/osxphotos/issues?q=author%3Apekingduck" title="Bug reports">🐛</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://www.patreon.com/cclauss"><img src="https://avatars.githubusercontent.com/u/3709715?v=4?s=75" width="75px;" alt="Christian Clauss"/><br /><sub><b>Christian Clauss</b></sub></a><br /><a href="https://github.com/RhetTbull/osxphotos/commits?author=cclauss" title="Code">💻</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/dvdkon"><img src="https://avatars.githubusercontent.com/u/3526303?v=4?s=75" width="75px;" alt="dvdkon"/><br /><sub><b>dvdkon</b></sub></a><br /><a href="https://github.com/RhetTbull/osxphotos/commits?author=dvdkon" title="Code">💻</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/wernerzj"><img src="https://avatars.githubusercontent.com/u/130370930?v=4?s=75" width="75px;" alt="wernerzj"/><br /><sub><b>wernerzj</b></sub></a><br /><a href="https://github.com/RhetTbull/osxphotos/issues?q=author%3Awernerzj" title="Bug reports">🐛</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/rajscode"><img src="https://avatars.githubusercontent.com/u/99123253?v=4?s=75" width="75px;" alt="rajscode"/><br /><sub><b>rajscode</b></sub></a><br /><a href="https://github.com/RhetTbull/osxphotos/issues?q=author%3Arajscode" title="Bug reports">🐛</a> <a href="https://github.com/RhetTbull/osxphotos/commits?author=rajscode" title="Documentation">📖</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/MaxLyt"><img src="https://avatars.githubusercontent.com/u/136200430?v=4?s=75" width="75px;" alt="MaxLyt"/><br /><sub><b>MaxLyt</b></sub></a><br /><a href="https://github.com/RhetTbull/osxphotos/issues?q=author%3AMaxLyt" title="Bug reports">🐛</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ces3001"><img src="https://avatars.githubusercontent.com/u/23762610?v=4?s=75" width="75px;" alt="ces3001"/><br /><sub><b>ces3001</b></sub></a><br /><a href="https://github.com/RhetTbull/osxphotos/issues?q=author%3Aces3001" title="Bug reports">🐛</a></td>
|
||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/msolo"><img src="https://avatars.githubusercontent.com/u/5078276?v=4?s=75" width="75px;" alt="msolo"/><br /><sub><b>msolo</b></sub></a><br /><a href="https://github.com/RhetTbull/osxphotos/issues?q=author%3Amsolo" title="Bug reports">🐛</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -7,7 +7,7 @@ These are notes for developers working on osxphotos. They're mostly to help me r
|
||||
- Clone the repo: `git clone git@github.com:RhetTbull/osxphotos.git`
|
||||
- Create a virtual environment and activate it: `python3 -m venv venv` then `source venv/bin/activate`. I use [pyenv](https://github.com/pyenv/pyenv) with [pyenv-virtualenv](https://github.com/pyenv/pyenv-virtualenv) to manage my virtual environments
|
||||
- Install the requirements: `pip install -r requirements.txt`
|
||||
- Install the development requirements: `pip install -r requirements-dev.txt`
|
||||
- Install the development requirements: `pip install -r dev_requirements.txt`
|
||||
- Install osxphotos: `pip install -e .`
|
||||
|
||||
## Running tests
|
||||
|
||||
@@ -2,7 +2,7 @@ build
|
||||
bump2version==1.0.1
|
||||
cogapp>=3.3.0,<4.0.0
|
||||
furo
|
||||
m2r2==0.3.3
|
||||
m2r2==0.3.3.post2
|
||||
pdbpp
|
||||
pyinstaller==5.6.2
|
||||
pytest-cov==4.0.0
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Sphinx build info version 1
|
||||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
|
||||
config: dd34c3ea1cc9003033a129207a3fd912
|
||||
config: b4797f5f0cba9ef01218a6f2b8eb0959
|
||||
tags: 645f666f9bcd5a90fca523b33c5a78b7
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta name="color-scheme" content="light dark"><link rel="index" title="Index" href="../genindex.html" /><link rel="search" title="Search" href="../search.html" />
|
||||
|
||||
<meta name="generator" content="sphinx-5.3.0, furo 2022.09.29"/>
|
||||
<title>Overview: module code - osxphotos 0.58.2 documentation</title>
|
||||
<title>Overview: module code - osxphotos 0.60.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../_static/styles/furo.css?digest=d81277517bee4d6b0349d71bb2661d4890b5617c" />
|
||||
<link rel="stylesheet" type="text/css" href="../_static/copybutton.css" />
|
||||
@@ -123,7 +123,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="../index.html"><div class="brand">osxphotos 0.58.2 documentation</div></a>
|
||||
<a href="../index.html"><div class="brand">osxphotos 0.60.7 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -146,7 +146,7 @@
|
||||
<div class="sidebar-sticky"><a class="sidebar-brand" href="../index.html">
|
||||
|
||||
|
||||
<span class="sidebar-brand-text">osxphotos 0.58.2 documentation</span>
|
||||
<span class="sidebar-brand-text">osxphotos 0.60.7 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="../search.html" role="search">
|
||||
<input class="sidebar-search" placeholder=Search name="q" aria-label="Search">
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta name="color-scheme" content="light dark"><link rel="index" title="Index" href="../../genindex.html" /><link rel="search" title="Search" href="../../search.html" />
|
||||
|
||||
<meta name="generator" content="sphinx-5.3.0, furo 2022.09.29"/>
|
||||
<title>osxphotos._constants - osxphotos 0.58.1 documentation</title>
|
||||
<title>osxphotos._constants - osxphotos 0.60.5 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/styles/furo.css?digest=d81277517bee4d6b0349d71bb2661d4890b5617c" />
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/copybutton.css" />
|
||||
@@ -123,7 +123,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="../../index.html"><div class="brand">osxphotos 0.58.1 documentation</div></a>
|
||||
<a href="../../index.html"><div class="brand">osxphotos 0.60.5 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -146,7 +146,7 @@
|
||||
<div class="sidebar-sticky"><a class="sidebar-brand" href="../../index.html">
|
||||
|
||||
|
||||
<span class="sidebar-brand-text">osxphotos 0.58.1 documentation</span>
|
||||
<span class="sidebar-brand-text">osxphotos 0.60.5 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="../../search.html" role="search">
|
||||
<input class="sidebar-search" placeholder=Search name="q" aria-label="Search">
|
||||
@@ -199,10 +199,14 @@
|
||||
|
||||
<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">annotations</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">logging</span>
|
||||
<span class="kn">import</span> <span class="nn">os.path</span>
|
||||
<span class="kn">import</span> <span class="nn">sqlite3</span>
|
||||
<span class="kn">from</span> <span class="nn">datetime</span> <span class="kn">import</span> <span class="n">datetime</span>
|
||||
<span class="kn">from</span> <span class="nn">enum</span> <span class="kn">import</span> <span class="n">Enum</span>
|
||||
|
||||
<span class="n">logger</span><span class="p">:</span> <span class="n">logging</span><span class="o">.</span><span class="n">Logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s2">"osxphotos"</span><span class="p">)</span>
|
||||
|
||||
<span class="n">APP_NAME</span> <span class="o">=</span> <span class="s2">"osxphotos"</span>
|
||||
|
||||
<span class="n">OSXPHOTOS_URL</span> <span class="o">=</span> <span class="s2">"https://github.com/RhetTbull/osxphotos"</span>
|
||||
@@ -211,9 +215,6 @@
|
||||
<span class="c1"># Apple Epoch is Jan 1, 2001</span>
|
||||
<span class="n">TIME_DELTA</span> <span class="o">=</span> <span class="p">(</span><span class="n">datetime</span><span class="p">(</span><span class="mi">2001</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="o">-</span> <span class="n">datetime</span><span class="p">(</span><span class="mi">1970</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span><span class="o">.</span><span class="n">total_seconds</span><span class="p">()</span>
|
||||
|
||||
<span class="c1"># Unicode format to use for comparing strings</span>
|
||||
<span class="n">UNICODE_FORMAT</span> <span class="o">=</span> <span class="s2">"NFC"</span>
|
||||
|
||||
<span class="c1"># which Photos library database versions have been tested</span>
|
||||
<span class="c1"># Photos 2.0 (10.12.6) == 2622</span>
|
||||
<span class="c1"># Photos 3.0 (10.13.6) == 3301</span>
|
||||
@@ -321,6 +322,8 @@
|
||||
<span class="p">(</span><span class="s2">"13"</span><span class="p">,</span> <span class="s2">"0"</span><span class="p">),</span>
|
||||
<span class="p">(</span><span class="s2">"13"</span><span class="p">,</span> <span class="s2">"1"</span><span class="p">),</span>
|
||||
<span class="p">(</span><span class="s2">"13"</span><span class="p">,</span> <span class="s2">"2"</span><span class="p">),</span>
|
||||
<span class="p">(</span><span class="s2">"13"</span><span class="p">,</span> <span class="s2">"3"</span><span class="p">),</span>
|
||||
<span class="p">(</span><span class="s2">"13"</span><span class="p">,</span> <span class="s2">"4"</span><span class="p">),</span>
|
||||
<span class="p">]</span>
|
||||
|
||||
<span class="c1"># Photos 5 has persons who are empty string if unidentified face</span>
|
||||
@@ -661,6 +664,15 @@
|
||||
<span class="n">UUID_PATTERN</span> <span class="o">=</span> <span class="p">(</span>
|
||||
<span class="sa">r</span><span class="s2">"[0-9a-fA-F]</span><span class="si">{8}</span><span class="s2">-[0-9a-fA-F]</span><span class="si">{4}</span><span class="s2">-[0-9a-fA-F]</span><span class="si">{4}</span><span class="s2">-[0-9a-fA-F]</span><span class="si">{4}</span><span class="s2">-[0-9a-fA-F]</span><span class="si">{12}</span><span class="s2">"</span>
|
||||
<span class="p">)</span>
|
||||
<span class="c1"># Reference: https://docs.python.org/3/library/sqlite3.html?highlight=sqlite3%20threadsafety#sqlite3.threadsafety</span>
|
||||
<span class="c1"># and https://docs.python.org/3/library/sqlite3.html?highlight=sqlite3%20threadsafety#sqlite3.connect</span>
|
||||
<span class="c1"># 3: serialized mode; Threads may share the module, connections and cursors</span>
|
||||
<span class="c1"># 3 is the default in the python.org python 3.11 distribution</span>
|
||||
<span class="c1"># earlier versions of python.org python 3.x default to 1 which means threads may not share</span>
|
||||
<span class="c1"># sqlite3 connections and thus PhotoInfo.export() cannot be used in a multithreaded environment</span>
|
||||
<span class="c1"># pass SQLITE_CHECK_SAME_THREAD to sqlite3.connect() to enable multithreaded access on systems that support it</span>
|
||||
<span class="n">SQLITE_CHECK_SAME_THREAD</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">sqlite3</span><span class="o">.</span><span class="n">threadsafety</span> <span class="o">==</span> <span class="mi">3</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">SQLITE_CHECK_SAME_THREAD</span><span class="si">=}</span><span class="s2">, </span><span class="si">{</span><span class="n">sqlite3</span><span class="o">.</span><span class="n">threadsafety</span><span class="si">=}</span><span class="s2">"</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta name="color-scheme" content="light dark"><link rel="index" title="Index" href="../../genindex.html" /><link rel="search" title="Search" href="../../search.html" />
|
||||
|
||||
<meta name="generator" content="sphinx-5.3.0, furo 2022.09.29"/>
|
||||
<title>osxphotos.albuminfo - osxphotos 0.58.1 documentation</title>
|
||||
<title>osxphotos.albuminfo - osxphotos 0.59.2 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/styles/furo.css?digest=d81277517bee4d6b0349d71bb2661d4890b5617c" />
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/copybutton.css" />
|
||||
@@ -123,7 +123,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="../../index.html"><div class="brand">osxphotos 0.58.1 documentation</div></a>
|
||||
<a href="../../index.html"><div class="brand">osxphotos 0.59.2 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -146,7 +146,7 @@
|
||||
<div class="sidebar-sticky"><a class="sidebar-brand" href="../../index.html">
|
||||
|
||||
|
||||
<span class="sidebar-brand-text">osxphotos 0.58.1 documentation</span>
|
||||
<span class="sidebar-brand-text">osxphotos 0.59.2 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="../../search.html" role="search">
|
||||
<input class="sidebar-search" placeholder=Search name="q" aria-label="Search">
|
||||
@@ -215,6 +215,7 @@
|
||||
<span class="n">_PHOTOS_4_VERSION</span><span class="p">,</span>
|
||||
<span class="n">_PHOTOS_5_ALBUM_KIND</span><span class="p">,</span>
|
||||
<span class="n">_PHOTOS_5_FOLDER_KIND</span><span class="p">,</span>
|
||||
<span class="n">_PHOTOS_5_VERSION</span><span class="p">,</span>
|
||||
<span class="n">TIME_DELTA</span><span class="p">,</span>
|
||||
<span class="n">AlbumSortOrder</span><span class="p">,</span>
|
||||
<span class="p">)</span>
|
||||
@@ -246,9 +247,8 @@
|
||||
<span class="sd"> ValueError: raised if len(values) != len(sort_keys)</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">values</span><span class="p">)</span> <span class="o">!=</span> <span class="nb">len</span><span class="p">(</span><span class="n">sort_keys</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"values and sort_keys must have same length"</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="o">*</span><span class="nb">sorted</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">sort_keys</span><span class="p">,</span> <span class="n">values</span><span class="p">))))[</span><span class="mi">1</span><span class="p">]</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"values and sort_keys must be same length"</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="n">x</span> <span class="k">for</span> <span class="n">_</span><span class="p">,</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">sort_keys</span><span class="p">,</span> <span class="n">values</span><span class="p">))]</span>
|
||||
|
||||
|
||||
<span class="k">class</span> <span class="nc">AlbumInfoBaseClass</span><span class="p">:</span>
|
||||
@@ -258,7 +258,7 @@
|
||||
<span class="sd"> including folders, photos, etc.</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">db</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">uuid</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">db</span><span class="p">,</span> <span class="n">uuid</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_uuid</span> <span class="o">=</span> <span class="n">uuid</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_db</span> <span class="o">=</span> <span class="n">db</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_title</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_dbalbum_details</span><span class="p">[</span><span class="n">uuid</span><span class="p">][</span><span class="s2">"title"</span><span class="p">]</span>
|
||||
@@ -318,7 +318,8 @@
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">end_date</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""For Albums, return end date (most recent image) of album or None for albums with no images</span>
|
||||
<span class="sd"> For Import Sessions, return end date of import sessions (when import was completed)"""</span>
|
||||
<span class="sd"> For Import Sessions, return end date of import sessions (when import was completed)</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_end_date</span>
|
||||
<span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
|
||||
@@ -360,6 +361,16 @@
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_owner</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_owner</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">asdict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""Return album info as a dict; does not include photos"""</span>
|
||||
<span class="k">return</span> <span class="p">{</span>
|
||||
<span class="s2">"uuid"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">uuid</span><span class="p">,</span>
|
||||
<span class="s2">"creation_date"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">creation_date</span><span class="p">,</span>
|
||||
<span class="s2">"start_date"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">start_date</span><span class="p">,</span>
|
||||
<span class="s2">"end_date"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">end_date</span><span class="p">,</span>
|
||||
<span class="s2">"owner"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">owner</span><span class="p">,</span>
|
||||
<span class="p">}</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__len__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""return number of photos contained in album"""</span>
|
||||
<span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">photos</span><span class="p">)</span>
|
||||
@@ -371,6 +382,10 @@
|
||||
<span class="sd"> including folders, photos, etc.</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">db</span><span class="p">,</span> <span class="n">uuid</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">db</span><span class="o">=</span><span class="n">db</span><span class="p">,</span> <span class="n">uuid</span><span class="o">=</span><span class="n">uuid</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_title</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_dbalbum_details</span><span class="p">[</span><span class="n">uuid</span><span class="p">][</span><span class="s2">"title"</span><span class="p">]</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">title</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""return title / name of album"""</span>
|
||||
@@ -402,10 +417,11 @@
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">folder_names</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""return hierarchical list of folders the album is contained in</span>
|
||||
<span class="sd">"""Return hierarchical list of folders the album is contained in</span>
|
||||
<span class="sd"> the folder list is in form:</span>
|
||||
<span class="sd"> ["Top level folder", "sub folder 1", "sub folder 2", ...]</span>
|
||||
<span class="sd"> returns empty list if album is not in any folders"""</span>
|
||||
<span class="sd"> or empty list if album is not in any folders</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_folder_names</span>
|
||||
@@ -415,10 +431,9 @@
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">folder_list</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""return hierarchical list of folders the album is contained in</span>
|
||||
<span class="sd"> as list of FolderInfo objects in form</span>
|
||||
<span class="sd"> ["Top level folder", "sub folder 1", "sub folder 2", ...]</span>
|
||||
<span class="sd"> returns empty list if album is not in any folders"""</span>
|
||||
<span class="sd">"""Returns list of FolderInfo objects for each folder the album is contained in</span>
|
||||
<span class="sd"> or empty list if album is not in any folders</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_folders</span>
|
||||
@@ -443,7 +458,7 @@
|
||||
<span class="n">parent_pk</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_dbalbum_details</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_uuid</span><span class="p">][</span><span class="s2">"parentfolder"</span><span class="p">]</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_parent</span> <span class="o">=</span> <span class="p">(</span>
|
||||
<span class="n">FolderInfo</span><span class="p">(</span><span class="n">db</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="p">,</span> <span class="n">uuid</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_dbalbums_pk</span><span class="p">[</span><span class="n">parent_pk</span><span class="p">])</span>
|
||||
<span class="k">if</span> <span class="n">parent_pk</span> <span class="o">!=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_folder_root_pk</span>
|
||||
<span class="k">if</span> <span class="n">parent_pk</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="n">parent_pk</span> <span class="o">!=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_folder_root_pk</span>
|
||||
<span class="k">else</span> <span class="kc">None</span>
|
||||
<span class="p">)</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parent</span>
|
||||
@@ -476,29 +491,81 @@
|
||||
<span class="k">return</span> <span class="n">index</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
|
||||
<span class="sa">f</span><span class="s2">"Photo with uuid </span><span class="si">{</span><span class="n">photo</span><span class="o">.</span><span class="n">uuid</span><span class="si">}</span><span class="s2"> does not appear to be in this album"</span>
|
||||
<span class="p">)</span></div></div>
|
||||
<span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="AlbumInfo.asdict"><a class="viewcode-back" href="../../reference.html#osxphotos.AlbumInfo.asdict">[docs]</a> <span class="k">def</span> <span class="nf">asdict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""Return album info as a dict; does not include photos"""</span>
|
||||
<span class="n">dict_data</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">asdict</span><span class="p">()</span>
|
||||
<span class="n">dict_data</span><span class="p">[</span><span class="s2">"title"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">title</span>
|
||||
<span class="n">dict_data</span><span class="p">[</span><span class="s2">"folder_names"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">folder_names</span>
|
||||
<span class="n">dict_data</span><span class="p">[</span><span class="s2">"folder_list"</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="n">f</span><span class="o">.</span><span class="n">uuid</span> <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">folder_list</span><span class="p">]</span>
|
||||
<span class="n">dict_data</span><span class="p">[</span><span class="s2">"sort_order"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sort_order</span>
|
||||
<span class="n">dict_data</span><span class="p">[</span><span class="s2">"parent"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">parent</span><span class="o">.</span><span class="n">uuid</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">parent</span> <span class="k">else</span> <span class="kc">None</span>
|
||||
<span class="k">return</span> <span class="n">dict_data</span></div></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="ImportInfo"><a class="viewcode-back" href="../../reference.html#osxphotos.ImportInfo">[docs]</a><span class="k">class</span> <span class="nc">ImportInfo</span><span class="p">(</span><span class="n">AlbumInfoBaseClass</span><span class="p">):</span>
|
||||
<span class="sd">"""Information about import sessions"""</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">db</span><span class="p">,</span> <span class="n">uuid</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_uuid</span> <span class="o">=</span> <span class="n">uuid</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_db</span> <span class="o">=</span> <span class="n">db</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_db_version</span> <span class="o">>=</span> <span class="n">_PHOTOS_5_VERSION</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">db</span><span class="o">=</span><span class="n">db</span><span class="p">,</span> <span class="n">uuid</span><span class="o">=</span><span class="n">uuid</span><span class="p">)</span>
|
||||
|
||||
<span class="n">import_session</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_db_import_group</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_uuid</span><span class="p">]</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_creation_date_timestamp</span> <span class="o">=</span> <span class="n">import_session</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span>
|
||||
<span class="k">except</span> <span class="p">(</span><span class="ne">ValueError</span><span class="p">,</span> <span class="ne">TypeError</span><span class="p">,</span> <span class="ne">KeyError</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_creation_date_timestamp</span> <span class="o">=</span> <span class="n">datetime</span><span class="p">(</span><span class="mi">1970</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_start_date_timestamp</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_creation_date_timestamp</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_end_date_timestamp</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_creation_date_timestamp</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_title</span> <span class="o">=</span> <span class="n">import_session</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_local_tz</span> <span class="o">=</span> <span class="n">get_local_tz</span><span class="p">(</span>
|
||||
<span class="n">datetime</span><span class="o">.</span><span class="n">fromtimestamp</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_creation_date_timestamp</span> <span class="o">+</span> <span class="n">TIME_DELTA</span><span class="p">)</span>
|
||||
<span class="p">)</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">title</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""return title / name of import session"""</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_title</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">photos</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""return list of photos contained in import session"""</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_photos</span>
|
||||
<span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
|
||||
<span class="n">uuid_list</span><span class="p">,</span> <span class="n">sort_order</span> <span class="o">=</span> <span class="nb">zip</span><span class="p">(</span>
|
||||
<span class="o">*</span><span class="p">[</span>
|
||||
<span class="p">(</span><span class="n">uuid</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_dbphotos</span><span class="p">[</span><span class="n">uuid</span><span class="p">][</span><span class="s2">"fok_import_session"</span><span class="p">])</span>
|
||||
<span class="k">for</span> <span class="n">uuid</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_dbphotos</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_dbphotos</span><span class="p">[</span><span class="n">uuid</span><span class="p">][</span><span class="s2">"import_uuid"</span><span class="p">]</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">uuid</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_db_version</span> <span class="o">>=</span> <span class="n">_PHOTOS_5_VERSION</span><span class="p">:</span>
|
||||
<span class="n">uuid_list</span><span class="p">,</span> <span class="n">sort_order</span> <span class="o">=</span> <span class="nb">zip</span><span class="p">(</span>
|
||||
<span class="o">*</span><span class="p">[</span>
|
||||
<span class="p">(</span><span class="n">uuid</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_dbphotos</span><span class="p">[</span><span class="n">uuid</span><span class="p">][</span><span class="s2">"fok_import_session"</span><span class="p">])</span>
|
||||
<span class="k">for</span> <span class="n">uuid</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_dbphotos</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_dbphotos</span><span class="p">[</span><span class="n">uuid</span><span class="p">][</span><span class="s2">"import_uuid"</span><span class="p">]</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">uuid</span>
|
||||
<span class="p">]</span>
|
||||
<span class="p">)</span>
|
||||
<span class="n">sorted_uuid</span> <span class="o">=</span> <span class="n">sort_list_by_keys</span><span class="p">(</span><span class="n">uuid_list</span><span class="p">,</span> <span class="n">sort_order</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_photos</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">photos_by_uuid</span><span class="p">(</span><span class="n">sorted_uuid</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">import_photo_uuids</span> <span class="o">=</span> <span class="p">[</span>
|
||||
<span class="n">u</span>
|
||||
<span class="k">for</span> <span class="n">u</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_dbphotos</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_dbphotos</span><span class="p">[</span><span class="n">u</span><span class="p">][</span><span class="s2">"import_uuid"</span><span class="p">]</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">uuid</span>
|
||||
<span class="p">]</span>
|
||||
<span class="p">)</span>
|
||||
<span class="n">sorted_uuid</span> <span class="o">=</span> <span class="n">sort_list_by_keys</span><span class="p">(</span><span class="n">uuid_list</span><span class="p">,</span> <span class="n">sort_order</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_photos</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">photos_by_uuid</span><span class="p">(</span><span class="n">sorted_uuid</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_photos</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">photos_by_uuid</span><span class="p">(</span><span class="n">import_photo_uuids</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_photos</span>
|
||||
|
||||
<div class="viewcode-block" id="ImportInfo.asdict"><a class="viewcode-back" href="../../reference.html#osxphotos.ImportInfo.asdict">[docs]</a> <span class="k">def</span> <span class="nf">asdict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""Return import info as a dict; does not include photos"""</span>
|
||||
<span class="k">return</span> <span class="p">{</span>
|
||||
<span class="s2">"uuid"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">uuid</span><span class="p">,</span>
|
||||
<span class="s2">"creation_date"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">creation_date</span><span class="p">,</span>
|
||||
<span class="s2">"start_date"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">start_date</span><span class="p">,</span>
|
||||
<span class="s2">"end_date"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">end_date</span><span class="p">,</span>
|
||||
<span class="s2">"title"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">title</span><span class="p">,</span>
|
||||
<span class="p">}</span></div>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__bool__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""Always returns True</span>
|
||||
<span class="sd"> A photo without an import session will return None for import_info,</span>
|
||||
@@ -506,13 +573,32 @@
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">return</span> <span class="kc">True</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="ProjectInfo"><a class="viewcode-back" href="../../reference.html#osxphotos.ProjectInfo">[docs]</a><span class="k">class</span> <span class="nc">ProjectInfo</span><span class="p">(</span><span class="n">AlbumInfo</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> ProjectInfo with info about projects</span>
|
||||
<span class="sd"> Projects are cards, calendars, slideshows, etc.</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="o">...</span></div>
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">folder_names</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""Return hierarchical list of folders the album is contained in</span>
|
||||
<span class="sd"> the folder list is in form:</span>
|
||||
<span class="sd"> ["Top level folder", "sub folder 1", "sub folder 2", ...]</span>
|
||||
<span class="sd"> or empty list if album is not in any folders</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="c1"># projects are not in folders</span>
|
||||
<span class="k">return</span> <span class="p">[]</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">folder_list</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""Returns list of FolderInfo objects for each folder the album is contained in</span>
|
||||
<span class="sd"> or empty list if album is not in any folders</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="c1"># projects are not in folders</span>
|
||||
<span class="k">return</span> <span class="p">[]</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="FolderInfo"><a class="viewcode-back" href="../../reference.html#osxphotos.FolderInfo">[docs]</a><span class="k">class</span> <span class="nc">FolderInfo</span><span class="p">:</span>
|
||||
@@ -583,7 +669,7 @@
|
||||
<span class="n">parent_pk</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_dbalbum_details</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_uuid</span><span class="p">][</span><span class="s2">"parentfolder"</span><span class="p">]</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_parent</span> <span class="o">=</span> <span class="p">(</span>
|
||||
<span class="n">FolderInfo</span><span class="p">(</span><span class="n">db</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="p">,</span> <span class="n">uuid</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_dbalbums_pk</span><span class="p">[</span><span class="n">parent_pk</span><span class="p">])</span>
|
||||
<span class="k">if</span> <span class="n">parent_pk</span> <span class="o">!=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_folder_root_pk</span>
|
||||
<span class="k">if</span> <span class="n">parent_pk</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="n">parent_pk</span> <span class="o">!=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_folder_root_pk</span>
|
||||
<span class="k">else</span> <span class="kc">None</span>
|
||||
<span class="p">)</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parent</span>
|
||||
@@ -613,6 +699,16 @@
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_folders</span> <span class="o">=</span> <span class="n">folders</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_folders</span>
|
||||
|
||||
<div class="viewcode-block" id="FolderInfo.asdict"><a class="viewcode-back" href="../../reference.html#osxphotos.FolderInfo.asdict">[docs]</a> <span class="k">def</span> <span class="nf">asdict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""Return folder info as a dict"""</span>
|
||||
<span class="k">return</span> <span class="p">{</span>
|
||||
<span class="s2">"title"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">title</span><span class="p">,</span>
|
||||
<span class="s2">"uuid"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">uuid</span><span class="p">,</span>
|
||||
<span class="s2">"parent"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">parent</span><span class="o">.</span><span class="n">uuid</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">parent</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span>
|
||||
<span class="s2">"subfolders"</span><span class="p">:</span> <span class="p">[</span><span class="n">f</span><span class="o">.</span><span class="n">uuid</span> <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">subfolders</span><span class="p">],</span>
|
||||
<span class="s2">"albums"</span><span class="p">:</span> <span class="p">[</span><span class="n">a</span><span class="o">.</span><span class="n">uuid</span> <span class="k">for</span> <span class="n">a</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">album_info</span><span class="p">],</span>
|
||||
<span class="p">}</span></div>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__len__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""returns count of folders + albums contained in the folder"""</span>
|
||||
<span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">subfolders</span><span class="p">)</span> <span class="o">+</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">album_info</span><span class="p">)</span></div>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta name="color-scheme" content="light dark"><link rel="index" title="Index" href="../../genindex.html" /><link rel="search" title="Search" href="../../search.html" />
|
||||
|
||||
<meta name="generator" content="sphinx-5.3.0, furo 2022.09.29"/>
|
||||
<title>osxphotos.exiftool - osxphotos 0.58.1 documentation</title>
|
||||
<title>osxphotos.exiftool - osxphotos 0.59.1 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/styles/furo.css?digest=d81277517bee4d6b0349d71bb2661d4890b5617c" />
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/copybutton.css" />
|
||||
@@ -123,7 +123,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="../../index.html"><div class="brand">osxphotos 0.58.1 documentation</div></a>
|
||||
<a href="../../index.html"><div class="brand">osxphotos 0.59.1 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -146,7 +146,7 @@
|
||||
<div class="sidebar-sticky"><a class="sidebar-brand" href="../../index.html">
|
||||
|
||||
|
||||
<span class="sidebar-brand-text">osxphotos 0.58.1 documentation</span>
|
||||
<span class="sidebar-brand-text">osxphotos 0.59.1 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="../../search.html" role="search">
|
||||
<input class="sidebar-search" placeholder=Search name="q" aria-label="Search">
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,7 @@
|
||||
<meta name="color-scheme" content="light dark"><link rel="index" title="Index" href="../../genindex.html" /><link rel="search" title="Search" href="../../search.html" />
|
||||
|
||||
<meta name="generator" content="sphinx-5.3.0, furo 2022.09.29"/>
|
||||
<title>osxphotos.fileutil - osxphotos 0.58.1 documentation</title>
|
||||
<title>osxphotos.fileutil - osxphotos 0.60.5 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/styles/furo.css?digest=d81277517bee4d6b0349d71bb2661d4890b5617c" />
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/copybutton.css" />
|
||||
@@ -123,7 +123,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="../../index.html"><div class="brand">osxphotos 0.58.1 documentation</div></a>
|
||||
<a href="../../index.html"><div class="brand">osxphotos 0.60.5 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -146,7 +146,7 @@
|
||||
<div class="sidebar-sticky"><a class="sidebar-brand" href="../../index.html">
|
||||
|
||||
|
||||
<span class="sidebar-brand-text">osxphotos 0.58.1 documentation</span>
|
||||
<span class="sidebar-brand-text">osxphotos 0.60.5 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="../../search.html" role="search">
|
||||
<input class="sidebar-search" placeholder=Search name="q" aria-label="Search">
|
||||
@@ -206,9 +206,12 @@
|
||||
<span class="kn">from</span> <span class="nn">abc</span> <span class="kn">import</span> <span class="n">ABC</span><span class="p">,</span> <span class="n">abstractmethod</span>
|
||||
<span class="kn">from</span> <span class="nn">tempfile</span> <span class="kn">import</span> <span class="n">TemporaryDirectory</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">Foundation</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">.imageconverter</span> <span class="kn">import</span> <span class="n">ImageConverter</span>
|
||||
<span class="kn">from</span> <span class="nn">.platform</span> <span class="kn">import</span> <span class="n">is_macos</span>
|
||||
<span class="kn">from</span> <span class="nn">.unicode</span> <span class="kn">import</span> <span class="n">normalize_fs_path</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">is_macos</span><span class="p">:</span>
|
||||
<span class="kn">import</span> <span class="nn">Foundation</span>
|
||||
|
||||
<span class="n">__all__</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"FileUtilABC"</span><span class="p">,</span> <span class="s2">"FileUtilMacOS"</span><span class="p">,</span> <span class="s2">"FileUtilShUtil"</span><span class="p">,</span> <span class="s2">"FileUtil"</span><span class="p">,</span> <span class="s2">"FileUtilNoOp"</span><span class="p">]</span>
|
||||
|
||||
@@ -287,6 +290,9 @@
|
||||
<span class="k">if</span> <span class="n">src</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="n">dest</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"src and dest must not be None"</span><span class="p">,</span> <span class="n">src</span><span class="p">,</span> <span class="n">dest</span><span class="p">)</span>
|
||||
|
||||
<span class="n">src</span> <span class="o">=</span> <span class="n">normalize_fs_path</span><span class="p">(</span><span class="n">src</span><span class="p">)</span>
|
||||
<span class="n">dest</span> <span class="o">=</span> <span class="n">normalize_fs_path</span><span class="p">(</span><span class="n">dest</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">src</span><span class="p">):</span>
|
||||
<span class="k">raise</span> <span class="ne">FileNotFoundError</span><span class="p">(</span><span class="s2">"src file does not appear to exist"</span><span class="p">,</span> <span class="n">src</span><span class="p">)</span>
|
||||
|
||||
@@ -312,6 +318,9 @@
|
||||
<span class="sd"> OSError if copy fails</span>
|
||||
<span class="sd"> TypeError if either path is None</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">src</span> <span class="o">=</span> <span class="n">normalize_fs_path</span><span class="p">(</span><span class="n">src</span><span class="p">)</span>
|
||||
<span class="n">dest</span> <span class="o">=</span> <span class="n">normalize_fs_path</span><span class="p">(</span><span class="n">dest</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">src</span><span class="p">,</span> <span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">):</span>
|
||||
<span class="n">src</span> <span class="o">=</span> <span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">(</span><span class="n">src</span><span class="p">)</span>
|
||||
|
||||
@@ -332,6 +341,7 @@
|
||||
<span class="nd">@classmethod</span>
|
||||
<span class="k">def</span> <span class="nf">unlink</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">filepath</span><span class="p">):</span>
|
||||
<span class="sd">"""unlink filepath; if it's pathlib.Path, use Path.unlink, otherwise use os.unlink"""</span>
|
||||
<span class="n">filepath</span> <span class="o">=</span> <span class="n">normalize_fs_path</span><span class="p">(</span><span class="n">filepath</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">filepath</span><span class="p">,</span> <span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">):</span>
|
||||
<span class="n">filepath</span><span class="o">.</span><span class="n">unlink</span><span class="p">()</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
@@ -340,6 +350,7 @@
|
||||
<span class="nd">@classmethod</span>
|
||||
<span class="k">def</span> <span class="nf">rmdir</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">dirpath</span><span class="p">):</span>
|
||||
<span class="sd">"""remove directory filepath; dirpath must be empty"""</span>
|
||||
<span class="n">dirpath</span> <span class="o">=</span> <span class="n">normalize_fs_path</span><span class="p">(</span><span class="n">dirpath</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dirpath</span><span class="p">,</span> <span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">):</span>
|
||||
<span class="n">dirpath</span><span class="o">.</span><span class="n">rmdir</span><span class="p">()</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
@@ -348,6 +359,7 @@
|
||||
<span class="nd">@classmethod</span>
|
||||
<span class="k">def</span> <span class="nf">utime</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">path</span><span class="p">,</span> <span class="n">times</span><span class="p">):</span>
|
||||
<span class="sd">"""Set the access and modified time of path."""</span>
|
||||
<span class="n">path</span> <span class="o">=</span> <span class="n">normalize_fs_path</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">utime</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">times</span><span class="o">=</span><span class="n">times</span><span class="p">)</span>
|
||||
|
||||
<span class="nd">@classmethod</span>
|
||||
@@ -363,6 +375,9 @@
|
||||
<span class="sd"> Does not do a byte-by-byte comparison.</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="n">f1</span> <span class="o">=</span> <span class="n">normalize_fs_path</span><span class="p">(</span><span class="n">f1</span><span class="p">)</span>
|
||||
<span class="n">f2</span> <span class="o">=</span> <span class="n">normalize_fs_path</span><span class="p">(</span><span class="n">f2</span><span class="p">)</span>
|
||||
|
||||
<span class="n">s1</span> <span class="o">=</span> <span class="bp">cls</span><span class="o">.</span><span class="n">_sig</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">stat</span><span class="p">(</span><span class="n">f1</span><span class="p">))</span>
|
||||
<span class="k">if</span> <span class="n">mtime1</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">s1</span> <span class="o">=</span> <span class="p">(</span><span class="n">s1</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">s1</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="nb">int</span><span class="p">(</span><span class="n">mtime1</span><span class="p">))</span>
|
||||
@@ -385,6 +400,7 @@
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">s2</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="kc">False</span>
|
||||
|
||||
<span class="n">f1</span> <span class="o">=</span> <span class="n">normalize_fs_path</span><span class="p">(</span><span class="n">f1</span><span class="p">)</span>
|
||||
<span class="n">s1</span> <span class="o">=</span> <span class="bp">cls</span><span class="o">.</span><span class="n">_sig</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">stat</span><span class="p">(</span><span class="n">f1</span><span class="p">))</span>
|
||||
<span class="k">if</span> <span class="n">s1</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">!=</span> <span class="n">stat</span><span class="o">.</span><span class="n">S_IFREG</span> <span class="ow">or</span> <span class="n">s2</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">!=</span> <span class="n">stat</span><span class="o">.</span><span class="n">S_IFREG</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="kc">False</span>
|
||||
@@ -393,6 +409,7 @@
|
||||
<span class="nd">@classmethod</span>
|
||||
<span class="k">def</span> <span class="nf">file_sig</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">f1</span><span class="p">):</span>
|
||||
<span class="sd">"""return os.stat signature for file f1 as tuple of (mode, size, mtime)"""</span>
|
||||
<span class="n">f1</span> <span class="o">=</span> <span class="n">normalize_fs_path</span><span class="p">(</span><span class="n">f1</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="bp">cls</span><span class="o">.</span><span class="n">_sig</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">stat</span><span class="p">(</span><span class="n">f1</span><span class="p">))</span>
|
||||
|
||||
<span class="nd">@classmethod</span>
|
||||
@@ -407,6 +424,8 @@
|
||||
<span class="sd"> Returns:</span>
|
||||
<span class="sd"> True if success, otherwise False</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">src_file</span> <span class="o">=</span> <span class="n">normalize_fs_path</span><span class="p">(</span><span class="n">src_file</span><span class="p">)</span>
|
||||
<span class="n">dest_file</span> <span class="o">=</span> <span class="n">normalize_fs_path</span><span class="p">(</span><span class="n">dest_file</span><span class="p">)</span>
|
||||
<span class="n">converter</span> <span class="o">=</span> <span class="n">ImageConverter</span><span class="p">()</span>
|
||||
<span class="k">return</span> <span class="n">converter</span><span class="o">.</span><span class="n">write_jpeg</span><span class="p">(</span>
|
||||
<span class="n">src_file</span><span class="p">,</span> <span class="n">dest_file</span><span class="p">,</span> <span class="n">compression_quality</span><span class="o">=</span><span class="n">compression_quality</span>
|
||||
@@ -424,6 +443,8 @@
|
||||
<span class="sd"> Name of renamed file (dest)</span>
|
||||
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">src</span> <span class="o">=</span> <span class="n">normalize_fs_path</span><span class="p">(</span><span class="n">src</span><span class="p">)</span>
|
||||
<span class="n">dest</span> <span class="o">=</span> <span class="n">normalize_fs_path</span><span class="p">(</span><span class="n">dest</span><span class="p">)</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">rename</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">src</span><span class="p">),</span> <span class="nb">str</span><span class="p">(</span><span class="n">dest</span><span class="p">))</span>
|
||||
<span class="k">return</span> <span class="n">dest</span>
|
||||
|
||||
@@ -468,6 +489,9 @@
|
||||
<span class="sd"> OSError if copy fails</span>
|
||||
<span class="sd"> TypeError if either path is None</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">src</span> <span class="o">=</span> <span class="n">normalize_fs_path</span><span class="p">(</span><span class="n">src</span><span class="p">)</span>
|
||||
<span class="n">dest</span> <span class="o">=</span> <span class="n">normalize_fs_path</span><span class="p">(</span><span class="n">dest</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">src</span><span class="p">,</span> <span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">):</span>
|
||||
<span class="n">src</span> <span class="o">=</span> <span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">(</span><span class="n">src</span><span class="p">)</span>
|
||||
|
||||
@@ -485,7 +509,7 @@
|
||||
<span class="k">return</span> <span class="kc">True</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="FileUtil"><a class="viewcode-back" href="../../reference.html#osxphotos.FileUtil">[docs]</a><span class="k">class</span> <span class="nc">FileUtil</span><span class="p">(</span><span class="n">FileUtilMacOS</span><span class="p">):</span>
|
||||
<div class="viewcode-block" id="FileUtil"><a class="viewcode-back" href="../../reference.html#osxphotos.FileUtil">[docs]</a><span class="k">class</span> <span class="nc">FileUtil</span><span class="p">(</span><span class="n">FileUtilShUtil</span><span class="p">):</span>
|
||||
<span class="sd">"""Various file utilities"""</span>
|
||||
|
||||
<span class="k">pass</span></div>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta name="color-scheme" content="light dark"><link rel="index" title="Index" href="../../genindex.html" /><link rel="search" title="Search" href="../../search.html" />
|
||||
|
||||
<meta name="generator" content="sphinx-5.3.0, furo 2022.09.29"/>
|
||||
<title>osxphotos.photoexporter - osxphotos 0.58.1 documentation</title>
|
||||
<title>osxphotos.photoexporter - osxphotos 0.60.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/styles/furo.css?digest=d81277517bee4d6b0349d71bb2661d4890b5617c" />
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/copybutton.css" />
|
||||
@@ -123,7 +123,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="../../index.html"><div class="brand">osxphotos 0.58.1 documentation</div></a>
|
||||
<a href="../../index.html"><div class="brand">osxphotos 0.60.7 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -146,7 +146,7 @@
|
||||
<div class="sidebar-sticky"><a class="sidebar-brand" href="../../index.html">
|
||||
|
||||
|
||||
<span class="sidebar-brand-text">osxphotos 0.58.1 documentation</span>
|
||||
<span class="sidebar-brand-text">osxphotos 0.60.7 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="../../search.html" role="search">
|
||||
<input class="sidebar-search" placeholder=Search name="q" aria-label="Search">
|
||||
@@ -198,6 +198,8 @@
|
||||
<span></span><span class="sd">""" PhotoExport class to export photos</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">annotations</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">dataclasses</span>
|
||||
<span class="kn">import</span> <span class="nn">json</span>
|
||||
<span class="kn">import</span> <span class="nn">logging</span>
|
||||
@@ -205,12 +207,11 @@
|
||||
<span class="kn">import</span> <span class="nn">pathlib</span>
|
||||
<span class="kn">import</span> <span class="nn">re</span>
|
||||
<span class="kn">import</span> <span class="nn">typing</span> <span class="k">as</span> <span class="nn">t</span>
|
||||
<span class="kn">from</span> <span class="nn">collections</span> <span class="kn">import</span> <span class="n">namedtuple</span> <span class="c1"># pylint: disable=syntax-error</span>
|
||||
<span class="kn">from</span> <span class="nn">dataclasses</span> <span class="kn">import</span> <span class="n">asdict</span><span class="p">,</span> <span class="n">dataclass</span>
|
||||
<span class="kn">from</span> <span class="nn">datetime</span> <span class="kn">import</span> <span class="n">datetime</span>
|
||||
<span class="kn">from</span> <span class="nn">enum</span> <span class="kn">import</span> <span class="n">Enum</span>
|
||||
<span class="kn">from</span> <span class="nn">types</span> <span class="kn">import</span> <span class="n">SimpleNamespace</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">photoscript</span>
|
||||
<span class="kn">from</span> <span class="nn">mako.template</span> <span class="kn">import</span> <span class="n">Template</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">._constants</span> <span class="kn">import</span> <span class="p">(</span>
|
||||
@@ -228,18 +229,13 @@
|
||||
<span class="p">)</span>
|
||||
<span class="kn">from</span> <span class="nn">._version</span> <span class="kn">import</span> <span class="n">__version__</span>
|
||||
<span class="kn">from</span> <span class="nn">.datetime_utils</span> <span class="kn">import</span> <span class="n">datetime_tz_to_utc</span>
|
||||
<span class="kn">from</span> <span class="nn">.exiftool</span> <span class="kn">import</span> <span class="n">ExifTool</span><span class="p">,</span> <span class="n">exiftool_can_write</span>
|
||||
<span class="kn">from</span> <span class="nn">.exiftool</span> <span class="kn">import</span> <span class="n">ExifTool</span><span class="p">,</span> <span class="n">ExifToolCaching</span><span class="p">,</span> <span class="n">exiftool_can_write</span><span class="p">,</span> <span class="n">get_exiftool_path</span>
|
||||
<span class="kn">from</span> <span class="nn">.export_db</span> <span class="kn">import</span> <span class="n">ExportDB</span><span class="p">,</span> <span class="n">ExportDBTemp</span>
|
||||
<span class="kn">from</span> <span class="nn">.fileutil</span> <span class="kn">import</span> <span class="n">FileUtil</span>
|
||||
<span class="kn">from</span> <span class="nn">.photokit</span> <span class="kn">import</span> <span class="p">(</span>
|
||||
<span class="n">PHOTOS_VERSION_CURRENT</span><span class="p">,</span>
|
||||
<span class="n">PHOTOS_VERSION_ORIGINAL</span><span class="p">,</span>
|
||||
<span class="n">PHOTOS_VERSION_UNADJUSTED</span><span class="p">,</span>
|
||||
<span class="n">PhotoKitFetchFailed</span><span class="p">,</span>
|
||||
<span class="n">PhotoLibrary</span><span class="p">,</span>
|
||||
<span class="p">)</span>
|
||||
<span class="kn">from</span> <span class="nn">.phototemplate</span> <span class="kn">import</span> <span class="n">RenderOptions</span>
|
||||
<span class="kn">from</span> <span class="nn">.platform</span> <span class="kn">import</span> <span class="n">is_macos</span>
|
||||
<span class="kn">from</span> <span class="nn">.rich_utils</span> <span class="kn">import</span> <span class="n">add_rich_markup_tag</span>
|
||||
<span class="kn">from</span> <span class="nn">.unicode</span> <span class="kn">import</span> <span class="n">normalize_fs_path</span>
|
||||
<span class="kn">from</span> <span class="nn">.uti</span> <span class="kn">import</span> <span class="n">get_preferred_uti_extension</span>
|
||||
<span class="kn">from</span> <span class="nn">.utils</span> <span class="kn">import</span> <span class="p">(</span>
|
||||
<span class="n">hexdigest</span><span class="p">,</span>
|
||||
@@ -251,6 +247,18 @@
|
||||
<span class="n">unlock_filename</span><span class="p">,</span>
|
||||
<span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">is_macos</span><span class="p">:</span>
|
||||
<span class="kn">import</span> <span class="nn">photoscript</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">.photokit</span> <span class="kn">import</span> <span class="p">(</span>
|
||||
<span class="n">PHOTOS_VERSION_CURRENT</span><span class="p">,</span>
|
||||
<span class="n">PHOTOS_VERSION_ORIGINAL</span><span class="p">,</span>
|
||||
<span class="n">PHOTOS_VERSION_UNADJUSTED</span><span class="p">,</span>
|
||||
<span class="n">PhotoKitFetchFailed</span><span class="p">,</span>
|
||||
<span class="n">PhotoLibrary</span><span class="p">,</span>
|
||||
<span class="p">)</span>
|
||||
|
||||
|
||||
<span class="n">__all__</span> <span class="o">=</span> <span class="p">[</span>
|
||||
<span class="s2">"ExportError"</span><span class="p">,</span>
|
||||
<span class="s2">"ExportOptions"</span><span class="p">,</span>
|
||||
@@ -265,6 +273,11 @@
|
||||
<span class="c1"># retry if download_missing/use_photos_export fails the first time (which sometimes it does)</span>
|
||||
<span class="n">MAX_PHOTOSCRIPT_RETRIES</span> <span class="o">=</span> <span class="mi">3</span>
|
||||
|
||||
<span class="c1"># Global to hold the compiled XMP template</span>
|
||||
<span class="c1"># This is expensive to compile so we only want to do it once</span>
|
||||
<span class="n">_global_xmp_template</span><span class="p">:</span> <span class="n">Template</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
|
||||
|
||||
<span class="c1"># return values for _should_update_photo</span>
|
||||
<span class="k">class</span> <span class="nc">ShouldUpdate</span><span class="p">(</span><span class="n">Enum</span><span class="p">):</span>
|
||||
<span class="n">NOT_IN_DATABASE</span> <span class="o">=</span> <span class="mi">1</span>
|
||||
@@ -319,6 +332,7 @@
|
||||
<span class="sd"> render_options (RenderOptions): t.Optional osxphotos.phototemplate.RenderOptions instance to specify options for rendering templates</span>
|
||||
<span class="sd"> replace_keywords (bool): if True, keyword_template replaces any keywords, otherwise it's additive</span>
|
||||
<span class="sd"> rich (bool): if True, will use rich markup with verbose output</span>
|
||||
<span class="sd"> export_aae (bool): if True, also exports adjustments as .AAE file</span>
|
||||
<span class="sd"> sidecar_drop_ext (bool, default=False): if True, drops the photo's extension from sidecar filename (e.g. 'IMG_1234.json' instead of 'IMG_1234.JPG.json')</span>
|
||||
<span class="sd"> sidecar: bit field (int): set to one or more of `SIDECAR_XMP`, `SIDECAR_JSON`, `SIDECAR_EXIFTOOL`</span>
|
||||
<span class="sd"> - SIDECAR_JSON: if set will write a json sidecar with data in format readable by exiftool sidecar filename will be dest/filename.json;</span>
|
||||
@@ -371,6 +385,7 @@
|
||||
<span class="n">render_options</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">RenderOptions</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="n">replace_keywords</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
|
||||
<span class="n">rich</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
|
||||
<span class="n">export_aae</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
|
||||
<span class="n">sidecar_drop_ext</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
|
||||
<span class="n">sidecar</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
<span class="n">strip</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
|
||||
@@ -432,6 +447,9 @@
|
||||
<span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">asdict</span><span class="p">())</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="sa">f</span><span class="s2">"StagedFiles(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">asdict</span><span class="p">()</span><span class="si">}</span><span class="s2">)"</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">asdict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="p">{</span>
|
||||
<span class="s2">"original"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">original</span><span class="p">,</span>
|
||||
@@ -462,6 +480,7 @@
|
||||
<span class="s2">"missing"</span><span class="p">,</span>
|
||||
<span class="s2">"missing_album"</span><span class="p">,</span>
|
||||
<span class="s2">"new"</span><span class="p">,</span>
|
||||
<span class="s2">"aae_written"</span><span class="p">,</span>
|
||||
<span class="s2">"sidecar_exiftool_skipped"</span><span class="p">,</span>
|
||||
<span class="s2">"sidecar_exiftool_written"</span><span class="p">,</span>
|
||||
<span class="s2">"sidecar_json_skipped"</span><span class="p">,</span>
|
||||
@@ -492,6 +511,7 @@
|
||||
<span class="n">missing</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
|
||||
<span class="n">missing_album</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
|
||||
<span class="n">new</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
|
||||
<span class="n">aae_written</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
|
||||
<span class="n">sidecar_exiftool_skipped</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
|
||||
<span class="n">sidecar_exiftool_written</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
|
||||
<span class="n">sidecar_json_skipped</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
|
||||
@@ -506,7 +526,6 @@
|
||||
<span class="n">xattr_skipped</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
|
||||
<span class="n">xattr_written</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
|
||||
<span class="p">):</span>
|
||||
|
||||
<span class="n">local_vars</span> <span class="o">=</span> <span class="nb">locals</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_datetime</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()</span><span class="o">.</span><span class="n">isoformat</span><span class="p">()</span>
|
||||
<span class="k">for</span> <span class="n">attr</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">attributes</span><span class="p">:</span>
|
||||
@@ -532,6 +551,7 @@
|
||||
<span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">exif_updated</span>
|
||||
<span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">touched</span>
|
||||
<span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">converted_to_jpeg</span>
|
||||
<span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">aae_written</span>
|
||||
<span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">sidecar_json_written</span>
|
||||
<span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">sidecar_json_skipped</span>
|
||||
<span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">sidecar_exiftool_written</span>
|
||||
@@ -571,7 +591,7 @@
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">photo</span><span class="p">:</span> <span class="s2">"PhotoInfo"</span><span class="p">,</span> <span class="n">tmpdir</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">photo</span> <span class="o">=</span> <span class="n">photo</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_render_options</span> <span class="o">=</span> <span class="n">RenderOptions</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_verbose</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">photo</span><span class="o">.</span><span class="n">_verbose</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_verbose</span> <span class="o">=</span> <span class="n">photo</span><span class="o">.</span><span class="n">_verbose</span>
|
||||
|
||||
<span class="c1"># define functions for adding markup</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_filepath</span> <span class="o">=</span> <span class="n">add_rich_markup_tag</span><span class="p">(</span><span class="s2">"filepath"</span><span class="p">,</span> <span class="n">rich</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
|
||||
@@ -668,6 +688,11 @@
|
||||
<span class="n">dest</span><span class="p">,</span> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_should_convert_to_jpeg</span><span class="p">(</span><span class="n">dest</span><span class="p">,</span> <span class="n">options</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># stage files for export by finding path in local library or downloading from iCloud as appropriate</span>
|
||||
<span class="c1"># for `--download-missing` and `--update` case, this may cause unnecessary downloads</span>
|
||||
<span class="c1"># as it will download the file even if it's not needed (won't be checked until the _should_update_photo() call from _export_photo()</span>
|
||||
<span class="c1"># fixing this will require major refactoring of the export code, see #1086</span>
|
||||
<span class="c1"># leaving it for now as this should not be a common use case</span>
|
||||
<span class="c1"># (if using `--update` it is much better to be using "Download originals to this Mac" in Photos)</span>
|
||||
<span class="n">staged_files</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_stage_photos_for_export</span><span class="p">(</span><span class="n">options</span><span class="p">)</span>
|
||||
<span class="n">src</span> <span class="o">=</span> <span class="n">staged_files</span><span class="o">.</span><span class="n">edited</span> <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">edited</span> <span class="k">else</span> <span class="n">staged_files</span><span class="o">.</span><span class="n">original</span>
|
||||
|
||||
@@ -782,6 +807,8 @@
|
||||
<span class="sa">f</span><span class="s2">"Skipping missing preview photo for </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_filename</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">photo</span><span class="o">.</span><span class="n">original_filename</span><span class="p">)</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_uuid</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">photo</span><span class="o">.</span><span class="n">uuid</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span>
|
||||
<span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">export_aae</span><span class="p">:</span>
|
||||
<span class="n">all_results</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_write_aae_file</span><span class="p">(</span><span class="n">dest</span><span class="o">=</span><span class="n">dest</span><span class="p">,</span> <span class="n">options</span><span class="o">=</span><span class="n">options</span><span class="p">)</span>
|
||||
<span class="n">all_results</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_write_sidecar_files</span><span class="p">(</span><span class="n">dest</span><span class="o">=</span><span class="n">dest</span><span class="p">,</span> <span class="n">options</span><span class="o">=</span><span class="n">options</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">all_results</span></div>
|
||||
@@ -854,8 +881,16 @@
|
||||
<span class="k">return</span> <span class="n">lock_filename</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span> <span class="k">if</span> <span class="n">lock</span> <span class="k">else</span> <span class="n">filename</span>
|
||||
|
||||
<span class="c1"># if overwrite==False and #increment==False, export should fail if file exists</span>
|
||||
<span class="k">if</span> <span class="n">dest</span><span class="o">.</span><span class="n">exists</span><span class="p">()</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">any</span><span class="p">(</span>
|
||||
<span class="p">[</span><span class="n">options</span><span class="o">.</span><span class="n">increment</span><span class="p">,</span> <span class="n">options</span><span class="o">.</span><span class="n">update</span><span class="p">,</span> <span class="n">options</span><span class="o">.</span><span class="n">force_update</span><span class="p">,</span> <span class="n">options</span><span class="o">.</span><span class="n">overwrite</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="p">(</span>
|
||||
<span class="ow">not</span> <span class="nb">any</span><span class="p">(</span>
|
||||
<span class="p">[</span>
|
||||
<span class="n">options</span><span class="o">.</span><span class="n">increment</span><span class="p">,</span>
|
||||
<span class="n">options</span><span class="o">.</span><span class="n">update</span><span class="p">,</span>
|
||||
<span class="n">options</span><span class="o">.</span><span class="n">force_update</span><span class="p">,</span>
|
||||
<span class="n">options</span><span class="o">.</span><span class="n">overwrite</span><span class="p">,</span>
|
||||
<span class="p">]</span>
|
||||
<span class="p">)</span>
|
||||
<span class="ow">and</span> <span class="n">dest</span><span class="o">.</span><span class="n">exists</span><span class="p">()</span>
|
||||
<span class="p">):</span>
|
||||
<span class="k">raise</span> <span class="ne">FileExistsError</span><span class="p">(</span>
|
||||
<span class="sa">f</span><span class="s2">"destination exists (</span><span class="si">{</span><span class="n">dest</span><span class="si">}</span><span class="s2">); overwrite=</span><span class="si">{</span><span class="n">options</span><span class="o">.</span><span class="n">overwrite</span><span class="si">}</span><span class="s2">, increment=</span><span class="si">{</span><span class="n">options</span><span class="o">.</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span>
|
||||
@@ -914,9 +949,18 @@
|
||||
<span class="k">return</span> <span class="n">dest</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_should_update_photo</span><span class="p">(</span>
|
||||
<span class="bp">self</span><span class="p">,</span> <span class="n">src</span><span class="p">:</span> <span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">,</span> <span class="n">dest</span><span class="p">:</span> <span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">,</span> <span class="n">options</span><span class="p">:</span> <span class="n">ExportOptions</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Literal</span><span class="p">[</span><span class="kc">True</span><span class="p">,</span> <span class="kc">False</span><span class="p">]:</span>
|
||||
<span class="sd">"""Return True if photo should be updated, else False"""</span>
|
||||
<span class="bp">self</span><span class="p">,</span> <span class="n">src</span><span class="p">:</span> <span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span> <span class="o">|</span> <span class="kc">None</span><span class="p">,</span> <span class="n">dest</span><span class="p">:</span> <span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">,</span> <span class="n">options</span><span class="p">:</span> <span class="n">ExportOptions</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span> <span class="o">|</span> <span class="n">ShouldUpdate</span><span class="p">:</span>
|
||||
<span class="sd">"""Return True if photo should be updated, else False</span>
|
||||
|
||||
<span class="sd"> Args:</span>
|
||||
<span class="sd"> src (pathlib.Path | None): source path; if None, photo is missing and</span>
|
||||
<span class="sd"> any checks that require src will return True</span>
|
||||
<span class="sd"> dest (pathlib.Path): destination path</span>
|
||||
|
||||
<span class="sd"> Returns:</span>
|
||||
<span class="sd"> False if photo should not be updated otherwise a truthy ShouldUpdate value</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="c1"># NOTE: The order of certain checks is important</span>
|
||||
<span class="c1"># read the comments below to understand why before changing</span>
|
||||
@@ -930,11 +974,11 @@
|
||||
<span class="c1"># photo doesn't exist in database, should update</span>
|
||||
<span class="k">return</span> <span class="n">ShouldUpdate</span><span class="o">.</span><span class="n">NOT_IN_DATABASE</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">export_as_hardlink</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">dest</span><span class="o">.</span><span class="n">samefile</span><span class="p">(</span><span class="n">src</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">export_as_hardlink</span> <span class="ow">and</span> <span class="p">(</span><span class="ow">not</span> <span class="n">src</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">dest</span><span class="o">.</span><span class="n">samefile</span><span class="p">(</span><span class="n">src</span><span class="p">)):</span>
|
||||
<span class="c1"># different files, should update</span>
|
||||
<span class="k">return</span> <span class="n">ShouldUpdate</span><span class="o">.</span><span class="n">HARDLINK_DIFFERENT_FILES</span>
|
||||
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">options</span><span class="o">.</span><span class="n">export_as_hardlink</span> <span class="ow">and</span> <span class="n">dest</span><span class="o">.</span><span class="n">samefile</span><span class="p">(</span><span class="n">src</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">options</span><span class="o">.</span><span class="n">export_as_hardlink</span> <span class="ow">and</span> <span class="p">(</span><span class="ow">not</span> <span class="n">src</span> <span class="ow">or</span> <span class="n">dest</span><span class="o">.</span><span class="n">samefile</span><span class="p">(</span><span class="n">src</span><span class="p">)):</span>
|
||||
<span class="c1"># same file but not exporting as hardlink, should update</span>
|
||||
<span class="k">return</span> <span class="n">ShouldUpdate</span><span class="o">.</span><span class="n">NOT_HARDLINK_SAME_FILES</span>
|
||||
|
||||
@@ -966,7 +1010,9 @@
|
||||
<span class="c1"># as exiftool will be used to update edited file</span>
|
||||
<span class="k">return</span> <span class="n">ShouldUpdate</span><span class="o">.</span><span class="n">EXIFTOOL_DIFFERENT</span> <span class="k">if</span> <span class="n">rv</span> <span class="k">else</span> <span class="kc">False</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">edited</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">fileutil</span><span class="o">.</span><span class="n">cmp_file_sig</span><span class="p">(</span><span class="n">src</span><span class="p">,</span> <span class="n">file_record</span><span class="o">.</span><span class="n">src_sig</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">edited</span> <span class="ow">and</span> <span class="p">(</span>
|
||||
<span class="ow">not</span> <span class="n">src</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">fileutil</span><span class="o">.</span><span class="n">cmp_file_sig</span><span class="p">(</span><span class="n">src</span><span class="p">,</span> <span class="n">file_record</span><span class="o">.</span><span class="n">src_sig</span><span class="p">)</span>
|
||||
<span class="p">):</span>
|
||||
<span class="c1"># edited file in Photos doesn't match what was last exported</span>
|
||||
<span class="k">return</span> <span class="n">ShouldUpdate</span><span class="o">.</span><span class="n">EDITED_SIG_DIFFERENT</span>
|
||||
|
||||
@@ -1017,22 +1063,46 @@
|
||||
|
||||
<span class="c1"># download any missing files</span>
|
||||
<span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">download_missing</span><span class="p">:</span>
|
||||
<span class="n">live_photo</span> <span class="o">=</span> <span class="n">staged</span><span class="o">.</span><span class="n">edited_live</span> <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">edited</span> <span class="k">else</span> <span class="n">staged</span><span class="o">.</span><span class="n">original_live</span>
|
||||
<span class="n">missing_options</span> <span class="o">=</span> <span class="n">ExportOptions</span><span class="p">(</span>
|
||||
<span class="n">edited</span><span class="o">=</span><span class="n">options</span><span class="o">.</span><span class="n">edited</span><span class="p">,</span>
|
||||
<span class="n">preview</span><span class="o">=</span><span class="n">options</span><span class="o">.</span><span class="n">preview</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">staged</span><span class="o">.</span><span class="n">preview</span><span class="p">,</span>
|
||||
<span class="n">raw_photo</span><span class="o">=</span><span class="n">options</span><span class="o">.</span><span class="n">raw_photo</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">staged</span><span class="o">.</span><span class="n">raw</span><span class="p">,</span>
|
||||
<span class="n">live_photo</span><span class="o">=</span><span class="n">options</span><span class="o">.</span><span class="n">live_photo</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">live_photo</span><span class="p">,</span>
|
||||
<span class="n">staged</span> <span class="o">|=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_stage_missing_photos_for_export</span><span class="p">(</span>
|
||||
<span class="n">staged</span><span class="o">=</span><span class="n">staged</span><span class="p">,</span> <span class="n">options</span><span class="o">=</span><span class="n">options</span>
|
||||
<span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">use_photokit</span><span class="p">:</span>
|
||||
<span class="n">missing_staged</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_stage_photo_for_export_with_photokit</span><span class="p">(</span>
|
||||
<span class="n">options</span><span class="o">=</span><span class="n">missing_options</span>
|
||||
<span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">missing_staged</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_stage_photo_for_export_with_applescript</span><span class="p">(</span>
|
||||
<span class="n">options</span><span class="o">=</span><span class="n">missing_options</span>
|
||||
<span class="p">)</span>
|
||||
<span class="n">staged</span> <span class="o">|=</span> <span class="n">missing_staged</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">staged</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_stage_missing_photos_for_export</span><span class="p">(</span>
|
||||
<span class="bp">self</span><span class="p">,</span> <span class="n">staged</span><span class="p">:</span> <span class="n">StagedFiles</span><span class="p">,</span> <span class="n">options</span><span class="p">:</span> <span class="n">ExportOptions</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="n">StagedFiles</span><span class="p">:</span>
|
||||
<span class="sd">"""Download and stage any missing files for export"""</span>
|
||||
|
||||
<span class="c1"># if live photo and requesting edited version need the edited live photo</span>
|
||||
<span class="n">live_photo</span> <span class="o">=</span> <span class="n">staged</span><span class="o">.</span><span class="n">edited_live</span> <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">edited</span> <span class="k">else</span> <span class="n">staged</span><span class="o">.</span><span class="n">original_live</span>
|
||||
|
||||
<span class="c1"># is there actually a missing file? (#1086)</span>
|
||||
<span class="n">something_to_download</span> <span class="o">=</span> <span class="p">(</span>
|
||||
<span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">photo</span><span class="o">.</span><span class="n">hasadjustments</span> <span class="ow">and</span> <span class="n">options</span><span class="o">.</span><span class="n">edited</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">staged</span><span class="o">.</span><span class="n">edited</span><span class="p">)</span>
|
||||
<span class="ow">or</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">photo</span><span class="o">.</span><span class="n">live_photo</span> <span class="ow">and</span> <span class="n">options</span><span class="o">.</span><span class="n">live_photo</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">live_photo</span><span class="p">)</span>
|
||||
<span class="ow">or</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">photo</span><span class="o">.</span><span class="n">has_raw</span> <span class="ow">and</span> <span class="n">options</span><span class="o">.</span><span class="n">raw_photo</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">staged</span><span class="o">.</span><span class="n">raw</span><span class="p">)</span>
|
||||
<span class="ow">or</span> <span class="p">(</span><span class="n">options</span><span class="o">.</span><span class="n">preview</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">staged</span><span class="o">.</span><span class="n">preview</span><span class="p">)</span>
|
||||
<span class="ow">or</span> <span class="p">(</span><span class="ow">not</span> <span class="n">options</span><span class="o">.</span><span class="n">edited</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">staged</span><span class="o">.</span><span class="n">original</span><span class="p">)</span>
|
||||
<span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">something_to_download</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">staged</span>
|
||||
|
||||
<span class="n">missing_options</span> <span class="o">=</span> <span class="n">ExportOptions</span><span class="p">(</span>
|
||||
<span class="n">edited</span><span class="o">=</span><span class="n">options</span><span class="o">.</span><span class="n">edited</span><span class="p">,</span>
|
||||
<span class="n">preview</span><span class="o">=</span><span class="n">options</span><span class="o">.</span><span class="n">preview</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">staged</span><span class="o">.</span><span class="n">preview</span><span class="p">,</span>
|
||||
<span class="n">raw_photo</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">photo</span><span class="o">.</span><span class="n">has_raw</span> <span class="ow">and</span> <span class="n">options</span><span class="o">.</span><span class="n">raw_photo</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">staged</span><span class="o">.</span><span class="n">raw</span><span class="p">,</span>
|
||||
<span class="n">live_photo</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">photo</span><span class="o">.</span><span class="n">live_photo</span> <span class="ow">and</span> <span class="n">options</span><span class="o">.</span><span class="n">live_photo</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">live_photo</span><span class="p">,</span>
|
||||
<span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">use_photokit</span><span class="p">:</span>
|
||||
<span class="n">missing_staged</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_stage_photo_for_export_with_photokit</span><span class="p">(</span>
|
||||
<span class="n">options</span><span class="o">=</span><span class="n">missing_options</span>
|
||||
<span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">missing_staged</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_stage_photo_for_export_with_applescript</span><span class="p">(</span>
|
||||
<span class="n">options</span><span class="o">=</span><span class="n">missing_options</span>
|
||||
<span class="p">)</span>
|
||||
<span class="n">staged</span> <span class="o">|=</span> <span class="n">missing_staged</span>
|
||||
<span class="k">return</span> <span class="n">staged</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_stage_photo_for_export_with_photokit</span><span class="p">(</span>
|
||||
@@ -1147,7 +1217,8 @@
|
||||
<span class="sd">"""Stage a photo for export with AppleScript to a temporary directory</span>
|
||||
|
||||
<span class="sd"> Note: If exporting an edited live photo, the associated live video will not be exported.</span>
|
||||
<span class="sd"> This is a limitation of the Photos AppleScript interface and Photos behaves the same way."""</span>
|
||||
<span class="sd"> This is a limitation of the Photos AppleScript interface and Photos behaves the same way.</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">edited</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">photo</span><span class="o">.</span><span class="n">hasadjustments</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Edited version requested but photo has no adjustments"</span><span class="p">)</span>
|
||||
@@ -1376,7 +1447,7 @@
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">fileutil</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">src</span><span class="p">,</span> <span class="n">dest_str</span><span class="p">)</span>
|
||||
<span class="n">verbose</span><span class="p">(</span>
|
||||
<span class="sa">f</span><span class="s2">"Exported </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_filename</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">photo</span><span class="o">.</span><span class="n">original_filename</span><span class="p">)</span><span class="si">}</span><span class="s2"> to </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_filepath</span><span class="p">(</span><span class="n">dest_str</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span>
|
||||
<span class="sa">f</span><span class="s2">"Exported </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_filename</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">photo</span><span class="o">.</span><span class="n">original_filename</span><span class="p">)</span><span class="si">}</span><span class="s2"> to </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_filepath</span><span class="p">(</span><span class="n">normalize_fs_path</span><span class="p">(</span><span class="n">dest_str</span><span class="p">))</span><span class="si">}</span><span class="s2">"</span>
|
||||
<span class="p">)</span>
|
||||
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="n">ExportError</span><span class="p">(</span>
|
||||
@@ -1407,7 +1478,7 @@
|
||||
|
||||
<span class="c1"># set data in the database</span>
|
||||
<span class="k">with</span> <span class="n">export_db</span><span class="o">.</span><span class="n">create_or_get_file_record</span><span class="p">(</span><span class="n">dest_str</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">photo</span><span class="o">.</span><span class="n">uuid</span><span class="p">)</span> <span class="k">as</span> <span class="n">rec</span><span class="p">:</span>
|
||||
<span class="n">rec</span><span class="o">.</span><span class="n">photoinfo</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">photo</span><span class="o">.</span><span class="n">json</span><span class="p">()</span>
|
||||
<span class="n">rec</span><span class="o">.</span><span class="n">photoinfo</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">photo</span><span class="o">.</span><span class="n">json</span><span class="p">(</span><span class="n">shallow</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
||||
<span class="n">rec</span><span class="o">.</span><span class="n">export_options</span> <span class="o">=</span> <span class="n">options</span><span class="o">.</span><span class="n">bit_flags</span>
|
||||
<span class="c1"># don't set src_sig as that is set above before any modifications by convert_to_jpeg or exiftool</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">options</span><span class="o">.</span><span class="n">ignore_signature</span><span class="p">:</span>
|
||||
@@ -1537,6 +1608,53 @@
|
||||
<span class="n">exported_paths</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">dest_new</span><span class="p">))</span>
|
||||
<span class="k">return</span> <span class="n">exported_paths</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_write_aae_file</span><span class="p">(</span>
|
||||
<span class="bp">self</span><span class="p">,</span>
|
||||
<span class="n">dest</span><span class="p">:</span> <span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">,</span>
|
||||
<span class="n">options</span><span class="p">:</span> <span class="n">ExportOptions</span><span class="p">,</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="n">ExportResults</span><span class="p">:</span>
|
||||
<span class="sd">"""Write AAE file for the photo."""</span>
|
||||
|
||||
<span class="c1"># AAE files describe adjustments to originals, so they don't make sense</span>
|
||||
<span class="c1"># for edited files</span>
|
||||
<span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">edited</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">ExportResults</span><span class="p">()</span>
|
||||
|
||||
<span class="n">verbose</span> <span class="o">=</span> <span class="n">options</span><span class="o">.</span><span class="n">verbose</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_verbose</span>
|
||||
|
||||
<span class="n">aae_src</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">photo</span><span class="o">.</span><span class="n">adjustments_path</span>
|
||||
<span class="k">if</span> <span class="n">aae_src</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">ExportResults</span><span class="p">()</span>
|
||||
<span class="n">aae_dest</span> <span class="o">=</span> <span class="n">dest</span><span class="o">.</span><span class="n">with_suffix</span><span class="p">(</span><span class="s2">".AAE"</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">export_as_hardlink</span><span class="p">:</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">aae_dest</span><span class="o">.</span><span class="n">exists</span><span class="p">()</span> <span class="ow">and</span> <span class="nb">any</span><span class="p">(</span>
|
||||
<span class="p">[</span><span class="n">options</span><span class="o">.</span><span class="n">overwrite</span><span class="p">,</span> <span class="n">options</span><span class="o">.</span><span class="n">update</span><span class="p">,</span> <span class="n">options</span><span class="o">.</span><span class="n">force_update</span><span class="p">]):</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">options</span><span class="o">.</span><span class="n">fileutil</span><span class="o">.</span><span class="n">unlink</span><span class="p">(</span><span class="n">aae_dest</span><span class="p">)</span>
|
||||
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="n">ExportError</span><span class="p">(</span>
|
||||
<span class="sa">f</span><span class="s2">"Error removing file </span><span class="si">{</span><span class="n">aae_dest</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="n">e</span><span class="si">}</span><span class="s2"> ((</span><span class="si">{</span><span class="n">lineno</span><span class="p">(</span><span class="vm">__file__</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span>
|
||||
<span class="p">)</span> <span class="kn">from</span> <span class="nn">e</span>
|
||||
<span class="n">options</span><span class="o">.</span><span class="n">fileutil</span><span class="o">.</span><span class="n">hardlink</span><span class="p">(</span><span class="n">aae_src</span><span class="p">,</span> <span class="n">aae_dest</span><span class="p">)</span>
|
||||
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="n">ExportError</span><span class="p">(</span>
|
||||
<span class="sa">f</span><span class="s2">"Error hardlinking </span><span class="si">{</span><span class="n">aae_src</span><span class="si">}</span><span class="s2"> to </span><span class="si">{</span><span class="n">aae_dest</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="n">e</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">lineno</span><span class="p">(</span><span class="vm">__file__</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span>
|
||||
<span class="p">)</span> <span class="kn">from</span> <span class="nn">e</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">options</span><span class="o">.</span><span class="n">fileutil</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">aae_src</span><span class="p">,</span> <span class="n">aae_dest</span><span class="p">)</span>
|
||||
<span class="n">verbose</span><span class="p">(</span>
|
||||
<span class="sa">f</span><span class="s2">"Exported adjustments of </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_filename</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">photo</span><span class="o">.</span><span class="n">original_filename</span><span class="p">)</span><span class="si">}</span><span class="s2"> to </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_filepath</span><span class="p">(</span><span class="n">normalize_fs_path</span><span class="p">(</span><span class="n">aae_dest</span><span class="p">))</span><span class="si">}</span><span class="s2">"</span>
|
||||
<span class="p">)</span>
|
||||
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="n">ExportError</span><span class="p">(</span>
|
||||
<span class="sa">f</span><span class="s2">"Error copying file </span><span class="si">{</span><span class="n">aae_src</span><span class="si">}</span><span class="s2"> to </span><span class="si">{</span><span class="n">aae_dest</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="n">e</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">lineno</span><span class="p">(</span><span class="vm">__file__</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span>
|
||||
<span class="p">)</span> <span class="kn">from</span> <span class="nn">e</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">ExportResults</span><span class="p">(</span><span class="n">aae_written</span><span class="o">=</span><span class="p">[</span><span class="n">aae_dest</span><span class="p">])</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_write_sidecar_files</span><span class="p">(</span>
|
||||
<span class="bp">self</span><span class="p">,</span>
|
||||
<span class="n">dest</span><span class="p">:</span> <span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">,</span>
|
||||
@@ -1716,10 +1834,10 @@
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">options</span><span class="o">.</span><span class="n">dry_run</span><span class="p">:</span>
|
||||
<span class="n">warning_</span><span class="p">,</span> <span class="n">error_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_write_exif_data</span><span class="p">(</span><span class="n">src</span><span class="p">,</span> <span class="n">options</span><span class="o">=</span><span class="n">options</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">warning_</span><span class="p">:</span>
|
||||
<span class="n">exiftool_results</span><span class="o">.</span><span class="n">exiftool_warning</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">dest</span><span class="p">,</span> <span class="n">warning_</span><span class="p">))</span>
|
||||
<span class="n">exiftool_results</span><span class="o">.</span><span class="n">exiftool_warning</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="nb">str</span><span class="p">(</span><span class="n">dest</span><span class="p">),</span> <span class="nb">str</span><span class="p">(</span><span class="n">warning_</span><span class="p">)))</span>
|
||||
<span class="k">if</span> <span class="n">error_</span><span class="p">:</span>
|
||||
<span class="n">exiftool_results</span><span class="o">.</span><span class="n">exiftool_error</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">dest</span><span class="p">,</span> <span class="n">error_</span><span class="p">))</span>
|
||||
<span class="n">exiftool_results</span><span class="o">.</span><span class="n">error</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">dest</span><span class="p">,</span> <span class="n">error_</span><span class="p">))</span>
|
||||
<span class="n">exiftool_results</span><span class="o">.</span><span class="n">exiftool_error</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="nb">str</span><span class="p">(</span><span class="n">dest</span><span class="p">),</span> <span class="nb">str</span><span class="p">(</span><span class="n">error_</span><span class="p">)))</span>
|
||||
<span class="n">exiftool_results</span><span class="o">.</span><span class="n">error</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="nb">str</span><span class="p">(</span><span class="n">dest</span><span class="p">),</span> <span class="nb">str</span><span class="p">(</span><span class="n">error_</span><span class="p">)))</span>
|
||||
|
||||
<span class="n">exiftool_results</span><span class="o">.</span><span class="n">exif_updated</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">dest</span><span class="p">)</span>
|
||||
<span class="n">exiftool_results</span><span class="o">.</span><span class="n">to_touch</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">dest</span><span class="p">)</span>
|
||||
@@ -1761,7 +1879,7 @@
|
||||
<span class="k">with</span> <span class="n">ExifTool</span><span class="p">(</span>
|
||||
<span class="n">filepath</span><span class="p">,</span>
|
||||
<span class="n">flags</span><span class="o">=</span><span class="n">options</span><span class="o">.</span><span class="n">exiftool_flags</span><span class="p">,</span>
|
||||
<span class="n">exiftool</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">photo</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_exiftool_path</span><span class="p">,</span>
|
||||
<span class="n">exiftool</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">photo</span><span class="o">.</span><span class="n">_exiftool_path</span><span class="p">,</span>
|
||||
<span class="p">)</span> <span class="k">as</span> <span class="n">exiftool</span><span class="p">:</span>
|
||||
<span class="k">for</span> <span class="n">exiftag</span><span class="p">,</span> <span class="n">val</span> <span class="ow">in</span> <span class="n">exif_info</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
|
||||
<span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">val</span><span class="p">)</span> <span class="o">==</span> <span class="nb">list</span><span class="p">:</span>
|
||||
@@ -1941,7 +2059,6 @@
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">photo</span><span class="o">.</span><span class="n">ismovie</span><span class="p">:</span>
|
||||
<span class="n">exif</span><span class="p">[</span><span class="s2">"Keys:GPSCoordinates"</span><span class="p">]</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">lat</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">lon</span><span class="si">}</span><span class="s2">"</span>
|
||||
<span class="n">exif</span><span class="p">[</span><span class="s2">"UserData:GPSCoordinates"</span><span class="p">]</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">lat</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">lon</span><span class="si">}</span><span class="s2">"</span>
|
||||
|
||||
<span class="c1"># process date/time and timezone offset</span>
|
||||
<span class="c1"># Photos exports the following fields and sets modify date to creation date</span>
|
||||
<span class="c1"># [EXIF] Modify Date : 2020:10:30 00:00:00</span>
|
||||
@@ -2051,7 +2168,7 @@
|
||||
<span class="k">def</span> <span class="nf">_get_exif_keywords</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""returns list of keywords found in the file's exif metadata"""</span>
|
||||
<span class="n">keywords</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="n">exif</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">photo</span><span class="o">.</span><span class="n">exiftool</span>
|
||||
<span class="n">exif</span> <span class="o">=</span> <span class="n">exiftool_caching</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">photo</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">exif</span><span class="p">:</span>
|
||||
<span class="n">exifdict</span> <span class="o">=</span> <span class="n">exif</span><span class="o">.</span><span class="n">asdict</span><span class="p">()</span>
|
||||
<span class="k">for</span> <span class="n">field</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">"IPTC:Keywords"</span><span class="p">,</span> <span class="s2">"XMP:TagsList"</span><span class="p">,</span> <span class="s2">"XMP:Subject"</span><span class="p">]:</span>
|
||||
@@ -2068,7 +2185,7 @@
|
||||
<span class="k">def</span> <span class="nf">_get_exif_persons</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""returns list of persons found in the file's exif metadata"""</span>
|
||||
<span class="n">persons</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="n">exif</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">photo</span><span class="o">.</span><span class="n">exiftool</span>
|
||||
<span class="n">exif</span> <span class="o">=</span> <span class="n">exiftool_caching</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">photo</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">exif</span><span class="p">:</span>
|
||||
<span class="n">exifdict</span> <span class="o">=</span> <span class="n">exif</span><span class="o">.</span><span class="n">asdict</span><span class="p">()</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
@@ -2149,10 +2266,7 @@
|
||||
|
||||
<span class="n">options</span> <span class="o">=</span> <span class="n">options</span> <span class="ow">or</span> <span class="n">ExportOptions</span><span class="p">()</span>
|
||||
|
||||
<span class="n">xmp_template_file</span> <span class="o">=</span> <span class="p">(</span>
|
||||
<span class="n">_XMP_TEMPLATE_NAME</span> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">photo</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_beta</span> <span class="k">else</span> <span class="n">_XMP_TEMPLATE_NAME_BETA</span>
|
||||
<span class="p">)</span>
|
||||
<span class="n">xmp_template</span> <span class="o">=</span> <span class="n">Template</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">_TEMPLATE_DIR</span><span class="p">,</span> <span class="n">xmp_template_file</span><span class="p">))</span>
|
||||
<span class="n">xmp_template</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_xmp_template</span><span class="p">()</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">extension</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">extension</span> <span class="o">=</span> <span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">photo</span><span class="o">.</span><span class="n">original_filename</span><span class="p">)</span>
|
||||
@@ -2259,6 +2373,20 @@
|
||||
<span class="n">xmp_str</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">line</span> <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">xmp_str</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">line</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="o">!=</span> <span class="s2">""</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">xmp_str</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_xmp_template</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""Return the mako template for XMP sidecar, creating it if necessary"""</span>
|
||||
<span class="k">global</span> <span class="n">_global_xmp_template</span>
|
||||
<span class="k">if</span> <span class="n">_global_xmp_template</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">_global_xmp_template</span>
|
||||
|
||||
<span class="n">xmp_template_file</span> <span class="o">=</span> <span class="p">(</span>
|
||||
<span class="n">_XMP_TEMPLATE_NAME_BETA</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">photo</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_beta</span> <span class="k">else</span> <span class="n">_XMP_TEMPLATE_NAME</span>
|
||||
<span class="p">)</span>
|
||||
<span class="n">_global_xmp_template</span> <span class="o">=</span> <span class="n">Template</span><span class="p">(</span>
|
||||
<span class="n">filename</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">_TEMPLATE_DIR</span><span class="p">,</span> <span class="n">xmp_template_file</span><span class="p">)</span>
|
||||
<span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">_global_xmp_template</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_write_sidecar</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="n">sidecar_str</span><span class="p">):</span>
|
||||
<span class="sd">"""write sidecar_str to filename</span>
|
||||
<span class="sd"> used for exporting sidecar info"""</span>
|
||||
@@ -2339,6 +2467,35 @@
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">new_files</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">file</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">new_files</span>
|
||||
|
||||
|
||||
<span class="k">def</span> <span class="nf">exiftool_caching</span><span class="p">(</span><span class="n">photo</span><span class="p">:</span> <span class="n">SimpleNamespace</span><span class="p">)</span> <span class="o">-></span> <span class="n">ExifToolCaching</span><span class="p">:</span>
|
||||
<span class="sd">"""Return ExifToolCaching object for photo</span>
|
||||
|
||||
<span class="sd"> Args:</span>
|
||||
<span class="sd"> photo: SimpleNamespace object with photo info</span>
|
||||
|
||||
<span class="sd"> Returns:</span>
|
||||
<span class="sd"> ExifToolCaching object</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">photo</span><span class="o">.</span><span class="n">_exiftool_caching</span>
|
||||
<span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">exiftool_path</span> <span class="o">=</span> <span class="n">photo</span><span class="o">.</span><span class="n">_exiftool_path</span> <span class="ow">or</span> <span class="n">get_exiftool_path</span><span class="p">()</span>
|
||||
<span class="k">if</span> <span class="n">photo</span><span class="o">.</span><span class="n">path</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">photo</span><span class="o">.</span><span class="n">path</span><span class="p">):</span>
|
||||
<span class="n">exiftool</span> <span class="o">=</span> <span class="n">ExifToolCaching</span><span class="p">(</span><span class="n">photo</span><span class="o">.</span><span class="n">path</span><span class="p">,</span> <span class="n">exiftool</span><span class="o">=</span><span class="n">exiftool_path</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">exiftool</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="k">except</span> <span class="ne">FileNotFoundError</span><span class="p">:</span>
|
||||
<span class="c1"># get_exiftool_path raises FileNotFoundError if exiftool not found</span>
|
||||
<span class="n">exiftool</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="n">logging</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span>
|
||||
<span class="s2">"exiftool not in path; download and install from https://exiftool.org/"</span>
|
||||
<span class="p">)</span>
|
||||
|
||||
<span class="n">photo</span><span class="o">.</span><span class="n">_exiftool_caching</span> <span class="o">=</span> <span class="n">exiftool</span>
|
||||
<span class="k">return</span> <span class="n">photo</span><span class="o">.</span><span class="n">_exiftool_caching</span>
|
||||
</pre></div>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta name="color-scheme" content="light dark"><link rel="index" title="Index" href="../../genindex.html" /><link rel="search" title="Search" href="../../search.html" />
|
||||
|
||||
<meta name="generator" content="sphinx-5.3.0, furo 2022.09.29"/>
|
||||
<title>osxphotos.photoinfo - osxphotos 0.58.1 documentation</title>
|
||||
<title>osxphotos.photoinfo - osxphotos 0.60.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/styles/furo.css?digest=d81277517bee4d6b0349d71bb2661d4890b5617c" />
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/copybutton.css" />
|
||||
@@ -123,7 +123,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="../../index.html"><div class="brand">osxphotos 0.58.1 documentation</div></a>
|
||||
<a href="../../index.html"><div class="brand">osxphotos 0.60.7 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -146,7 +146,7 @@
|
||||
<div class="sidebar-sticky"><a class="sidebar-brand" href="../../index.html">
|
||||
|
||||
|
||||
<span class="sidebar-brand-text">osxphotos 0.58.1 documentation</span>
|
||||
<span class="sidebar-brand-text">osxphotos 0.60.7 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="../../search.html" role="search">
|
||||
<input class="sidebar-search" placeholder=Search name="q" aria-label="Search">
|
||||
@@ -205,17 +205,18 @@
|
||||
<span class="kn">import</span> <span class="nn">dataclasses</span>
|
||||
<span class="kn">import</span> <span class="nn">datetime</span>
|
||||
<span class="kn">import</span> <span class="nn">json</span>
|
||||
<span class="kn">import</span> <span class="nn">logging</span>
|
||||
<span class="kn">import</span> <span class="nn">os</span>
|
||||
<span class="kn">import</span> <span class="nn">os.path</span>
|
||||
<span class="kn">import</span> <span class="nn">pathlib</span>
|
||||
<span class="kn">import</span> <span class="nn">plistlib</span>
|
||||
<span class="kn">import</span> <span class="nn">re</span>
|
||||
<span class="kn">from</span> <span class="nn">datetime</span> <span class="kn">import</span> <span class="n">timedelta</span><span class="p">,</span> <span class="n">timezone</span>
|
||||
<span class="kn">from</span> <span class="nn">functools</span> <span class="kn">import</span> <span class="n">cached_property</span>
|
||||
<span class="kn">from</span> <span class="nn">types</span> <span class="kn">import</span> <span class="n">SimpleNamespace</span>
|
||||
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Any</span><span class="p">,</span> <span class="n">Dict</span><span class="p">,</span> <span class="n">Optional</span>
|
||||
<span class="kn">import</span> <span class="nn">logging</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">yaml</span>
|
||||
<span class="kn">from</span> <span class="nn">osxmetadata</span> <span class="kn">import</span> <span class="n">OSXMetaData</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">osxphotos</span>
|
||||
|
||||
@@ -254,16 +255,22 @@
|
||||
<span class="kn">from</span> <span class="nn">.momentinfo</span> <span class="kn">import</span> <span class="n">MomentInfo</span>
|
||||
<span class="kn">from</span> <span class="nn">.personinfo</span> <span class="kn">import</span> <span class="n">FaceInfo</span><span class="p">,</span> <span class="n">PersonInfo</span>
|
||||
<span class="kn">from</span> <span class="nn">.photoexporter</span> <span class="kn">import</span> <span class="n">ExportOptions</span><span class="p">,</span> <span class="n">PhotoExporter</span>
|
||||
<span class="kn">from</span> <span class="nn">.phototables</span> <span class="kn">import</span> <span class="n">PhotoTables</span>
|
||||
<span class="kn">from</span> <span class="nn">.phototemplate</span> <span class="kn">import</span> <span class="n">PhotoTemplate</span><span class="p">,</span> <span class="n">RenderOptions</span>
|
||||
<span class="kn">from</span> <span class="nn">.placeinfo</span> <span class="kn">import</span> <span class="n">PlaceInfo4</span><span class="p">,</span> <span class="n">PlaceInfo5</span>
|
||||
<span class="kn">from</span> <span class="nn">.platform</span> <span class="kn">import</span> <span class="n">assert_macos</span><span class="p">,</span> <span class="n">is_macos</span>
|
||||
<span class="kn">from</span> <span class="nn">.query_builder</span> <span class="kn">import</span> <span class="n">get_query</span>
|
||||
<span class="kn">from</span> <span class="nn">.scoreinfo</span> <span class="kn">import</span> <span class="n">ScoreInfo</span>
|
||||
<span class="kn">from</span> <span class="nn">.searchinfo</span> <span class="kn">import</span> <span class="n">SearchInfo</span>
|
||||
<span class="kn">from</span> <span class="nn">.text_detection</span> <span class="kn">import</span> <span class="n">detect_text</span>
|
||||
<span class="kn">from</span> <span class="nn">.uti</span> <span class="kn">import</span> <span class="n">get_preferred_uti_extension</span><span class="p">,</span> <span class="n">get_uti_for_extension</span>
|
||||
<span class="kn">from</span> <span class="nn">.utils</span> <span class="kn">import</span> <span class="n">_get_resource_loc</span><span class="p">,</span> <span class="n">hexdigest</span><span class="p">,</span> <span class="n">list_directory</span>
|
||||
|
||||
<span class="n">__all__</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"PhotoInfo"</span><span class="p">,</span> <span class="s2">"PhotoInfoNone"</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="n">is_macos</span><span class="p">:</span>
|
||||
<span class="kn">from</span> <span class="nn">osxmetadata</span> <span class="kn">import</span> <span class="n">OSXMetaData</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">.text_detection</span> <span class="kn">import</span> <span class="n">detect_text</span>
|
||||
|
||||
<span class="n">__all__</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"PhotoInfo"</span><span class="p">,</span> <span class="s2">"PhotoInfoNone"</span><span class="p">,</span> <span class="s2">"frozen_photoinfo_factory"</span><span class="p">]</span>
|
||||
|
||||
<span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s2">"osxphotos"</span><span class="p">)</span>
|
||||
|
||||
@@ -278,6 +285,7 @@
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_uuid</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="n">uuid</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_info</span><span class="p">:</span> <span class="nb">dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Any</span><span class="p">]</span> <span class="o">=</span> <span class="n">info</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="p">:</span> <span class="s2">"osxphotos.PhotosDB"</span> <span class="o">=</span> <span class="n">db</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_exiftool_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_exiftool_path</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_verbose</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_verbose</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
@@ -325,8 +333,7 @@
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">hasadjustments</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_db_version</span> <span class="o"><=</span> <span class="n">_PHOTOS_4_VERSION</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="kc">None</span>
|
||||
|
||||
<span class="n">imagedate</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_info</span><span class="p">[</span><span class="s2">"lastmodifieddate"</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="n">imagedate</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">imagedate</span> <span class="o">:=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_info</span><span class="p">[</span><span class="s2">"lastmodifieddate"</span><span class="p">]:</span>
|
||||
<span class="n">seconds</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_info</span><span class="p">[</span><span class="s2">"imageTimeZoneOffsetSeconds"</span><span class="p">]</span> <span class="ow">or</span> <span class="mi">0</span>
|
||||
<span class="n">delta</span> <span class="o">=</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">seconds</span><span class="o">=</span><span class="n">seconds</span><span class="p">)</span>
|
||||
<span class="n">tz</span> <span class="o">=</span> <span class="n">timezone</span><span class="p">(</span><span class="n">delta</span><span class="p">)</span>
|
||||
@@ -363,6 +370,9 @@
|
||||
<span class="sd">"""Returns candidate path for original photo on Photos >= version 5"""</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_info</span><span class="p">[</span><span class="s2">"shared"</span><span class="p">]:</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_path_5_shared</span><span class="p">()</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">syndicated</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">saved_to_library</span><span class="p">:</span>
|
||||
<span class="c1"># path for "shared with you" syndicated photos that have not yet been saved to the library</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_path_syndication</span><span class="p">()</span>
|
||||
<span class="k">return</span> <span class="p">(</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_info</span><span class="p">[</span><span class="s2">"directory"</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">_info</span><span class="p">[</span><span class="s2">"filename"</span><span class="p">])</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_info</span><span class="p">[</span><span class="s2">"directory"</span><span class="p">]</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"/"</span><span class="p">)</span>
|
||||
@@ -402,6 +412,21 @@
|
||||
<span class="n">filename</span><span class="p">,</span>
|
||||
<span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_path_syndication</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""Return path for syndicated photo on Photos >= version 8"""</span>
|
||||
<span class="c1"># Photos 8+ stores syndicated photos in a separate directory</span>
|
||||
<span class="c1"># in ~/Photos Library.photoslibrary/scopes/syndication/originals/X/UUID.ext</span>
|
||||
<span class="c1"># where X is first digit of UUID</span>
|
||||
<span class="n">syndication_path</span> <span class="o">=</span> <span class="s2">"scopes/syndication/originals"</span>
|
||||
<span class="n">uuid_dir</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">uuid</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
<span class="n">path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_library_path</span><span class="p">,</span>
|
||||
<span class="n">syndication_path</span><span class="p">,</span>
|
||||
<span class="n">uuid_dir</span><span class="p">,</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">filename</span><span class="p">,</span>
|
||||
<span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">path</span> <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">path</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_path_4</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""Returns candidate path for original photo on Photos <= version 4"""</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_info</span><span class="p">[</span><span class="s2">"has_raw"</span><span class="p">]:</span>
|
||||
@@ -585,6 +610,8 @@
|
||||
<span class="sd">"""return path_edited_live_photo for Photos <= 4"""</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_db_version</span> <span class="o">></span> <span class="n">_PHOTOS_4_VERSION</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s2">"Wrong database format!"</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">live_photo</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="kc">None</span>
|
||||
<span class="n">photopath</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_predicted_path_edited_live_photo_4</span><span class="p">()</span>
|
||||
<span class="k">if</span> <span class="n">photopath</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">photopath</span><span class="p">):</span>
|
||||
<span class="c1"># the heuristic failed, so try to find the file</span>
|
||||
@@ -598,10 +625,6 @@
|
||||
<span class="p">),</span>
|
||||
<span class="kc">None</span><span class="p">,</span>
|
||||
<span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">photopath</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span>
|
||||
<span class="sa">f</span><span class="s2">"MISSING PATH: edited live photo file for UUID </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_uuid</span><span class="si">}</span><span class="s2"> does not appear to exist"</span>
|
||||
<span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">photopath</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_path_edited_5_live_photo</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
@@ -713,39 +736,26 @@
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">person_info</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""list of PersonInfo objects for person in picture"""</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_personinfo</span>
|
||||
<span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_personinfo</span> <span class="o">=</span> <span class="p">[</span>
|
||||
<span class="n">PersonInfo</span><span class="p">(</span><span class="n">db</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="p">,</span> <span class="n">pk</span><span class="o">=</span><span class="n">pk</span><span class="p">)</span> <span class="k">for</span> <span class="n">pk</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_info</span><span class="p">[</span><span class="s2">"persons"</span><span class="p">]</span>
|
||||
<span class="p">]</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_personinfo</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="n">PersonInfo</span><span class="p">(</span><span class="n">db</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="p">,</span> <span class="n">pk</span><span class="o">=</span><span class="n">pk</span><span class="p">)</span> <span class="k">for</span> <span class="n">pk</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_info</span><span class="p">[</span><span class="s2">"persons"</span><span class="p">]]</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">face_info</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""list of FaceInfo objects for faces in picture"""</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_faceinfo</span>
|
||||
<span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">faces</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_db_faceinfo_uuid</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_uuid</span><span class="p">]</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_faceinfo</span> <span class="o">=</span> <span class="p">[</span><span class="n">FaceInfo</span><span class="p">(</span><span class="n">db</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="p">,</span> <span class="n">pk</span><span class="o">=</span><span class="n">pk</span><span class="p">)</span> <span class="k">for</span> <span class="n">pk</span> <span class="ow">in</span> <span class="n">faces</span><span class="p">]</span>
|
||||
<span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
|
||||
<span class="c1"># no faces</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_faceinfo</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_faceinfo</span>
|
||||
<span class="n">faces</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_db_faceinfo_uuid</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_uuid</span><span class="p">]</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_faceinfo</span> <span class="o">=</span> <span class="p">[</span><span class="n">FaceInfo</span><span class="p">(</span><span class="n">db</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="p">,</span> <span class="n">pk</span><span class="o">=</span><span class="n">pk</span><span class="p">)</span> <span class="k">for</span> <span class="n">pk</span> <span class="ow">in</span> <span class="n">faces</span><span class="p">]</span>
|
||||
<span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
|
||||
<span class="c1"># no faces</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_faceinfo</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_faceinfo</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">moment_info</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""Moment photo belongs to"""</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_moment</span>
|
||||
<span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_moment</span> <span class="o">=</span> <span class="n">MomentInfo</span><span class="p">(</span><span class="n">db</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="p">,</span> <span class="n">moment_pk</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_info</span><span class="p">[</span><span class="s2">"momentID"</span><span class="p">])</span>
|
||||
<span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_moment</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_moment</span>
|
||||
<span class="k">return</span> <span class="n">MomentInfo</span><span class="p">(</span><span class="n">db</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="p">,</span> <span class="n">moment_pk</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_info</span><span class="p">[</span><span class="s2">"momentID"</span><span class="p">])</span>
|
||||
<span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="kc">None</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">albums</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
@@ -762,65 +772,41 @@
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">burst_albums</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""If photo is burst photo, list of albums it is contained in as well as any albums the key photo is contained in, otherwise returns self.albums"""</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_burst_albums</span>
|
||||
<span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
|
||||
<span class="n">burst_albums</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">albums</span><span class="p">)</span>
|
||||
<span class="k">for</span> <span class="n">photo</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">burst_photos</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">photo</span><span class="o">.</span><span class="n">burst_key</span><span class="p">:</span>
|
||||
<span class="n">burst_albums</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">photo</span><span class="o">.</span><span class="n">albums</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_burst_albums</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">burst_albums</span><span class="p">))</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_burst_albums</span>
|
||||
<span class="n">burst_albums</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">albums</span><span class="p">)</span>
|
||||
<span class="k">for</span> <span class="n">photo</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">burst_photos</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">photo</span><span class="o">.</span><span class="n">burst_key</span><span class="p">:</span>
|
||||
<span class="n">burst_albums</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">photo</span><span class="o">.</span><span class="n">albums</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">burst_albums</span><span class="p">))</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">album_info</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""list of AlbumInfo objects representing albums the photo is contained in"""</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_album_info</span>
|
||||
<span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
|
||||
<span class="n">album_uuids</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_album_uuids</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_album_info</span> <span class="o">=</span> <span class="p">[</span>
|
||||
<span class="n">AlbumInfo</span><span class="p">(</span><span class="n">db</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="p">,</span> <span class="n">uuid</span><span class="o">=</span><span class="n">album</span><span class="p">)</span> <span class="k">for</span> <span class="n">album</span> <span class="ow">in</span> <span class="n">album_uuids</span>
|
||||
<span class="p">]</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_album_info</span>
|
||||
<span class="n">album_uuids</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_album_uuids</span><span class="p">()</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="n">AlbumInfo</span><span class="p">(</span><span class="n">db</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="p">,</span> <span class="n">uuid</span><span class="o">=</span><span class="n">album</span><span class="p">)</span> <span class="k">for</span> <span class="n">album</span> <span class="ow">in</span> <span class="n">album_uuids</span><span class="p">]</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">burst_album_info</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""If photo is a burst photo, returns list of AlbumInfo objects representing albums the photo is contained in as well as albums the burst key photo is contained in, otherwise returns self.album_info."""</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_burst_album_info</span>
|
||||
<span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
|
||||
<span class="n">burst_album_info</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">album_info</span><span class="p">)</span>
|
||||
<span class="k">for</span> <span class="n">photo</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">burst_photos</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">photo</span><span class="o">.</span><span class="n">burst_key</span><span class="p">:</span>
|
||||
<span class="n">burst_album_info</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">photo</span><span class="o">.</span><span class="n">album_info</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_burst_album_info</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">burst_album_info</span><span class="p">))</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_burst_album_info</span>
|
||||
<span class="n">burst_album_info</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">album_info</span><span class="p">)</span>
|
||||
<span class="k">for</span> <span class="n">photo</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">burst_photos</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">photo</span><span class="o">.</span><span class="n">burst_key</span><span class="p">:</span>
|
||||
<span class="n">burst_album_info</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">photo</span><span class="o">.</span><span class="n">album_info</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">burst_album_info</span><span class="p">))</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">import_info</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""ImportInfo object representing import session for the photo or None if no import session"""</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_import_info</span>
|
||||
<span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_import_info</span> <span class="o">=</span> <span class="p">(</span>
|
||||
<span class="n">ImportInfo</span><span class="p">(</span><span class="n">db</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="p">,</span> <span class="n">uuid</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_info</span><span class="p">[</span><span class="s2">"import_uuid"</span><span class="p">])</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_info</span><span class="p">[</span><span class="s2">"import_uuid"</span><span class="p">]</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span>
|
||||
<span class="k">else</span> <span class="kc">None</span>
|
||||
<span class="p">)</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_import_info</span>
|
||||
<span class="k">return</span> <span class="p">(</span>
|
||||
<span class="n">ImportInfo</span><span class="p">(</span><span class="n">db</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="p">,</span> <span class="n">uuid</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_info</span><span class="p">[</span><span class="s2">"import_uuid"</span><span class="p">])</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_info</span><span class="p">[</span><span class="s2">"import_uuid"</span><span class="p">]</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span>
|
||||
<span class="k">else</span> <span class="kc">None</span>
|
||||
<span class="p">)</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">project_info</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""list of AlbumInfo objects representing projects for the photo or None if no projects"""</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_project_info</span>
|
||||
<span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
|
||||
<span class="n">project_uuids</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_album_uuids</span><span class="p">(</span><span class="n">project</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_project_info</span> <span class="o">=</span> <span class="p">[</span>
|
||||
<span class="n">ProjectInfo</span><span class="p">(</span><span class="n">db</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="p">,</span> <span class="n">uuid</span><span class="o">=</span><span class="n">album</span><span class="p">)</span> <span class="k">for</span> <span class="n">album</span> <span class="ow">in</span> <span class="n">project_uuids</span>
|
||||
<span class="p">]</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_project_info</span>
|
||||
<span class="n">project_uuids</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_album_uuids</span><span class="p">(</span><span class="n">project</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="n">ProjectInfo</span><span class="p">(</span><span class="n">db</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="p">,</span> <span class="n">uuid</span><span class="o">=</span><span class="n">album</span><span class="p">)</span> <span class="k">for</span> <span class="n">album</span> <span class="ow">in</span> <span class="n">project_uuids</span><span class="p">]</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">keywords</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
@@ -834,8 +820,7 @@
|
||||
<span class="c1"># in this case, return None so result is the same as if title had never been set (which returns NULL)</span>
|
||||
<span class="c1"># issue #512</span>
|
||||
<span class="n">title</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_info</span><span class="p">[</span><span class="s2">"name"</span><span class="p">]</span>
|
||||
<span class="n">title</span> <span class="o">=</span> <span class="kc">None</span> <span class="k">if</span> <span class="n">title</span> <span class="o">==</span> <span class="s2">""</span> <span class="k">else</span> <span class="n">title</span>
|
||||
<span class="k">return</span> <span class="n">title</span>
|
||||
<span class="k">return</span> <span class="kc">None</span> <span class="k">if</span> <span class="n">title</span> <span class="o">==</span> <span class="s2">""</span> <span class="k">else</span> <span class="n">title</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">uuid</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
@@ -862,28 +847,38 @@
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_info</span><span class="p">[</span><span class="s2">"hasAdjustments"</span><span class="p">]</span> <span class="o">==</span> <span class="mi">1</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">adjustments</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""Returns AdjustmentsInfo class for adjustment data or None if no adjustments; Photos 5+ only"""</span>
|
||||
<span class="k">def</span> <span class="nf">adjustments_path</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""Returns path to adjustments file or none if file doesn't exist"""</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_db_version</span> <span class="o"><=</span> <span class="n">_PHOTOS_4_VERSION</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="kc">None</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">hasadjustments</span><span class="p">:</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_adjustmentinfo</span>
|
||||
<span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
|
||||
<span class="n">library</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_library_path</span>
|
||||
<span class="n">directory</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_uuid</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="c1"># first char of uuid</span>
|
||||
<span class="n">plist_file</span> <span class="o">=</span> <span class="p">(</span>
|
||||
<span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">(</span><span class="n">library</span><span class="p">)</span>
|
||||
<span class="o">/</span> <span class="s2">"resources"</span>
|
||||
<span class="o">/</span> <span class="s2">"renders"</span>
|
||||
<span class="o">/</span> <span class="n">directory</span>
|
||||
<span class="o">/</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_uuid</span><span class="si">}</span><span class="s2">.plist"</span>
|
||||
<span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">plist_file</span><span class="o">.</span><span class="n">is_file</span><span class="p">():</span>
|
||||
<span class="k">return</span> <span class="kc">None</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_adjustmentinfo</span> <span class="o">=</span> <span class="n">AdjustmentsInfo</span><span class="p">(</span><span class="n">plist_file</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_adjustmentinfo</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">hasadjustments</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="kc">None</span>
|
||||
|
||||
<span class="n">library</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_library_path</span>
|
||||
<span class="n">directory</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_uuid</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="c1"># first char of uuid</span>
|
||||
<span class="n">plist_file</span> <span class="o">=</span> <span class="p">(</span>
|
||||
<span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">(</span><span class="n">library</span><span class="p">)</span>
|
||||
<span class="o">/</span> <span class="s2">"resources"</span>
|
||||
<span class="o">/</span> <span class="s2">"renders"</span>
|
||||
<span class="o">/</span> <span class="n">directory</span>
|
||||
<span class="o">/</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_uuid</span><span class="si">}</span><span class="s2">.plist"</span>
|
||||
<span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">plist_file</span><span class="o">.</span><span class="n">is_file</span><span class="p">():</span>
|
||||
<span class="k">return</span> <span class="kc">None</span>
|
||||
<span class="k">return</span> <span class="n">plist_file</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">adjustments</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""Returns AdjustmentsInfo class for adjustment data or None if no adjustments; Photos 5+ only"""</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_adjustmentinfo</span>
|
||||
<span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
|
||||
<span class="n">plist_file</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">adjustments_path</span>
|
||||
<span class="k">if</span> <span class="n">plist_file</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="kc">None</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_adjustmentinfo</span> <span class="o">=</span> <span class="n">AdjustmentsInfo</span><span class="p">(</span><span class="n">plist_file</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_adjustmentinfo</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">external_edit</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
@@ -1108,33 +1103,14 @@
|
||||
|
||||
<span class="n">photopath</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_db_version</span> <span class="o"><=</span> <span class="n">_PHOTOS_4_VERSION</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">live_photo</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">ismissing</span><span class="p">:</span>
|
||||
<span class="n">live_model_id</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_info</span><span class="p">[</span><span class="s2">"live_model_id"</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="n">live_model_id</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="sa">f</span><span class="s2">"missing live_model_id: </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_uuid</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
|
||||
<span class="n">photopath</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">folder_id</span><span class="p">,</span> <span class="n">file_id</span><span class="p">,</span> <span class="n">nn_id</span> <span class="o">=</span> <span class="n">_get_resource_loc</span><span class="p">(</span><span class="n">live_model_id</span><span class="p">)</span>
|
||||
<span class="n">library_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">library_path</span>
|
||||
<span class="n">photopath</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
|
||||
<span class="n">library_path</span><span class="p">,</span>
|
||||
<span class="s2">"resources"</span><span class="p">,</span>
|
||||
<span class="s2">"media"</span><span class="p">,</span>
|
||||
<span class="s2">"master"</span><span class="p">,</span>
|
||||
<span class="n">folder_id</span><span class="p">,</span>
|
||||
<span class="n">nn_id</span><span class="p">,</span>
|
||||
<span class="sa">f</span><span class="s2">"jpegvideocomplement_</span><span class="si">{</span><span class="n">file_id</span><span class="si">}</span><span class="s2">.mov"</span><span class="p">,</span>
|
||||
<span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">photopath</span><span class="p">):</span>
|
||||
<span class="c1"># In testing, I've seen occasional missing movie for live photo</span>
|
||||
<span class="c1"># These appear to be valid -- e.g. live component hasn't been downloaded from iCloud</span>
|
||||
<span class="c1"># photos 4 has "isOnDisk" column we could check</span>
|
||||
<span class="c1"># or could do the actual check with "isfile"</span>
|
||||
<span class="c1"># TODO: should this be a warning or debug?</span>
|
||||
<span class="n">photopath</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">photopath</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_path_live_photo_4</span><span class="p">()</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">live_photo</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">path</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">ismissing</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">shared</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_path_live_photo_shared_5</span><span class="p">()</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">syndicated</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">saved_to_library</span><span class="p">:</span>
|
||||
<span class="c1"># syndicated ("Shared with you") photos not yet saved to library</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_path_live_syndicated</span><span class="p">()</span>
|
||||
|
||||
<span class="n">filename</span> <span class="o">=</span> <span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">path</span><span class="p">)</span>
|
||||
<span class="n">photopath</span> <span class="o">=</span> <span class="n">filename</span><span class="o">.</span><span class="n">parent</span><span class="o">.</span><span class="n">joinpath</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">filename</span><span class="o">.</span><span class="n">stem</span><span class="si">}</span><span class="s2">_3.mov"</span><span class="p">)</span>
|
||||
<span class="n">photopath</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">photopath</span><span class="p">)</span>
|
||||
@@ -1148,8 +1124,68 @@
|
||||
|
||||
<span class="k">return</span> <span class="n">photopath</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_path_live_photo_shared_5</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""Return path for live photo for shared photos"""</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">shared</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"photo </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">uuid</span><span class="si">}</span><span class="s2"> is not a shared photo"</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">live_photo</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"photo </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">uuid</span><span class="si">}</span><span class="s2"> is not a live photo"</span><span class="p">)</span>
|
||||
|
||||
<span class="n">photopath</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_path_5_shared</span><span class="p">()</span>
|
||||
<span class="k">if</span> <span class="n">photopath</span><span class="p">:</span>
|
||||
<span class="n">photopath</span> <span class="o">=</span> <span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">(</span><span class="n">photopath</span><span class="p">)</span><span class="o">.</span><span class="n">with_suffix</span><span class="p">(</span><span class="s2">".MOV"</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">photopath</span><span class="o">.</span><span class="n">exists</span><span class="p">():</span>
|
||||
<span class="n">photopath</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="k">return</span> <span class="n">photopath</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_path_live_photo_4</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""Return path for live edited photo for Photos <= 4"""</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">live_photo</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">ismissing</span><span class="p">:</span>
|
||||
<span class="n">live_model_id</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_info</span><span class="p">[</span><span class="s2">"live_model_id"</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="n">live_model_id</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="sa">f</span><span class="s2">"missing live_model_id: </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_uuid</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
|
||||
<span class="n">photopath</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">folder_id</span><span class="p">,</span> <span class="n">file_id</span><span class="p">,</span> <span class="n">nn_id</span> <span class="o">=</span> <span class="n">_get_resource_loc</span><span class="p">(</span><span class="n">live_model_id</span><span class="p">)</span>
|
||||
<span class="n">library_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">library_path</span>
|
||||
<span class="n">photopath</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
|
||||
<span class="n">library_path</span><span class="p">,</span>
|
||||
<span class="s2">"resources"</span><span class="p">,</span>
|
||||
<span class="s2">"media"</span><span class="p">,</span>
|
||||
<span class="s2">"master"</span><span class="p">,</span>
|
||||
<span class="n">folder_id</span><span class="p">,</span>
|
||||
<span class="n">nn_id</span><span class="p">,</span>
|
||||
<span class="sa">f</span><span class="s2">"jpegvideocomplement_</span><span class="si">{</span><span class="n">file_id</span><span class="si">}</span><span class="s2">.mov"</span><span class="p">,</span>
|
||||
<span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">photopath</span><span class="p">):</span>
|
||||
<span class="c1"># In testing, I've seen occasional missing movie for live photo</span>
|
||||
<span class="c1"># These appear to be valid -- e.g. live component hasn't been downloaded from iCloud</span>
|
||||
<span class="c1"># photos 4 has "isOnDisk" column we could check</span>
|
||||
<span class="c1"># or could do the actual check with "isfile"</span>
|
||||
<span class="c1"># TODO: should this be a warning or debug?</span>
|
||||
<span class="n">photopath</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">photopath</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="k">return</span> <span class="n">photopath</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_path_live_syndicated</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""Return path for live syndicated photo on Photos >= version 8"""</span>
|
||||
<span class="c1"># Photos 8+ stores live syndicated photos in a separate directory</span>
|
||||
<span class="c1"># in ~/Photos Library.photoslibrary/scopes/syndication/originals/X/UUID_3.mov</span>
|
||||
<span class="c1"># where X is first digit of UUID</span>
|
||||
<span class="n">syndication_path</span> <span class="o">=</span> <span class="s2">"scopes/syndication/originals"</span>
|
||||
<span class="n">uuid_dir</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">uuid</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
<span class="n">filename</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">filename</span><span class="p">)</span><span class="o">.</span><span class="n">stem</span><span class="si">}</span><span class="s2">_3.mov"</span>
|
||||
<span class="n">live_photo</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_library_path</span><span class="p">,</span>
|
||||
<span class="n">syndication_path</span><span class="p">,</span>
|
||||
<span class="n">uuid_dir</span><span class="p">,</span>
|
||||
<span class="n">filename</span><span class="p">,</span>
|
||||
<span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">live_photo</span> <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">live_photo</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span>
|
||||
|
||||
<span class="nd">@cached_property</span>
|
||||
<span class="k">def</span> <span class="nf">path_derivatives</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="nf">path_derivatives</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">list</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span>
|
||||
<span class="sd">"""Return any derivative (preview) images associated with the photo as a list of paths, sorted by file size (largest first)"""</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_db_version</span> <span class="o"><=</span> <span class="n">_PHOTOS_4_VERSION</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_path_derivatives_4</span><span class="p">()</span>
|
||||
@@ -1158,24 +1194,36 @@
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_path_derivatives_5_shared</span><span class="p">()</span>
|
||||
|
||||
<span class="n">directory</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_uuid</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="c1"># first char of uuid</span>
|
||||
<span class="n">derivative_path</span> <span class="o">=</span> <span class="p">(</span>
|
||||
<span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_library_path</span><span class="p">)</span> <span class="o">/</span> <span class="sa">f</span><span class="s2">"resources/derivatives/</span><span class="si">{</span><span class="n">directory</span><span class="si">}</span><span class="s2">"</span>
|
||||
<span class="p">)</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">syndicated</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">saved_to_library</span><span class="p">:</span>
|
||||
<span class="c1"># syndicated ("Shared with you") photos not yet saved to library</span>
|
||||
<span class="n">derivative_path</span> <span class="o">=</span> <span class="s2">"scopes/syndication/resources/derivatives"</span>
|
||||
<span class="n">thumb_path</span> <span class="o">=</span> <span class="p">(</span>
|
||||
<span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">derivative_path</span><span class="si">}</span><span class="s2">/masters/</span><span class="si">{</span><span class="n">directory</span><span class="si">}</span><span class="s2">/</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">uuid</span><span class="si">}</span><span class="s2">_4_5005_c.jpeg"</span>
|
||||
<span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">derivative_path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"resources/derivatives/</span><span class="si">{</span><span class="n">directory</span><span class="si">}</span><span class="s2">"</span>
|
||||
<span class="n">thumb_path</span> <span class="o">=</span> <span class="p">(</span>
|
||||
<span class="sa">f</span><span class="s2">"resources/derivatives/masters/</span><span class="si">{</span><span class="n">directory</span><span class="si">}</span><span class="s2">/</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">uuid</span><span class="si">}</span><span class="s2">_4_5005_c.jpeg"</span>
|
||||
<span class="p">)</span>
|
||||
|
||||
<span class="n">derivative_path</span> <span class="o">=</span> <span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_library_path</span><span class="p">)</span><span class="o">.</span><span class="n">joinpath</span><span class="p">(</span><span class="n">derivative_path</span><span class="p">)</span>
|
||||
<span class="n">thumb_path</span> <span class="o">=</span> <span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_library_path</span><span class="p">)</span><span class="o">.</span><span class="n">joinpath</span><span class="p">(</span><span class="n">thumb_path</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># find all files that start with uuid in derivative path</span>
|
||||
<span class="n">files</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">derivative_path</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">uuid</span><span class="si">}</span><span class="s2">*.*"</span><span class="p">))</span>
|
||||
|
||||
<span class="c1"># previews may be missing from derivatives path</span>
|
||||
<span class="c1"># there are what appear to be low res thumbnails in the "masters" subfolder</span>
|
||||
<span class="n">thumb_path</span> <span class="o">=</span> <span class="p">(</span>
|
||||
<span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_library_path</span><span class="p">)</span>
|
||||
<span class="o">/</span> <span class="sa">f</span><span class="s2">"resources/derivatives/masters/</span><span class="si">{</span><span class="n">directory</span><span class="si">}</span><span class="s2">/</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">uuid</span><span class="si">}</span><span class="s2">_4_5005_c.jpeg"</span>
|
||||
<span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">thumb_path</span><span class="o">.</span><span class="n">exists</span><span class="p">():</span>
|
||||
<span class="n">files</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">thumb_path</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># sort by file size, largest first</span>
|
||||
<span class="n">files</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">files</span><span class="p">,</span> <span class="n">reverse</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">f</span><span class="p">:</span> <span class="n">f</span><span class="o">.</span><span class="n">stat</span><span class="p">()</span><span class="o">.</span><span class="n">st_size</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># return list of filename but skip .THM files (these are actually low-res thumbnails in JPEG format but with .THM extension)</span>
|
||||
<span class="n">derivatives</span> <span class="o">=</span> <span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span> <span class="k">for</span> <span class="n">filename</span> <span class="ow">in</span> <span class="n">files</span> <span class="k">if</span> <span class="n">filename</span><span class="o">.</span><span class="n">suffix</span> <span class="o">!=</span> <span class="s2">".THM"</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">isphoto</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">derivatives</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span> <span class="ow">and</span> <span class="n">derivatives</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s2">".mov"</span><span class="p">):</span>
|
||||
<span class="c1"># ensure .mov is first in list as poster image could be larger than the movie preview</span>
|
||||
<span class="n">derivatives</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">derivatives</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">derivatives</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">derivatives</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">derivatives</span>
|
||||
@@ -1395,7 +1443,6 @@
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_db_version</span> <span class="o"><=</span> <span class="n">_PHOTOS_4_VERSION</span><span class="p">:</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="sa">f</span><span class="s2">"score not implemented for this database version"</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="kc">None</span>
|
||||
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
@@ -1495,6 +1542,38 @@
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_search_info_normalized</span> <span class="o">=</span> <span class="n">SearchInfo</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">normalized</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_search_info_normalized</span>
|
||||
|
||||
<span class="nd">@cached_property</span>
|
||||
<span class="k">def</span> <span class="nf">syndicated</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span> <span class="o">|</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="sd">"""Return true if photo was shared via syndication (e.g. via Messages, etc.);</span>
|
||||
<span class="sd"> these are photos that appear in "Shared with you" album.</span>
|
||||
<span class="sd"> Photos 8+ only; returns None if not Photos 8+.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">photos_version</span> <span class="o"><</span> <span class="mi">8</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="kc">None</span>
|
||||
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="p">(</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_db_syndication_uuid</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">uuid</span><span class="p">][</span><span class="s2">"syndication_identifier"</span><span class="p">]</span>
|
||||
<span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span>
|
||||
<span class="p">)</span>
|
||||
<span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="kc">False</span>
|
||||
|
||||
<span class="nd">@cached_property</span>
|
||||
<span class="k">def</span> <span class="nf">saved_to_library</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span> <span class="o">|</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="sd">"""Return True if syndicated photo has been saved to library;</span>
|
||||
<span class="sd"> returns False if photo is not syndicated or has not been saved to the library.</span>
|
||||
<span class="sd"> Returns None if not Photos 8+.</span>
|
||||
<span class="sd"> Syndicated photos are photos that appear in "Shared with you" album; Photos 8+ only.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">photos_version</span> <span class="o"><</span> <span class="mi">8</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="kc">None</span>
|
||||
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_db_syndication_uuid</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">uuid</span><span class="p">][</span><span class="s2">"syndication_history"</span><span class="p">]</span> <span class="o">!=</span> <span class="mi">0</span>
|
||||
<span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="kc">False</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">labels</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""returns list of labels applied to photo by Photos image categorization</span>
|
||||
@@ -1541,7 +1620,6 @@
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_db_version</span> <span class="o"><=</span> <span class="n">_PHOTOS_4_VERSION</span><span class="p">:</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="sa">f</span><span class="s2">"exif_info not implemented for this database version"</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="kc">None</span>
|
||||
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
@@ -1624,11 +1702,14 @@
|
||||
<span class="k">def</span> <span class="nf">hexdigest</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""Returns a unique digest of the photo's properties and metadata;</span>
|
||||
<span class="sd"> useful for detecting changes in any property/metadata of the photo"""</span>
|
||||
<span class="k">return</span> <span class="n">hexdigest</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">json</span><span class="p">())</span>
|
||||
<span class="k">return</span> <span class="n">hexdigest</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_json_hexdigest</span><span class="p">())</span>
|
||||
|
||||
<span class="nd">@cached_property</span>
|
||||
<span class="k">def</span> <span class="nf">cloud_metadata</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Dict</span><span class="p">:</span>
|
||||
<span class="sd">"""Returns contents of ZCLOUDMASTERMEDIAMETADATA as dict"""</span>
|
||||
<span class="k">def</span> <span class="nf">cloud_metadata</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">dict</span><span class="p">[</span><span class="n">Any</span><span class="p">,</span> <span class="n">Any</span><span class="p">]:</span>
|
||||
<span class="sd">"""Returns contents of ZCLOUDMASTERMEDIAMETADATA as dict; Photos 5+ only"""</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_db_version</span> <span class="o"><=</span> <span class="n">_PHOTOS_4_VERSION</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="p">{}</span>
|
||||
|
||||
<span class="c1"># This is a large blob of data so don't load it unless requested</span>
|
||||
<span class="n">asset_table</span> <span class="o">=</span> <span class="n">_DB_TABLE_NAMES</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_photos_ver</span><span class="p">][</span><span class="s2">"ASSET"</span><span class="p">]</span>
|
||||
<span class="n">sql_cloud_metadata</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"""</span>
|
||||
@@ -1639,10 +1720,6 @@
|
||||
<span class="s2"> WHERE </span><span class="si">{</span><span class="n">asset_table</span><span class="si">}</span><span class="s2">.ZUUID = ?</span>
|
||||
<span class="s2"> """</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_db_version</span> <span class="o"><=</span> <span class="n">_PHOTOS_4_VERSION</span><span class="p">:</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="sa">f</span><span class="s2">"cloud_metadata not implemented for this database version"</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="p">{}</span>
|
||||
|
||||
<span class="n">_</span><span class="p">,</span> <span class="n">cursor</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">get_db_connection</span><span class="p">()</span>
|
||||
<span class="n">metadata</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
<span class="k">if</span> <span class="n">results</span> <span class="o">:=</span> <span class="n">cursor</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="n">sql_cloud_metadata</span><span class="p">,</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">uuid</span><span class="p">,))</span><span class="o">.</span><span class="n">fetchone</span><span class="p">():</span>
|
||||
@@ -1697,6 +1774,8 @@
|
||||
|
||||
<span class="k">def</span> <span class="nf">_detected_text</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""detect text in photo, either from cached extended attribute or by attempting text detection"""</span>
|
||||
<span class="n">assert_macos</span><span class="p">()</span>
|
||||
|
||||
<span class="n">path</span> <span class="o">=</span> <span class="p">(</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">path_edited</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">hasadjustments</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">path_edited</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">path</span>
|
||||
<span class="p">)</span>
|
||||
@@ -1976,97 +2055,189 @@
|
||||
<span class="p">}</span>
|
||||
<span class="k">return</span> <span class="n">yaml</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">info</span><span class="p">,</span> <span class="n">sort_keys</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
|
||||
|
||||
<div class="viewcode-block" id="PhotoInfo.asdict"><a class="viewcode-back" href="../../reference.html#osxphotos.PhotoInfo.asdict">[docs]</a> <span class="k">def</span> <span class="nf">asdict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""return dict representation"""</span>
|
||||
<div class="viewcode-block" id="PhotoInfo.asdict"><a class="viewcode-back" href="../../reference.html#osxphotos.PhotoInfo.asdict">[docs]</a> <span class="k">def</span> <span class="nf">asdict</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">shallow</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="nb">dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Any</span><span class="p">]:</span>
|
||||
<span class="sd">"""Return dict representation of PhotoInfo object.</span>
|
||||
|
||||
<span class="sd"> Args:</span>
|
||||
<span class="sd"> shallow: if True, return shallow representation (does not contain folder_info, person_info, etc.)</span>
|
||||
|
||||
<span class="sd"> Returns:</span>
|
||||
<span class="sd"> dict representation of PhotoInfo object</span>
|
||||
|
||||
<span class="sd"> Note:</span>
|
||||
<span class="sd"> The shallow representation is used internally by export as it contains only the subset of data needed for export.</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="n">comments</span> <span class="o">=</span> <span class="p">[</span><span class="n">comment</span><span class="o">.</span><span class="n">asdict</span><span class="p">()</span> <span class="k">for</span> <span class="n">comment</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span><span class="p">]</span>
|
||||
<span class="n">exif_info</span> <span class="o">=</span> <span class="n">dataclasses</span><span class="o">.</span><span class="n">asdict</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">exif_info</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">exif_info</span> <span class="k">else</span> <span class="p">{}</span>
|
||||
<span class="n">face_info</span> <span class="o">=</span> <span class="p">[</span><span class="n">face</span><span class="o">.</span><span class="n">asdict</span><span class="p">()</span> <span class="k">for</span> <span class="n">face</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">face_info</span><span class="p">]</span>
|
||||
<span class="n">folders</span> <span class="o">=</span> <span class="p">{</span><span class="n">album</span><span class="o">.</span><span class="n">title</span><span class="p">:</span> <span class="n">album</span><span class="o">.</span><span class="n">folder_names</span> <span class="k">for</span> <span class="n">album</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">album_info</span><span class="p">}</span>
|
||||
<span class="n">exif</span> <span class="o">=</span> <span class="n">dataclasses</span><span class="o">.</span><span class="n">asdict</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">exif_info</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">exif_info</span> <span class="k">else</span> <span class="p">{}</span>
|
||||
<span class="n">likes</span> <span class="o">=</span> <span class="p">[</span><span class="n">like</span><span class="o">.</span><span class="n">asdict</span><span class="p">()</span> <span class="k">for</span> <span class="n">like</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">likes</span><span class="p">]</span>
|
||||
<span class="n">place</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">place</span><span class="o">.</span><span class="n">asdict</span><span class="p">()</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">place</span> <span class="k">else</span> <span class="p">{}</span>
|
||||
<span class="n">score</span> <span class="o">=</span> <span class="n">dataclasses</span><span class="o">.</span><span class="n">asdict</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">score</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">score</span> <span class="k">else</span> <span class="p">{}</span>
|
||||
<span class="n">comments</span> <span class="o">=</span> <span class="p">[</span><span class="n">comment</span><span class="o">.</span><span class="n">asdict</span><span class="p">()</span> <span class="k">for</span> <span class="n">comment</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span><span class="p">]</span>
|
||||
<span class="n">likes</span> <span class="o">=</span> <span class="p">[</span><span class="n">like</span><span class="o">.</span><span class="n">asdict</span><span class="p">()</span> <span class="k">for</span> <span class="n">like</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">likes</span><span class="p">]</span>
|
||||
<span class="n">faces</span> <span class="o">=</span> <span class="p">[</span><span class="n">face</span><span class="o">.</span><span class="n">asdict</span><span class="p">()</span> <span class="k">for</span> <span class="n">face</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">face_info</span><span class="p">]</span>
|
||||
<span class="n">search_info</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">search_info</span><span class="o">.</span><span class="n">asdict</span><span class="p">()</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">search_info</span> <span class="k">else</span> <span class="p">{}</span>
|
||||
|
||||
<span class="k">return</span> <span class="p">{</span>
|
||||
<span class="s2">"library"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_library_path</span><span class="p">,</span>
|
||||
<span class="s2">"uuid"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">uuid</span><span class="p">,</span>
|
||||
<span class="s2">"filename"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">filename</span><span class="p">,</span>
|
||||
<span class="s2">"original_filename"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">original_filename</span><span class="p">,</span>
|
||||
<span class="s2">"date"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">date</span><span class="p">,</span>
|
||||
<span class="s2">"description"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">description</span><span class="p">,</span>
|
||||
<span class="s2">"title"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">title</span><span class="p">,</span>
|
||||
<span class="s2">"keywords"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">keywords</span><span class="p">,</span>
|
||||
<span class="s2">"labels"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">labels</span><span class="p">,</span>
|
||||
<span class="s2">"keywords"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">keywords</span><span class="p">,</span>
|
||||
<span class="n">dict_data</span> <span class="o">=</span> <span class="p">{</span>
|
||||
<span class="s2">"albums"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">albums</span><span class="p">,</span>
|
||||
<span class="s2">"folders"</span><span class="p">:</span> <span class="n">folders</span><span class="p">,</span>
|
||||
<span class="s2">"persons"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">persons</span><span class="p">,</span>
|
||||
<span class="s2">"faces"</span><span class="p">:</span> <span class="n">faces</span><span class="p">,</span>
|
||||
<span class="s2">"path"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">path</span><span class="p">,</span>
|
||||
<span class="s2">"ismissing"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">ismissing</span><span class="p">,</span>
|
||||
<span class="s2">"hasadjustments"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">hasadjustments</span><span class="p">,</span>
|
||||
<span class="s2">"external_edit"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">external_edit</span><span class="p">,</span>
|
||||
<span class="s2">"favorite"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">favorite</span><span class="p">,</span>
|
||||
<span class="s2">"hidden"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">hidden</span><span class="p">,</span>
|
||||
<span class="s2">"latitude"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_latitude</span><span class="p">,</span>
|
||||
<span class="s2">"longitude"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_longitude</span><span class="p">,</span>
|
||||
<span class="s2">"path_edited"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">path_edited</span><span class="p">,</span>
|
||||
<span class="s2">"shared"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">shared</span><span class="p">,</span>
|
||||
<span class="s2">"isphoto"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">isphoto</span><span class="p">,</span>
|
||||
<span class="s2">"ismovie"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">ismovie</span><span class="p">,</span>
|
||||
<span class="s2">"uti"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">uti</span><span class="p">,</span>
|
||||
<span class="s2">"uti_original"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">uti_original</span><span class="p">,</span>
|
||||
<span class="s2">"burst"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">burst</span><span class="p">,</span>
|
||||
<span class="s2">"live_photo"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">live_photo</span><span class="p">,</span>
|
||||
<span class="s2">"path_live_photo"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">path_live_photo</span><span class="p">,</span>
|
||||
<span class="s2">"iscloudasset"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">iscloudasset</span><span class="p">,</span>
|
||||
<span class="s2">"incloud"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">incloud</span><span class="p">,</span>
|
||||
<span class="s2">"isreference"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">isreference</span><span class="p">,</span>
|
||||
<span class="s2">"date_modified"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">date_modified</span><span class="p">,</span>
|
||||
<span class="s2">"portrait"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">portrait</span><span class="p">,</span>
|
||||
<span class="s2">"screenshot"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">screenshot</span><span class="p">,</span>
|
||||
<span class="s2">"slow_mo"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">slow_mo</span><span class="p">,</span>
|
||||
<span class="s2">"time_lapse"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">time_lapse</span><span class="p">,</span>
|
||||
<span class="s2">"hdr"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">hdr</span><span class="p">,</span>
|
||||
<span class="s2">"selfie"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">selfie</span><span class="p">,</span>
|
||||
<span class="s2">"panorama"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">panorama</span><span class="p">,</span>
|
||||
<span class="s2">"has_raw"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">has_raw</span><span class="p">,</span>
|
||||
<span class="s2">"israw"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">israw</span><span class="p">,</span>
|
||||
<span class="s2">"raw_original"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">raw_original</span><span class="p">,</span>
|
||||
<span class="s2">"uti_raw"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">uti_raw</span><span class="p">,</span>
|
||||
<span class="s2">"path_raw"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">path_raw</span><span class="p">,</span>
|
||||
<span class="s2">"place"</span><span class="p">:</span> <span class="n">place</span><span class="p">,</span>
|
||||
<span class="s2">"exif"</span><span class="p">:</span> <span class="n">exif</span><span class="p">,</span>
|
||||
<span class="s2">"score"</span><span class="p">:</span> <span class="n">score</span><span class="p">,</span>
|
||||
<span class="s2">"intrash"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">intrash</span><span class="p">,</span>
|
||||
<span class="s2">"height"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">height</span><span class="p">,</span>
|
||||
<span class="s2">"width"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">width</span><span class="p">,</span>
|
||||
<span class="s2">"orientation"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">orientation</span><span class="p">,</span>
|
||||
<span class="s2">"original_height"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">original_height</span><span class="p">,</span>
|
||||
<span class="s2">"original_width"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">original_width</span><span class="p">,</span>
|
||||
<span class="s2">"original_orientation"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">original_orientation</span><span class="p">,</span>
|
||||
<span class="s2">"original_filesize"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">original_filesize</span><span class="p">,</span>
|
||||
<span class="s2">"comments"</span><span class="p">:</span> <span class="n">comments</span><span class="p">,</span>
|
||||
<span class="s2">"likes"</span><span class="p">:</span> <span class="n">likes</span><span class="p">,</span>
|
||||
<span class="s2">"search_info"</span><span class="p">:</span> <span class="n">search_info</span><span class="p">,</span>
|
||||
<span class="s2">"fingerprint"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">fingerprint</span><span class="p">,</span>
|
||||
<span class="s2">"cloud_guid"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">cloud_guid</span><span class="p">,</span>
|
||||
<span class="s2">"cloud_owner_hashed_id"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">cloud_owner_hashed_id</span><span class="p">,</span>
|
||||
<span class="p">}</span></div>
|
||||
<span class="s2">"comments"</span><span class="p">:</span> <span class="n">comments</span><span class="p">,</span>
|
||||
<span class="s2">"date_added"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">date_added</span><span class="p">,</span>
|
||||
<span class="s2">"date_modified"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">date_modified</span><span class="p">,</span>
|
||||
<span class="s2">"date_trashed"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">date_trashed</span><span class="p">,</span>
|
||||
<span class="s2">"date"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">date</span><span class="p">,</span>
|
||||
<span class="s2">"description"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">description</span><span class="p">,</span>
|
||||
<span class="s2">"exif_info"</span><span class="p">:</span> <span class="n">exif_info</span><span class="p">,</span>
|
||||
<span class="s2">"external_edit"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">external_edit</span><span class="p">,</span>
|
||||
<span class="s2">"face_info"</span><span class="p">:</span> <span class="n">face_info</span><span class="p">,</span>
|
||||
<span class="s2">"favorite"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">favorite</span><span class="p">,</span>
|
||||
<span class="s2">"filename"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">filename</span><span class="p">,</span>
|
||||
<span class="s2">"fingerprint"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">fingerprint</span><span class="p">,</span>
|
||||
<span class="s2">"folders"</span><span class="p">:</span> <span class="n">folders</span><span class="p">,</span>
|
||||
<span class="s2">"has_raw"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">has_raw</span><span class="p">,</span>
|
||||
<span class="s2">"hasadjustments"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">hasadjustments</span><span class="p">,</span>
|
||||
<span class="s2">"hdr"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">hdr</span><span class="p">,</span>
|
||||
<span class="s2">"height"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">height</span><span class="p">,</span>
|
||||
<span class="s2">"hidden"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">hidden</span><span class="p">,</span>
|
||||
<span class="s2">"incloud"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">incloud</span><span class="p">,</span>
|
||||
<span class="s2">"intrash"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">intrash</span><span class="p">,</span>
|
||||
<span class="s2">"iscloudasset"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">iscloudasset</span><span class="p">,</span>
|
||||
<span class="s2">"ismissing"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">ismissing</span><span class="p">,</span>
|
||||
<span class="s2">"ismovie"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">ismovie</span><span class="p">,</span>
|
||||
<span class="s2">"isphoto"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">isphoto</span><span class="p">,</span>
|
||||
<span class="s2">"israw"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">israw</span><span class="p">,</span>
|
||||
<span class="s2">"isreference"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">isreference</span><span class="p">,</span>
|
||||
<span class="s2">"keywords"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">keywords</span><span class="p">,</span>
|
||||
<span class="s2">"labels"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">labels</span><span class="p">,</span>
|
||||
<span class="s2">"latitude"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_latitude</span><span class="p">,</span>
|
||||
<span class="s2">"library"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_library_path</span><span class="p">,</span>
|
||||
<span class="s2">"likes"</span><span class="p">:</span> <span class="n">likes</span><span class="p">,</span>
|
||||
<span class="s2">"live_photo"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">live_photo</span><span class="p">,</span>
|
||||
<span class="s2">"location"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">location</span><span class="p">,</span>
|
||||
<span class="s2">"longitude"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_longitude</span><span class="p">,</span>
|
||||
<span class="s2">"orientation"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">orientation</span><span class="p">,</span>
|
||||
<span class="s2">"original_filename"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">original_filename</span><span class="p">,</span>
|
||||
<span class="s2">"original_filesize"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">original_filesize</span><span class="p">,</span>
|
||||
<span class="s2">"original_height"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">original_height</span><span class="p">,</span>
|
||||
<span class="s2">"original_orientation"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">original_orientation</span><span class="p">,</span>
|
||||
<span class="s2">"original_width"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">original_width</span><span class="p">,</span>
|
||||
<span class="s2">"owner"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">owner</span><span class="p">,</span>
|
||||
<span class="s2">"panorama"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">panorama</span><span class="p">,</span>
|
||||
<span class="s2">"path_edited_live_photo"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">path_edited_live_photo</span><span class="p">,</span>
|
||||
<span class="s2">"path_edited"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">path_edited</span><span class="p">,</span>
|
||||
<span class="s2">"path_live_photo"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">path_live_photo</span><span class="p">,</span>
|
||||
<span class="s2">"path_raw"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">path_raw</span><span class="p">,</span>
|
||||
<span class="s2">"path"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">path</span><span class="p">,</span>
|
||||
<span class="s2">"persons"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">persons</span><span class="p">,</span>
|
||||
<span class="s2">"place"</span><span class="p">:</span> <span class="n">place</span><span class="p">,</span>
|
||||
<span class="s2">"portrait"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">portrait</span><span class="p">,</span>
|
||||
<span class="s2">"raw_original"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">raw_original</span><span class="p">,</span>
|
||||
<span class="s2">"score"</span><span class="p">:</span> <span class="n">score</span><span class="p">,</span>
|
||||
<span class="s2">"screenshot"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">screenshot</span><span class="p">,</span>
|
||||
<span class="s2">"selfie"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">selfie</span><span class="p">,</span>
|
||||
<span class="s2">"shared"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">shared</span><span class="p">,</span>
|
||||
<span class="s2">"slow_mo"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">slow_mo</span><span class="p">,</span>
|
||||
<span class="s2">"time_lapse"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">time_lapse</span><span class="p">,</span>
|
||||
<span class="s2">"title"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">title</span><span class="p">,</span>
|
||||
<span class="s2">"tzoffset"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">tzoffset</span><span class="p">,</span>
|
||||
<span class="s2">"uti_edited"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">uti_edited</span><span class="p">,</span>
|
||||
<span class="s2">"uti_original"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">uti_original</span><span class="p">,</span>
|
||||
<span class="s2">"uti_raw"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">uti_raw</span><span class="p">,</span>
|
||||
<span class="s2">"uti"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">uti</span><span class="p">,</span>
|
||||
<span class="s2">"uuid"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">uuid</span><span class="p">,</span>
|
||||
<span class="s2">"visible"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">visible</span><span class="p">,</span>
|
||||
<span class="s2">"width"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">width</span><span class="p">,</span>
|
||||
<span class="p">}</span>
|
||||
|
||||
<div class="viewcode-block" id="PhotoInfo.json"><a class="viewcode-back" href="../../reference.html#osxphotos.PhotoInfo.json">[docs]</a> <span class="k">def</span> <span class="nf">json</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""Return JSON representation"""</span>
|
||||
<span class="c1"># non-shallow keys</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">shallow</span><span class="p">:</span>
|
||||
<span class="n">dict_data</span><span class="p">[</span><span class="s2">"album_info"</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="n">album</span><span class="o">.</span><span class="n">asdict</span><span class="p">()</span> <span class="k">for</span> <span class="n">album</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">album_info</span><span class="p">]</span>
|
||||
<span class="n">dict_data</span><span class="p">[</span><span class="s2">"path_derivatives"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">path_derivatives</span>
|
||||
<span class="n">dict_data</span><span class="p">[</span><span class="s2">"adjustments"</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">adjustments</span><span class="o">.</span><span class="n">asdict</span><span class="p">()</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">adjustments</span> <span class="k">else</span> <span class="p">{}</span>
|
||||
<span class="p">)</span>
|
||||
<span class="n">dict_data</span><span class="p">[</span><span class="s2">"burst_album_info"</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="n">a</span><span class="o">.</span><span class="n">asdict</span><span class="p">()</span> <span class="k">for</span> <span class="n">a</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">burst_album_info</span><span class="p">]</span>
|
||||
<span class="n">dict_data</span><span class="p">[</span><span class="s2">"burst_albums"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">burst_albums</span>
|
||||
<span class="n">dict_data</span><span class="p">[</span><span class="s2">"burst_default_pick"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">burst_default_pick</span>
|
||||
<span class="n">dict_data</span><span class="p">[</span><span class="s2">"burst_key"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">burst_key</span>
|
||||
<span class="n">dict_data</span><span class="p">[</span><span class="s2">"burst_photos"</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="n">p</span><span class="o">.</span><span class="n">uuid</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">burst_photos</span><span class="p">]</span>
|
||||
<span class="n">dict_data</span><span class="p">[</span><span class="s2">"burst_selected"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">burst_selected</span>
|
||||
<span class="n">dict_data</span><span class="p">[</span><span class="s2">"cloud_metadata"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">cloud_metadata</span>
|
||||
<span class="n">dict_data</span><span class="p">[</span><span class="s2">"import_info"</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">import_info</span><span class="o">.</span><span class="n">asdict</span><span class="p">()</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">import_info</span> <span class="k">else</span> <span class="p">{}</span>
|
||||
<span class="p">)</span>
|
||||
<span class="n">dict_data</span><span class="p">[</span><span class="s2">"labels_normalized"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">labels_normalized</span>
|
||||
<span class="n">dict_data</span><span class="p">[</span><span class="s2">"person_info"</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="n">p</span><span class="o">.</span><span class="n">asdict</span><span class="p">()</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">person_info</span><span class="p">]</span>
|
||||
<span class="n">dict_data</span><span class="p">[</span><span class="s2">"project_info"</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="n">p</span><span class="o">.</span><span class="n">asdict</span><span class="p">()</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">project_info</span><span class="p">]</span>
|
||||
<span class="n">dict_data</span><span class="p">[</span><span class="s2">"search_info"</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">search_info</span><span class="o">.</span><span class="n">asdict</span><span class="p">()</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">search_info</span> <span class="k">else</span> <span class="p">{}</span>
|
||||
<span class="p">)</span>
|
||||
<span class="n">dict_data</span><span class="p">[</span><span class="s2">"search_info_normalized"</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">search_info_normalized</span><span class="o">.</span><span class="n">asdict</span><span class="p">()</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">search_info_normalized</span>
|
||||
<span class="k">else</span> <span class="p">{}</span>
|
||||
<span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">dict_data</span></div>
|
||||
|
||||
<div class="viewcode-block" id="PhotoInfo.json"><a class="viewcode-back" href="../../reference.html#osxphotos.PhotoInfo.json">[docs]</a> <span class="k">def</span> <span class="nf">json</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">indent</span><span class="p">:</span> <span class="nb">int</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">shallow</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span>
|
||||
<span class="sd">"""Return JSON representation</span>
|
||||
|
||||
<span class="sd"> Args:</span>
|
||||
<span class="sd"> indent: indent level for JSON, if None, no indent</span>
|
||||
<span class="sd"> shallow: if True, return shallow JSON representation (does not contain folder_info, person_info, etc.)</span>
|
||||
|
||||
<span class="sd"> Returns:</span>
|
||||
<span class="sd"> JSON string</span>
|
||||
|
||||
<span class="sd"> Note:</span>
|
||||
<span class="sd"> The shallow representation is used internally by export as it contains only the subset of data needed for export.</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">default</span><span class="p">(</span><span class="n">o</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">o</span><span class="p">,</span> <span class="p">(</span><span class="n">datetime</span><span class="o">.</span><span class="n">date</span><span class="p">,</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="p">)):</span>
|
||||
<span class="k">return</span> <span class="n">o</span><span class="o">.</span><span class="n">isoformat</span><span class="p">()</span>
|
||||
|
||||
<span class="n">dict_data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">asdict</span><span class="p">()</span>
|
||||
<span class="n">dict_data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">asdict</span><span class="p">(</span><span class="n">shallow</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="k">if</span> <span class="n">shallow</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">asdict</span><span class="p">(</span><span class="n">shallow</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">dict_data</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
|
||||
<span class="c1"># sort lists such as keywords so JSON is consistent</span>
|
||||
<span class="c1"># but do not sort certain items like location</span>
|
||||
<span class="k">if</span> <span class="n">k</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">"location"</span><span class="p">]:</span>
|
||||
<span class="k">continue</span>
|
||||
<span class="k">if</span> <span class="n">v</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">))</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">v</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="nb">dict</span><span class="p">):</span>
|
||||
<span class="n">dict_data</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">v</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">dict_data</span><span class="p">,</span> <span class="n">sort_keys</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="n">default</span><span class="p">)</span></div>
|
||||
<span class="n">dict_data</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">v</span><span class="p">:</span> <span class="n">v</span> <span class="k">if</span> <span class="n">v</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="s2">""</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">dict_data</span><span class="p">,</span> <span class="n">sort_keys</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="n">default</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="n">indent</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="PhotoInfo.tables"><a class="viewcode-back" href="../../reference.html#osxphotos.PhotoInfo.tables">[docs]</a> <span class="k">def</span> <span class="nf">tables</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">PhotoTables</span><span class="p">:</span>
|
||||
<span class="sd">"""Return PhotoTables object to provide access database tables associated with this photo (Photos 5+)"""</span>
|
||||
<span class="k">return</span> <span class="kc">None</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_db</span><span class="o">.</span><span class="n">_photos_ver</span> <span class="o"><</span> <span class="mi">5</span> <span class="k">else</span> <span class="n">PhotoTables</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span></div>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_json_hexdigest</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""JSON for use by hexdigest()"""</span>
|
||||
|
||||
<span class="c1"># This differs from json() because hexdigest must not change if metadata changed</span>
|
||||
<span class="c1"># With json(), sort order of lists of dicts is not consistent but these aren't needed</span>
|
||||
<span class="c1"># for computing hexdigest so we can ignore them</span>
|
||||
<span class="c1"># also don't use visible because it changes based on Photos UI state</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">default</span><span class="p">(</span><span class="n">o</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">o</span><span class="p">,</span> <span class="p">(</span><span class="n">datetime</span><span class="o">.</span><span class="n">date</span><span class="p">,</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="p">)):</span>
|
||||
<span class="k">return</span> <span class="n">o</span><span class="o">.</span><span class="n">isoformat</span><span class="p">()</span>
|
||||
|
||||
<span class="n">dict_data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">asdict</span><span class="p">(</span><span class="n">shallow</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">"face_info"</span><span class="p">,</span> <span class="s2">"visible"</span><span class="p">]:</span>
|
||||
<span class="k">del</span> <span class="n">dict_data</span><span class="p">[</span><span class="n">k</span><span class="p">]</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">dict_data</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
|
||||
<span class="c1"># sort lists such as keywords so JSON is consistent</span>
|
||||
<span class="c1"># but do not sort certain items like location</span>
|
||||
<span class="k">if</span> <span class="n">k</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">"location"</span><span class="p">]:</span>
|
||||
<span class="k">continue</span>
|
||||
<span class="k">if</span> <span class="n">v</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">))</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">v</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="nb">dict</span><span class="p">):</span>
|
||||
<span class="n">dict_data</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">v</span><span class="p">:</span> <span class="n">v</span> <span class="k">if</span> <span class="n">v</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="s2">""</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">dict_data</span><span class="p">,</span> <span class="n">sort_keys</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="n">default</span><span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__eq__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
|
||||
<span class="sd">"""Compare two PhotoInfo objects for equality"""</span>
|
||||
@@ -2090,13 +2261,114 @@
|
||||
|
||||
|
||||
<span class="k">class</span> <span class="nc">PhotoInfoNone</span><span class="p">:</span>
|
||||
<span class="sd">"""mock class that returns None for all attributes"""</span>
|
||||
<span class="sd">"""Mock class that returns None for all attributes"""</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">pass</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__getattribute__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="kc">None</span>
|
||||
|
||||
|
||||
<span class="k">def</span> <span class="nf">frozen_photoinfo_factory</span><span class="p">(</span><span class="n">photo</span><span class="p">:</span> <span class="n">PhotoInfo</span><span class="p">)</span> <span class="o">-></span> <span class="n">SimpleNamespace</span><span class="p">:</span>
|
||||
<span class="sd">"""Return a frozen SimpleNamespace object for a PhotoInfo object"""</span>
|
||||
<span class="n">photo_json</span> <span class="o">=</span> <span class="n">photo</span><span class="o">.</span><span class="n">json</span><span class="p">()</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_object_hook</span><span class="p">(</span><span class="n">d</span><span class="p">:</span> <span class="nb">dict</span><span class="p">[</span><span class="n">Any</span><span class="p">,</span> <span class="n">Any</span><span class="p">]):</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">d</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">d</span>
|
||||
|
||||
<span class="c1"># if d key matches a ISO 8601 datetime ('2023-03-24T06:46:57.690786', '2019-07-04T16:24:01-07:00', '2019-07-04T16:24:01+07:00'), convert to datetime</span>
|
||||
<span class="c1"># fromisoformat will also handle dates with timezone offset in form +0700, etc.</span>
|
||||
<span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">d</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="nb">str</span><span class="p">)</span> <span class="ow">and</span> <span class="n">re</span><span class="o">.</span><span class="n">match</span><span class="p">(</span>
|
||||
<span class="sa">r</span><span class="s2">"\d</span><span class="si">{4}</span><span class="s2">-\d</span><span class="si">{2}</span><span class="s2">-\d</span><span class="si">{2}</span><span class="s2">T\d</span><span class="si">{2}</span><span class="s2">:\d</span><span class="si">{2}</span><span class="s2">:\d</span><span class="si">{2}</span><span class="s2">[.]?\d*[+-]?\d</span><span class="si">{2}</span><span class="s2">[:]?\d</span><span class="si">{2}</span><span class="s2">?"</span><span class="p">,</span> <span class="n">v</span>
|
||||
<span class="p">):</span>
|
||||
<span class="n">d</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">fromisoformat</span><span class="p">(</span><span class="n">v</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">SimpleNamespace</span><span class="p">(</span><span class="o">**</span><span class="n">d</span><span class="p">)</span>
|
||||
|
||||
<span class="n">frozen</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span><span class="n">photo_json</span><span class="p">,</span> <span class="n">object_hook</span><span class="o">=</span><span class="k">lambda</span> <span class="n">d</span><span class="p">:</span> <span class="n">_object_hook</span><span class="p">(</span><span class="n">d</span><span class="p">))</span>
|
||||
|
||||
<span class="c1"># add on json() method to frozen object</span>
|
||||
<span class="k">def</span> <span class="nf">_json</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="n">photo_json</span>
|
||||
|
||||
<span class="n">frozen</span><span class="o">.</span><span class="n">json</span> <span class="o">=</span> <span class="n">_json</span>
|
||||
|
||||
<span class="c1"># add hexdigest property to frozen object</span>
|
||||
<span class="n">frozen</span><span class="o">.</span><span class="n">hexdigest</span> <span class="o">=</span> <span class="n">photo</span><span class="o">.</span><span class="n">hexdigest</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">detected_text</span><span class="p">(</span><span class="n">confidence_threshold</span><span class="o">=</span><span class="n">TEXT_DETECTION_CONFIDENCE_THRESHOLD</span><span class="p">):</span>
|
||||
<span class="sd">"""Detects text in photo and returns lists of results as (detected text, confidence)</span>
|
||||
|
||||
<span class="sd"> confidence_threshold: float between 0.0 and 1.0. If text detection confidence is below this threshold,</span>
|
||||
<span class="sd"> text will not be returned. Default is TEXT_DETECTION_CONFIDENCE_THRESHOLD</span>
|
||||
|
||||
<span class="sd"> If photo is edited, uses the edited photo, otherwise the original; falls back to the preview image if neither edited or original is available</span>
|
||||
|
||||
<span class="sd"> Returns: list of (detected text, confidence) tuples</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">frozen</span><span class="o">.</span><span class="n">_detected_text_cache</span><span class="p">[</span><span class="n">confidence_threshold</span><span class="p">]</span>
|
||||
<span class="k">except</span> <span class="p">(</span><span class="ne">AttributeError</span><span class="p">,</span> <span class="ne">KeyError</span><span class="p">)</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="ne">AttributeError</span><span class="p">):</span>
|
||||
<span class="n">frozen</span><span class="o">.</span><span class="n">_detected_text_cache</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">detected_text</span> <span class="o">=</span> <span class="n">frozen</span><span class="o">.</span><span class="n">_detected_text</span><span class="p">()</span>
|
||||
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
|
||||
<span class="n">logging</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Error detecting text in photo </span><span class="si">{</span><span class="n">frozen</span><span class="o">.</span><span class="n">uuid</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="n">e</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
|
||||
<span class="n">detected_text</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
|
||||
<span class="n">frozen</span><span class="o">.</span><span class="n">_detected_text_cache</span><span class="p">[</span><span class="n">confidence_threshold</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span>
|
||||
<span class="p">(</span><span class="n">text</span><span class="p">,</span> <span class="n">confidence</span><span class="p">)</span>
|
||||
<span class="k">for</span> <span class="n">text</span><span class="p">,</span> <span class="n">confidence</span> <span class="ow">in</span> <span class="n">detected_text</span>
|
||||
<span class="k">if</span> <span class="n">confidence</span> <span class="o">>=</span> <span class="n">confidence_threshold</span>
|
||||
<span class="p">]</span>
|
||||
<span class="k">return</span> <span class="n">frozen</span><span class="o">.</span><span class="n">_detected_text_cache</span><span class="p">[</span><span class="n">confidence_threshold</span><span class="p">]</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_detected_text</span><span class="p">():</span>
|
||||
<span class="sd">"""detect text in photo, either from cached extended attribute or by attempting text detection"""</span>
|
||||
<span class="n">path</span> <span class="o">=</span> <span class="p">(</span>
|
||||
<span class="n">frozen</span><span class="o">.</span><span class="n">path_edited</span>
|
||||
<span class="k">if</span> <span class="n">frozen</span><span class="o">.</span><span class="n">hasadjustments</span> <span class="ow">and</span> <span class="n">frozen</span><span class="o">.</span><span class="n">path_edited</span>
|
||||
<span class="k">else</span> <span class="n">frozen</span><span class="o">.</span><span class="n">path</span>
|
||||
<span class="p">)</span>
|
||||
<span class="n">path</span> <span class="o">=</span> <span class="n">path</span> <span class="ow">or</span> <span class="n">frozen</span><span class="o">.</span><span class="n">path_derivatives</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">if</span> <span class="n">frozen</span><span class="o">.</span><span class="n">path_derivatives</span> <span class="k">else</span> <span class="kc">None</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">path</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="p">[]</span>
|
||||
|
||||
<span class="n">md</span> <span class="o">=</span> <span class="n">OSXMetaData</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">decoder</span><span class="p">(</span><span class="n">val</span><span class="p">):</span>
|
||||
<span class="sd">"""Decode value from JSON"""</span>
|
||||
<span class="k">return</span> <span class="n">json</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span><span class="n">val</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">))</span>
|
||||
|
||||
<span class="n">detected_text</span> <span class="o">=</span> <span class="n">md</span><span class="o">.</span><span class="n">get_xattr</span><span class="p">(</span>
|
||||
<span class="s2">"osxphotos.metadata:detected_text"</span><span class="p">,</span> <span class="n">decode</span><span class="o">=</span><span class="n">decoder</span>
|
||||
<span class="p">)</span>
|
||||
<span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
|
||||
<span class="n">detected_text</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="k">if</span> <span class="n">detected_text</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">orientation</span> <span class="o">=</span> <span class="n">frozen</span><span class="o">.</span><span class="n">orientation</span> <span class="ow">or</span> <span class="kc">None</span>
|
||||
<span class="n">detected_text</span> <span class="o">=</span> <span class="n">detect_text</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">orientation</span><span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">encoder</span><span class="p">(</span><span class="n">obj</span><span class="p">):</span>
|
||||
<span class="sd">"""Encode value as JSON"""</span>
|
||||
<span class="n">val</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">obj</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">val</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span>
|
||||
|
||||
<span class="n">md</span><span class="o">.</span><span class="n">set_xattr</span><span class="p">(</span>
|
||||
<span class="s2">"osxphotos.metadata:detected_text"</span><span class="p">,</span> <span class="n">detected_text</span><span class="p">,</span> <span class="n">encode</span><span class="o">=</span><span class="n">encoder</span>
|
||||
<span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">detected_text</span>
|
||||
|
||||
<span class="n">frozen</span><span class="o">.</span><span class="n">detected_text</span> <span class="o">=</span> <span class="n">detected_text</span>
|
||||
<span class="n">frozen</span><span class="o">.</span><span class="n">_detected_text</span> <span class="o">=</span> <span class="n">_detected_text</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">frozen</span>
|
||||
</pre></div>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta name="color-scheme" content="light dark"><link rel="index" title="Index" href="../../genindex.html" /><link rel="search" title="Search" href="../../search.html" />
|
||||
|
||||
<meta name="generator" content="sphinx-5.3.0, furo 2022.09.29"/>
|
||||
<title>osxphotos.photosalbum - osxphotos 0.58.1 documentation</title>
|
||||
<title>osxphotos.photosalbum - osxphotos 0.60.5 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/styles/furo.css?digest=d81277517bee4d6b0349d71bb2661d4890b5617c" />
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/copybutton.css" />
|
||||
@@ -123,7 +123,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="../../index.html"><div class="brand">osxphotos 0.58.1 documentation</div></a>
|
||||
<a href="../../index.html"><div class="brand">osxphotos 0.60.5 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -146,7 +146,7 @@
|
||||
<div class="sidebar-sticky"><a class="sidebar-brand" href="../../index.html">
|
||||
|
||||
|
||||
<span class="sidebar-brand-text">osxphotos 0.58.1 documentation</span>
|
||||
<span class="sidebar-brand-text">osxphotos 0.60.5 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="../../search.html" role="search">
|
||||
<input class="sidebar-search" placeholder=Search name="q" aria-label="Search">
|
||||
@@ -197,31 +197,55 @@
|
||||
<h1>Source code for osxphotos.photosalbum</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">""" PhotosAlbum class to create an album in default Photos library and add photos to it """</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">annotations</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">unicodedata</span>
|
||||
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">List</span><span class="p">,</span> <span class="n">Optional</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">photoscript</span>
|
||||
<span class="kn">from</span> <span class="nn">more_itertools</span> <span class="kn">import</span> <span class="n">chunked</span>
|
||||
<span class="kn">from</span> <span class="nn">photoscript</span> <span class="kn">import</span> <span class="n">Album</span><span class="p">,</span> <span class="n">Folder</span><span class="p">,</span> <span class="n">Photo</span><span class="p">,</span> <span class="n">PhotosLibrary</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">.photoinfo</span> <span class="kn">import</span> <span class="n">PhotoInfo</span>
|
||||
<span class="kn">from</span> <span class="nn">.platform</span> <span class="kn">import</span> <span class="n">assert_macos</span>
|
||||
<span class="kn">from</span> <span class="nn">.utils</span> <span class="kn">import</span> <span class="n">noop</span><span class="p">,</span> <span class="n">pluralize</span>
|
||||
|
||||
<span class="n">assert_macos</span><span class="p">()</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">photoscript</span>
|
||||
<span class="kn">from</span> <span class="nn">photoscript</span> <span class="kn">import</span> <span class="n">Album</span><span class="p">,</span> <span class="n">Folder</span><span class="p">,</span> <span class="n">Photo</span><span class="p">,</span> <span class="n">PhotosLibrary</span>
|
||||
|
||||
<span class="n">__all__</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"PhotosAlbum"</span><span class="p">,</span> <span class="s2">"PhotosAlbumPhotoScript"</span><span class="p">]</span>
|
||||
|
||||
|
||||
<span class="k">def</span> <span class="nf">get_unicode_variants</span><span class="p">(</span><span class="n">s</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">list</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span>
|
||||
<span class="sd">"""Get all unicode variants of string"""</span>
|
||||
<span class="n">variants</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">form</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">"NFC"</span><span class="p">,</span> <span class="s2">"NFD"</span><span class="p">,</span> <span class="s2">"NFKC"</span><span class="p">,</span> <span class="s2">"NFKD"</span><span class="p">]:</span>
|
||||
<span class="n">normalized</span> <span class="o">=</span> <span class="n">unicodedata</span><span class="o">.</span><span class="n">normalize</span><span class="p">(</span><span class="n">form</span><span class="p">,</span> <span class="n">s</span><span class="p">)</span>
|
||||
<span class="n">variants</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">normalized</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">variants</span>
|
||||
|
||||
|
||||
<span class="k">def</span> <span class="nf">folder_by_path</span><span class="p">(</span><span class="n">folders</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span> <span class="n">verbose</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">callable</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">Folder</span><span class="p">:</span>
|
||||
<span class="sd">"""Get (and create if necessary) a Photos Folder by path (passed as list of folder names)"""</span>
|
||||
<span class="n">library</span> <span class="o">=</span> <span class="n">PhotosLibrary</span><span class="p">()</span>
|
||||
<span class="n">verbose</span> <span class="o">=</span> <span class="n">verbose</span> <span class="ow">or</span> <span class="n">noop</span>
|
||||
<span class="n">top_folder_name</span> <span class="o">=</span> <span class="n">folders</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
|
||||
<span class="n">top_folder</span> <span class="o">=</span> <span class="n">library</span><span class="o">.</span><span class="n">folder</span><span class="p">(</span><span class="n">top_folder_name</span><span class="p">,</span> <span class="n">top_level</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">top_folder</span><span class="p">:</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">folder_variant</span> <span class="ow">in</span> <span class="n">get_unicode_variants</span><span class="p">(</span><span class="n">top_folder_name</span><span class="p">):</span>
|
||||
<span class="n">top_folder</span> <span class="o">=</span> <span class="n">library</span><span class="o">.</span><span class="n">folder</span><span class="p">(</span><span class="n">folder_variant</span><span class="p">,</span> <span class="n">top_level</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">top_folder</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="k">break</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">verbose</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Creating folder '</span><span class="si">{</span><span class="n">top_folder_name</span><span class="si">}</span><span class="s2">'"</span><span class="p">)</span>
|
||||
<span class="n">top_folder</span> <span class="o">=</span> <span class="n">library</span><span class="o">.</span><span class="n">create_folder</span><span class="p">(</span><span class="n">top_folder_name</span><span class="p">)</span>
|
||||
|
||||
<span class="n">current_folder</span> <span class="o">=</span> <span class="n">top_folder</span>
|
||||
<span class="k">for</span> <span class="n">folder_name</span> <span class="ow">in</span> <span class="n">folders</span><span class="p">:</span>
|
||||
<span class="n">folder</span> <span class="o">=</span> <span class="n">current_folder</span><span class="o">.</span><span class="n">folder</span><span class="p">(</span><span class="n">folder_name</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">folder</span><span class="p">:</span>
|
||||
<span class="k">for</span> <span class="n">folder_variant</span> <span class="ow">in</span> <span class="n">get_unicode_variants</span><span class="p">(</span><span class="n">folder_name</span><span class="p">):</span>
|
||||
<span class="n">folder</span> <span class="o">=</span> <span class="n">current_folder</span><span class="o">.</span><span class="n">folder</span><span class="p">(</span><span class="n">folder_variant</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">folder</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="k">break</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">verbose</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Creating folder '</span><span class="si">{</span><span class="n">folder_name</span><span class="si">}</span><span class="s2">'"</span><span class="p">)</span>
|
||||
<span class="n">folder</span> <span class="o">=</span> <span class="n">current_folder</span><span class="o">.</span><span class="n">create_folder</span><span class="p">(</span><span class="n">folder_name</span><span class="p">)</span>
|
||||
<span class="n">current_folder</span> <span class="o">=</span> <span class="n">folder</span>
|
||||
@@ -238,15 +262,24 @@
|
||||
<span class="c1"># have folders</span>
|
||||
<span class="n">album_name</span> <span class="o">=</span> <span class="n">folders_album</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span>
|
||||
<span class="n">folder</span> <span class="o">=</span> <span class="n">folder_by_path</span><span class="p">(</span><span class="n">folders_album</span><span class="p">,</span> <span class="n">verbose</span><span class="p">)</span>
|
||||
<span class="n">album</span> <span class="o">=</span> <span class="n">folder</span><span class="o">.</span><span class="n">album</span><span class="p">(</span><span class="n">album_name</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">album</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="k">for</span> <span class="n">album_variant</span> <span class="ow">in</span> <span class="n">get_unicode_variants</span><span class="p">(</span><span class="n">album_name</span><span class="p">):</span>
|
||||
<span class="c1"># Get album if it exists</span>
|
||||
<span class="c1"># need to check every unicode variant to avoid creating duplicate albums with same visual representation (#1085)</span>
|
||||
<span class="n">album</span> <span class="o">=</span> <span class="n">folder</span><span class="o">.</span><span class="n">album</span><span class="p">(</span><span class="n">album_variant</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">album</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="k">break</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">verbose</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Creating album '</span><span class="si">{</span><span class="n">album_name</span><span class="si">}</span><span class="s2">'"</span><span class="p">)</span>
|
||||
<span class="n">album</span> <span class="o">=</span> <span class="n">folder</span><span class="o">.</span><span class="n">create_album</span><span class="p">(</span><span class="n">album_name</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="c1"># only have album name</span>
|
||||
<span class="n">album_name</span> <span class="o">=</span> <span class="n">folders_album</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
<span class="n">album</span> <span class="o">=</span> <span class="n">library</span><span class="o">.</span><span class="n">album</span><span class="p">(</span><span class="n">album_name</span><span class="p">,</span> <span class="n">top_level</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">album</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="k">for</span> <span class="n">album_variant</span> <span class="ow">in</span> <span class="n">get_unicode_variants</span><span class="p">(</span><span class="n">album_name</span><span class="p">):</span>
|
||||
<span class="n">album</span> <span class="o">=</span> <span class="n">library</span><span class="o">.</span><span class="n">album</span><span class="p">(</span><span class="n">album_variant</span><span class="p">,</span> <span class="n">top_level</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">album</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="k">break</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="c1"># album doesn't exist, create it</span>
|
||||
<span class="n">verbose</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Creating album '</span><span class="si">{</span><span class="n">album_name</span><span class="si">}</span><span class="s2">'"</span><span class="p">)</span>
|
||||
<span class="n">album</span> <span class="o">=</span> <span class="n">library</span><span class="o">.</span><span class="n">create_album</span><span class="p">(</span><span class="n">album_name</span><span class="p">)</span>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta name="color-scheme" content="light dark"><link rel="index" title="Index" href="../../../genindex.html" /><link rel="search" title="Search" href="../../../search.html" />
|
||||
|
||||
<meta name="generator" content="sphinx-5.3.0, furo 2022.09.29"/>
|
||||
<title>osxphotos.photosdb._photosdb_process_comments - osxphotos 0.58.1 documentation</title>
|
||||
<title>osxphotos.photosdb._photosdb_process_comments - osxphotos 0.60.5 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/styles/furo.css?digest=d81277517bee4d6b0349d71bb2661d4890b5617c" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/copybutton.css" />
|
||||
@@ -123,7 +123,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="../../../index.html"><div class="brand">osxphotos 0.58.1 documentation</div></a>
|
||||
<a href="../../../index.html"><div class="brand">osxphotos 0.60.5 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -146,7 +146,7 @@
|
||||
<div class="sidebar-sticky"><a class="sidebar-brand" href="../../../index.html">
|
||||
|
||||
|
||||
<span class="sidebar-brand-text">osxphotos 0.58.1 documentation</span>
|
||||
<span class="sidebar-brand-text">osxphotos 0.60.5 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="../../../search.html" role="search">
|
||||
<input class="sidebar-search" placeholder=Search name="q" aria-label="Search">
|
||||
@@ -203,8 +203,8 @@
|
||||
<span class="kn">from</span> <span class="nn">dataclasses</span> <span class="kn">import</span> <span class="n">dataclass</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">.._constants</span> <span class="kn">import</span> <span class="n">_DB_TABLE_NAMES</span><span class="p">,</span> <span class="n">_PHOTOS_4_VERSION</span><span class="p">,</span> <span class="n">TIME_DELTA</span>
|
||||
<span class="kn">from</span> <span class="nn">..utils</span> <span class="kn">import</span> <span class="n">normalize_unicode</span>
|
||||
<span class="kn">from</span> <span class="nn">..sqlite_utils</span> <span class="kn">import</span> <span class="n">sqlite_open_ro</span>
|
||||
<span class="kn">from</span> <span class="nn">..unicode</span> <span class="kn">import</span> <span class="n">normalize_unicode</span>
|
||||
|
||||
|
||||
<span class="k">def</span> <span class="nf">_process_comments</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta name="color-scheme" content="light dark"><link rel="index" title="Index" href="../../../genindex.html" /><link rel="search" title="Search" href="../../../search.html" />
|
||||
|
||||
<meta name="generator" content="sphinx-5.3.0, furo 2022.09.29"/>
|
||||
<title>osxphotos.photosdb.photosdb - osxphotos 0.58.1 documentation</title>
|
||||
<title>osxphotos.photosdb.photosdb - osxphotos 0.60.5 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/styles/furo.css?digest=d81277517bee4d6b0349d71bb2661d4890b5617c" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/copybutton.css" />
|
||||
@@ -123,7 +123,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="../../../index.html"><div class="brand">osxphotos 0.58.1 documentation</div></a>
|
||||
<a href="../../../index.html"><div class="brand">osxphotos 0.60.5 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -146,7 +146,7 @@
|
||||
<div class="sidebar-sticky"><a class="sidebar-brand" href="../../../index.html">
|
||||
|
||||
|
||||
<span class="sidebar-brand-text">osxphotos 0.58.1 documentation</span>
|
||||
<span class="sidebar-brand-text">osxphotos 0.60.5 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="../../../search.html" role="search">
|
||||
<input class="sidebar-search" placeholder=Search name="q" aria-label="Search">
|
||||
@@ -218,7 +218,6 @@
|
||||
<span class="kn">from</span> <span class="nn">unicodedata</span> <span class="kn">import</span> <span class="n">normalize</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">bitmath</span>
|
||||
<span class="kn">import</span> <span class="nn">photoscript</span>
|
||||
<span class="kn">from</span> <span class="nn">rich</span> <span class="kn">import</span> <span class="nb">print</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">.._constants</span> <span class="kn">import</span> <span class="p">(</span>
|
||||
@@ -254,18 +253,17 @@
|
||||
<span class="kn">from</span> <span class="nn">..personinfo</span> <span class="kn">import</span> <span class="n">PersonInfo</span>
|
||||
<span class="kn">from</span> <span class="nn">..photoinfo</span> <span class="kn">import</span> <span class="n">PhotoInfo</span>
|
||||
<span class="kn">from</span> <span class="nn">..phototemplate</span> <span class="kn">import</span> <span class="n">RenderOptions</span>
|
||||
<span class="kn">from</span> <span class="nn">..platform</span> <span class="kn">import</span> <span class="n">get_macos_version</span><span class="p">,</span> <span class="n">is_macos</span>
|
||||
<span class="kn">from</span> <span class="nn">..queryoptions</span> <span class="kn">import</span> <span class="n">QueryOptions</span>
|
||||
<span class="kn">from</span> <span class="nn">..rich_utils</span> <span class="kn">import</span> <span class="n">add_rich_markup_tag</span>
|
||||
<span class="kn">from</span> <span class="nn">..sqlite_utils</span> <span class="kn">import</span> <span class="n">sqlite_db_is_locked</span><span class="p">,</span> <span class="n">sqlite_open_ro</span>
|
||||
<span class="kn">from</span> <span class="nn">..utils</span> <span class="kn">import</span> <span class="p">(</span>
|
||||
<span class="n">_check_file_exists</span><span class="p">,</span>
|
||||
<span class="n">get_macos_version</span><span class="p">,</span>
|
||||
<span class="n">get_last_library_path</span><span class="p">,</span>
|
||||
<span class="n">noop</span><span class="p">,</span>
|
||||
<span class="n">normalize_unicode</span><span class="p">,</span>
|
||||
<span class="p">)</span>
|
||||
<span class="kn">from</span> <span class="nn">..unicode</span> <span class="kn">import</span> <span class="n">normalize_unicode</span>
|
||||
<span class="kn">from</span> <span class="nn">..utils</span> <span class="kn">import</span> <span class="n">_check_file_exists</span><span class="p">,</span> <span class="n">get_last_library_path</span><span class="p">,</span> <span class="n">noop</span>
|
||||
<span class="kn">from</span> <span class="nn">.photosdb_utils</span> <span class="kn">import</span> <span class="n">get_db_model_version</span><span class="p">,</span> <span class="n">get_db_version</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">is_macos</span><span class="p">:</span>
|
||||
<span class="kn">import</span> <span class="nn">photoscript</span>
|
||||
|
||||
<span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s2">"osxphotos"</span><span class="p">)</span>
|
||||
|
||||
<span class="n">__all__</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"PhotosDB"</span><span class="p">]</span>
|
||||
@@ -290,6 +288,7 @@
|
||||
<span class="n">labels_normalized</span><span class="p">,</span>
|
||||
<span class="n">labels_normalized_as_dict</span><span class="p">,</span>
|
||||
<span class="p">)</span>
|
||||
<span class="kn">from</span> <span class="nn">._photosdb_process_syndicationinfo</span> <span class="kn">import</span> <span class="n">_process_syndicationinfo</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
|
||||
<span class="bp">self</span><span class="p">,</span>
|
||||
@@ -315,8 +314,8 @@
|
||||
|
||||
<span class="c1"># Check OS version</span>
|
||||
<span class="n">system</span> <span class="o">=</span> <span class="n">platform</span><span class="o">.</span><span class="n">system</span><span class="p">()</span>
|
||||
<span class="p">(</span><span class="n">ver</span><span class="p">,</span> <span class="n">major</span><span class="p">,</span> <span class="n">_</span><span class="p">)</span> <span class="o">=</span> <span class="n">get_macos_version</span><span class="p">()</span>
|
||||
<span class="k">if</span> <span class="n">system</span> <span class="o">!=</span> <span class="s2">"Darwin"</span> <span class="ow">or</span> <span class="p">((</span><span class="n">ver</span><span class="p">,</span> <span class="n">major</span><span class="p">)</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">_TESTED_OS_VERSIONS</span><span class="p">):</span>
|
||||
<span class="p">(</span><span class="n">ver</span><span class="p">,</span> <span class="n">major</span><span class="p">,</span> <span class="n">_</span><span class="p">)</span> <span class="o">=</span> <span class="n">get_macos_version</span><span class="p">()</span> <span class="k">if</span> <span class="n">is_macos</span> <span class="k">else</span> <span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">system</span> <span class="o">==</span> <span class="s2">"Darwin"</span> <span class="ow">and</span> <span class="p">((</span><span class="n">ver</span><span class="p">,</span> <span class="n">major</span><span class="p">)</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">_TESTED_OS_VERSIONS</span><span class="p">):</span>
|
||||
<span class="n">logging</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span>
|
||||
<span class="sa">f</span><span class="s2">"WARNING: This module has only been tested with macOS versions "</span>
|
||||
<span class="sa">f</span><span class="s2">"[</span><span class="si">{</span><span class="s1">', '</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="sa">f</span><span class="s1">'</span><span class="si">{</span><span class="n">v</span><span class="si">}</span><span class="s1">.</span><span class="si">{</span><span class="n">m</span><span class="si">}</span><span class="s1">'</span> <span class="k">for</span> <span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="n">m</span><span class="p">)</span> <span class="ow">in</span> <span class="n">_TESTED_OS_VERSIONS</span><span class="p">)</span><span class="si">}</span><span class="s2">]: "</span>
|
||||
@@ -481,6 +480,13 @@
|
||||
<span class="c1"># key is Z_PK of ZMOMENT table and values are the moment info</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_db_moment_pk</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
|
||||
<span class="c1"># Dict to hold data on imports for Photos <= 4</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_db_import_group</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
|
||||
<span class="c1"># Dict to hold syndication info for Photos >= 8</span>
|
||||
<span class="c1"># key is UUID and value is dict of syndication info</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_db_syndication_uuid</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="sa">f</span><span class="s2">"dbfile = </span><span class="si">{</span><span class="n">dbfile</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">dbfile</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
@@ -710,7 +716,8 @@
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">album_info_shared</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""return list of AlbumInfo objects for each shared album in the photos database</span>
|
||||
<span class="sd"> only valid for Photos 5; on Photos <= 4, prints warning and returns empty list"""</span>
|
||||
<span class="sd"> only valid for Photos 5; on Photos <= 4, prints warning and returns empty list</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="c1"># if _dbalbum_details[key]["cloudownerhashedpersonid"] is not None, then it's a shared album</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_album_info_shared</span>
|
||||
@@ -737,7 +744,8 @@
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">albums_shared</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""return list of shared albums found in photos database</span>
|
||||
<span class="sd"> only valid for Photos 5; on Photos <= 4, prints warning and returns empty list"""</span>
|
||||
<span class="sd"> only valid for Photos 5; on Photos <= 4, prints warning and returns empty list</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="c1"># Could be more than one album with same name</span>
|
||||
<span class="c1"># Right now, they are treated as same album and photos are combined from albums with same name</span>
|
||||
@@ -2706,6 +2714,10 @@
|
||||
<span class="n">verbose</span><span class="p">(</span><span class="s2">"Processing moments."</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_process_moments</span><span class="p">()</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">photos_version</span> <span class="o">>=</span> <span class="mi">8</span><span class="p">:</span>
|
||||
<span class="n">verbose</span><span class="p">(</span><span class="s2">"Processing syndication info."</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_process_syndicationinfo</span><span class="p">()</span>
|
||||
|
||||
<span class="n">verbose</span><span class="p">(</span><span class="s2">"Done processing details from Photos library."</span><span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_process_moments</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
@@ -3247,7 +3259,6 @@
|
||||
<span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="kc">None</span></div>
|
||||
|
||||
<span class="c1"># TODO: add to docs and test</span>
|
||||
<div class="viewcode-block" id="PhotosDB.photos_by_uuid"><a class="viewcode-back" href="../../../reference.html#osxphotos.PhotosDB.photos_by_uuid">[docs]</a> <span class="k">def</span> <span class="nf">photos_by_uuid</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">uuids</span><span class="p">):</span>
|
||||
<span class="sd">"""Returns a list of photos with UUID in uuids.</span>
|
||||
<span class="sd"> Does not generate error if invalid or missing UUID passed.</span>
|
||||
@@ -3260,14 +3271,11 @@
|
||||
<span class="sd"> Returns:</span>
|
||||
<span class="sd"> list of PhotoInfo instance for photo with UUID matching uuid or [] if no match</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">photos</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">uuid</span> <span class="ow">in</span> <span class="n">uuids</span><span class="p">:</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">photos</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">PhotoInfo</span><span class="p">(</span><span class="n">db</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> <span class="n">uuid</span><span class="o">=</span><span class="n">uuid</span><span class="p">,</span> <span class="n">info</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_dbphotos</span><span class="p">[</span><span class="n">uuid</span><span class="p">]))</span>
|
||||
<span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
|
||||
<span class="c1"># ignore missing/invlaid UUID</span>
|
||||
<span class="k">pass</span>
|
||||
<span class="k">return</span> <span class="n">photos</span></div>
|
||||
<span class="k">return</span> <span class="p">[</span>
|
||||
<span class="n">PhotoInfo</span><span class="p">(</span><span class="n">db</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> <span class="n">uuid</span><span class="o">=</span><span class="n">uuid</span><span class="p">,</span> <span class="n">info</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_dbphotos</span><span class="p">[</span><span class="n">uuid</span><span class="p">])</span>
|
||||
<span class="k">for</span> <span class="n">uuid</span> <span class="ow">in</span> <span class="n">uuids</span>
|
||||
<span class="k">if</span> <span class="n">uuid</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_dbphotos</span>
|
||||
<span class="p">]</span></div>
|
||||
|
||||
<div class="viewcode-block" id="PhotosDB.query"><a class="viewcode-back" href="../../../reference.html#osxphotos.PhotosDB.query">[docs]</a> <span class="k">def</span> <span class="nf">query</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">options</span><span class="p">:</span> <span class="n">QueryOptions</span><span class="p">)</span> <span class="o">-></span> <span class="n">List</span><span class="p">[</span><span class="n">PhotoInfo</span><span class="p">]:</span>
|
||||
<span class="sd">"""Run a query against PhotosDB to extract the photos based on user supplied options</span>
|
||||
@@ -3709,6 +3717,16 @@
|
||||
<span class="n">added_after</span> <span class="o">=</span> <span class="n">datetime_naive_to_local</span><span class="p">(</span><span class="n">added_after</span><span class="p">)</span>
|
||||
<span class="n">photos</span> <span class="o">=</span> <span class="p">[</span><span class="n">p</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">photos</span> <span class="k">if</span> <span class="n">p</span><span class="o">.</span><span class="n">date_added</span> <span class="ow">and</span> <span class="n">p</span><span class="o">.</span><span class="n">date_added</span> <span class="o">></span> <span class="n">added_after</span><span class="p">]</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">syndicated</span><span class="p">:</span>
|
||||
<span class="n">photos</span> <span class="o">=</span> <span class="p">[</span><span class="n">p</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">photos</span> <span class="k">if</span> <span class="n">p</span><span class="o">.</span><span class="n">syndicated</span><span class="p">]</span>
|
||||
<span class="k">elif</span> <span class="n">options</span><span class="o">.</span><span class="n">not_syndicated</span><span class="p">:</span>
|
||||
<span class="n">photos</span> <span class="o">=</span> <span class="p">[</span><span class="n">p</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">photos</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">p</span><span class="o">.</span><span class="n">syndicated</span><span class="p">]</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">saved_to_library</span><span class="p">:</span>
|
||||
<span class="n">photos</span> <span class="o">=</span> <span class="p">[</span><span class="n">p</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">photos</span> <span class="k">if</span> <span class="n">p</span><span class="o">.</span><span class="n">syndicated</span> <span class="ow">and</span> <span class="n">p</span><span class="o">.</span><span class="n">saved_to_library</span><span class="p">]</span>
|
||||
<span class="k">elif</span> <span class="n">options</span><span class="o">.</span><span class="n">not_saved_to_library</span><span class="p">:</span>
|
||||
<span class="n">photos</span> <span class="o">=</span> <span class="p">[</span><span class="n">p</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">photos</span> <span class="k">if</span> <span class="n">p</span><span class="o">.</span><span class="n">syndicated</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">p</span><span class="o">.</span><span class="n">saved_to_library</span><span class="p">]</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">function</span><span class="p">:</span>
|
||||
<span class="k">for</span> <span class="n">function</span> <span class="ow">in</span> <span class="n">options</span><span class="o">.</span><span class="n">function</span><span class="p">:</span>
|
||||
<span class="n">photos</span> <span class="o">=</span> <span class="n">function</span><span class="p">[</span><span class="mi">0</span><span class="p">](</span><span class="n">photos</span><span class="p">)</span>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta name="color-scheme" content="light dark"><link rel="index" title="Index" href="../../genindex.html" /><link rel="search" title="Search" href="../../search.html" />
|
||||
|
||||
<meta name="generator" content="sphinx-5.3.0, furo 2022.09.29"/>
|
||||
<title>osxphotos.phototemplate - osxphotos 0.58.1 documentation</title>
|
||||
<title>osxphotos.phototemplate - osxphotos 0.60.0 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/styles/furo.css?digest=d81277517bee4d6b0349d71bb2661d4890b5617c" />
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/copybutton.css" />
|
||||
@@ -123,7 +123,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="../../index.html"><div class="brand">osxphotos 0.58.1 documentation</div></a>
|
||||
<a href="../../index.html"><div class="brand">osxphotos 0.60.0 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -146,7 +146,7 @@
|
||||
<div class="sidebar-sticky"><a class="sidebar-brand" href="../../index.html">
|
||||
|
||||
|
||||
<span class="sidebar-brand-text">osxphotos 0.58.1 documentation</span>
|
||||
<span class="sidebar-brand-text">osxphotos 0.60.0 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="../../search.html" role="search">
|
||||
<input class="sidebar-search" placeholder=Search name="q" aria-label="Search">
|
||||
@@ -218,7 +218,6 @@
|
||||
<span class="kn">from</span> <span class="nn">.datetime_formatter</span> <span class="kn">import</span> <span class="n">DateTimeFormatter</span>
|
||||
<span class="kn">from</span> <span class="nn">.exiftool</span> <span class="kn">import</span> <span class="n">ExifToolCaching</span>
|
||||
<span class="kn">from</span> <span class="nn">.path_utils</span> <span class="kn">import</span> <span class="n">sanitize_dirname</span><span class="p">,</span> <span class="n">sanitize_filename</span><span class="p">,</span> <span class="n">sanitize_pathpart</span>
|
||||
<span class="kn">from</span> <span class="nn">.text_detection</span> <span class="kn">import</span> <span class="n">detect_text</span>
|
||||
<span class="kn">from</span> <span class="nn">.utils</span> <span class="kn">import</span> <span class="n">expand_and_validate_filepath</span><span class="p">,</span> <span class="n">load_function</span><span class="p">,</span> <span class="n">uuid_to_shortuuid</span>
|
||||
|
||||
<span class="n">__all__</span> <span class="o">=</span> <span class="p">[</span>
|
||||
@@ -1350,7 +1349,7 @@
|
||||
<span class="p">)</span>
|
||||
<span class="k">except</span> <span class="ne">ValueError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">SyntaxError</span><span class="p">(</span>
|
||||
<span class="sa">f</span><span class="s2">"comparison operators may only be used with values that can be converted to numbers: </span><span class="si">{</span><span class="n">vals</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">conditional_value</span><span class="si">}</span><span class="s2">"</span>
|
||||
<span class="sa">f</span><span class="s2">"comparison operators may only be used with values that can be converted to numbers: </span><span class="si">{</span><span class="n">value</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">conditional_value</span><span class="si">}</span><span class="s2">"</span>
|
||||
<span class="p">)</span> <span class="kn">from</span> <span class="nn">e</span>
|
||||
|
||||
<span class="n">predicate_is_true</span> <span class="o">=</span> <span class="kc">False</span>
|
||||
@@ -1549,7 +1548,7 @@
|
||||
<span class="n">subfield</span> <span class="o">=</span> <span class="n">subfield</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span>
|
||||
<span class="k">if</span> <span class="n">subfield</span> <span class="ow">in</span> <span class="n">exifdict</span><span class="p">:</span>
|
||||
<span class="n">values</span> <span class="o">=</span> <span class="n">exifdict</span><span class="p">[</span><span class="n">subfield</span><span class="p">]</span>
|
||||
<span class="n">values</span> <span class="o">=</span> <span class="p">[</span><span class="n">values</span><span class="p">]</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">values</span><span class="p">,</span> <span class="nb">list</span><span class="p">)</span> <span class="k">else</span> <span class="n">values</span>
|
||||
<span class="n">values</span> <span class="o">=</span> <span class="n">values</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">values</span><span class="p">,</span> <span class="nb">list</span><span class="p">)</span> <span class="k">else</span> <span class="p">[</span><span class="n">values</span><span class="p">]</span>
|
||||
<span class="n">values</span> <span class="o">=</span> <span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">values</span><span class="p">]</span>
|
||||
|
||||
<span class="c1"># sanitize directory names if needed</span>
|
||||
@@ -1879,7 +1878,7 @@
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unhandled template value: </span><span class="si">{</span><span class="n">field</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="kn">from</span> <span class="nn">e</span>
|
||||
|
||||
|
||||
<span class="k">def</span> <span class="nf">get_place_value</span><span class="p">(</span><span class="n">photo</span><span class="p">:</span> <span class="s2">"PhotoInfo"</span><span class="p">,</span> <span class="n">field</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="nf">get_place_value</span><span class="p">(</span><span class="n">photo</span><span class="p">:</span> <span class="s2">"PhotoInfo"</span><span class="p">,</span> <span class="n">field</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span> <span class="c1"># noqa: F821</span>
|
||||
<span class="sd">"""Get the value of a 'place' field by attribute</span>
|
||||
|
||||
<span class="sd"> Args:</span>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta name="color-scheme" content="light dark"><link rel="index" title="Index" href="../../genindex.html" /><link rel="search" title="Search" href="../../search.html" />
|
||||
|
||||
<meta name="generator" content="sphinx-5.3.0, furo 2022.09.29"/>
|
||||
<title>osxphotos.placeinfo - osxphotos 0.58.1 documentation</title>
|
||||
<title>osxphotos.placeinfo - osxphotos 0.60.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/styles/furo.css?digest=d81277517bee4d6b0349d71bb2661d4890b5617c" />
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/copybutton.css" />
|
||||
@@ -123,7 +123,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="../../index.html"><div class="brand">osxphotos 0.58.1 documentation</div></a>
|
||||
<a href="../../index.html"><div class="brand">osxphotos 0.60.7 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -146,7 +146,7 @@
|
||||
<div class="sidebar-sticky"><a class="sidebar-brand" href="../../index.html">
|
||||
|
||||
|
||||
<span class="sidebar-brand-text">osxphotos 0.58.1 documentation</span>
|
||||
<span class="sidebar-brand-text">osxphotos 0.60.7 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="../../search.html" role="search">
|
||||
<input class="sidebar-search" placeholder=Search name="q" aria-label="Search">
|
||||
@@ -202,14 +202,16 @@
|
||||
<span class="sd"> See https://developer.apple.com/documentation/corelocation/clplacemark</span>
|
||||
<span class="sd"> for additional documentation on reverse geolocation data</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">annotations</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">abc</span> <span class="kn">import</span> <span class="n">ABC</span><span class="p">,</span> <span class="n">abstractmethod</span>
|
||||
<span class="kn">from</span> <span class="nn">collections</span> <span class="kn">import</span> <span class="n">namedtuple</span> <span class="c1"># pylint: disable=syntax-error</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">yaml</span>
|
||||
<span class="kn">from</span> <span class="nn">bpylist2</span> <span class="kn">import</span> <span class="n">archiver</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">._constants</span> <span class="kn">import</span> <span class="n">UNICODE_FORMAT</span>
|
||||
<span class="kn">from</span> <span class="nn">.utils</span> <span class="kn">import</span> <span class="n">normalize_unicode</span>
|
||||
<span class="kn">from</span> <span class="nn">.unicode</span> <span class="kn">import</span> <span class="n">normalize_unicode</span>
|
||||
|
||||
<span class="n">__all__</span> <span class="o">=</span> <span class="p">[</span>
|
||||
<span class="s2">"PLRevGeoLocationInfo"</span><span class="p">,</span>
|
||||
@@ -268,6 +270,7 @@
|
||||
<span class="p">],</span>
|
||||
<span class="p">)</span>
|
||||
|
||||
|
||||
<span class="c1"># The following classes represent Photo Library Reverse Geolocation Info as stored</span>
|
||||
<span class="c1"># in ZADDITIONALASSETATTRIBUTES.ZREVERSELOCATIONDATA</span>
|
||||
<span class="c1"># These classes are used by bpylist.archiver to unarchive the serialized objects</span>
|
||||
@@ -528,36 +531,101 @@
|
||||
<span class="n">archiver</span><span class="o">.</span><span class="n">update_class_map</span><span class="p">({</span><span class="s2">"PLRevGeoLocationInfo"</span><span class="p">:</span> <span class="n">PLRevGeoLocationInfo</span><span class="p">})</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="PlaceInfo"><a class="viewcode-back" href="../../reference.html#osxphotos.PlaceInfo">[docs]</a><span class="k">class</span> <span class="nc">PlaceInfo</span><span class="p">(</span><span class="n">ABC</span><span class="p">):</span>
|
||||
<span class="c1"># PlaceInfo is really an abstract base class but defining it as such</span>
|
||||
<span class="c1"># means it doesn't get picked up by the doc generation tools</span>
|
||||
<span class="c1"># so we define it as a regular class and then subclass it</span>
|
||||
<span class="c1"># TODO: right fix is probably have PlaceInfo as the only class that</span>
|
||||
<span class="c1"># is used and then have PlaceInfo4 and PlaceInfo5 called by PlaceInfo</span>
|
||||
<span class="c1"># as needed to return the properties (and make them private classes)</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="PlaceInfo"><a class="viewcode-back" href="../../reference.html#osxphotos.PlaceInfo">[docs]</a><span class="k">class</span> <span class="nc">PlaceInfo</span><span class="p">:</span>
|
||||
<span class="sd">"""Reverse geolocation place info for a photo."""</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="nd">@abstractmethod</span>
|
||||
<span class="k">def</span> <span class="nf">address_str</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="nf">address_str</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span> <span class="o">|</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="sd">"""Returns the full postal address as a string if defined, otherwise `None`."""</span>
|
||||
<span class="k">pass</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="nd">@abstractmethod</span>
|
||||
<span class="k">def</span> <span class="nf">country_code</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="nf">country_code</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span> <span class="o">|</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="sd">"""Returns the country_code of place, for example "GB".</span>
|
||||
<span class="sd"> Returns `None` if PhotoInfo contains no country code.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">pass</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="nd">@abstractmethod</span>
|
||||
<span class="k">def</span> <span class="nf">ishome</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="nf">ishome</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span>
|
||||
<span class="sd">"""Returns `True` if photo place is user's home address, otherwise `False`."""</span>
|
||||
<span class="k">pass</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="nd">@abstractmethod</span>
|
||||
<span class="k">def</span> <span class="nf">name</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="nf">name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span> <span class="o">|</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="sd">"""Returns the name of the local place as str.</span>
|
||||
<span class="sd"> This is what Photos displays in the Info window.</span>
|
||||
<span class="sd"> **Note** Photos 5 uses a different algorithm to determine the name than earlier versions which means the same Photo may have a different place name in Photos 4 and Photos 5.</span>
|
||||
<span class="sd"> `PhotoInfo.name` will return the name Photos would have shown depending on the version of the library being processed.</span>
|
||||
<span class="sd"> Returns `None` if photo does not contain a name.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">pass</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="nd">@abstractmethod</span>
|
||||
<span class="k">def</span> <span class="nf">names</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="nf">names</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">PlaceNames</span> <span class="o">|</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="sd">"""Returns a `PlaceNames` namedtuple with the following fields.</span>
|
||||
<span class="sd"> Each field is a list with zero or more values, sorted by area in ascending order.</span>
|
||||
<span class="sd"> E.g. `names.area_of_interest` could be ['Gulf Islands National Seashore', 'Santa Rosa Island'], ["Knott's Berry Farm"], or [] if `area_of_interest` not defined.</span>
|
||||
<span class="sd"> The value shown in Photos is the first value in the list. With the exception of `body_of_water` each of these field corresponds to an attribute of</span>
|
||||
<span class="sd"> a [CLPlacemark](https://developer.apple.com/documentation/corelocation/clplacemark) object.</span>
|
||||
|
||||
|
||||
<span class="sd"> * `country`; the name of the country associated with the placemark.</span>
|
||||
<span class="sd"> * `state_province`; administrativeArea, The state or province associated with the placemark.</span>
|
||||
<span class="sd"> * `sub_administrative_area`; additional administrative area information for the placemark.</span>
|
||||
<span class="sd"> * `city`; locality; the city associated with the placemark.</span>
|
||||
<span class="sd"> * `additional_city_info`; subLocality, Additional city-level information for the placemark.</span>
|
||||
<span class="sd"> * `ocean`; the name of the ocean associated with the placemark.</span>
|
||||
<span class="sd"> * `area_of_interest`; areasOfInterest, The relevant areas of interest associated with the placemark.</span>
|
||||
<span class="sd"> * `inland_water`; the name of the inland water body associated with the placemark.</span>
|
||||
<span class="sd"> * `region`; the geographic region associated with the placemark.</span>
|
||||
<span class="sd"> * `sub_throughfare`; additional street-level information for the placemark.</span>
|
||||
<span class="sd"> * `postal_code`; the postal code associated with the placemark.</span>
|
||||
<span class="sd"> * `street_address`; throughfare, The street address associated with the placemark.</span>
|
||||
<span class="sd"> * `body_of_water`; in Photos 4, any body of water; in Photos 5 contains the union of ocean and inland_water</span>
|
||||
|
||||
<span class="sd"> **Note**: In Photos <= 4.0, only the following fields are defined; all others are set to empty list:</span>
|
||||
|
||||
<span class="sd"> * `country`</span>
|
||||
<span class="sd"> * `state_province`</span>
|
||||
<span class="sd"> * `sub_administrative_area`</span>
|
||||
<span class="sd"> * `city`</span>
|
||||
<span class="sd"> * `additional_city_info`</span>
|
||||
<span class="sd"> * `area_of_interest`</span>
|
||||
<span class="sd"> * `body_of_water`</span>
|
||||
|
||||
<span class="sd"> Note:</span>
|
||||
<span class="sd"> The `PlaceNames` namedtuple contains reserved fields not listed below (see implementation for details),</span>
|
||||
<span class="sd"> thus it should be referenced only by name (e.g. `names.city`) and not by index.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">pass</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="nd">@abstractmethod</span>
|
||||
<span class="k">def</span> <span class="nf">address</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">pass</span></div>
|
||||
<span class="sd">"""Returns a `PostalAddress` namedtuple with details of the postal address containing the following fields:</span>
|
||||
|
||||
<span class="sd"> * `city`</span>
|
||||
<span class="sd"> * `country`</span>
|
||||
<span class="sd"> * `postal_code`</span>
|
||||
<span class="sd"> * `state`</span>
|
||||
<span class="sd"> * `street`</span>
|
||||
<span class="sd"> * `sub_administrative_area`</span>
|
||||
<span class="sd"> * `sub_locality`</span>
|
||||
<span class="sd"> * `iso_country_code`</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">pass</span>
|
||||
|
||||
<div class="viewcode-block" id="PlaceInfo.asdict"><a class="viewcode-back" href="../../reference.html#osxphotos.PlaceInfo.asdict">[docs]</a> <span class="k">def</span> <span class="nf">asdict</span><span class="p">():</span>
|
||||
<span class="sd">"""Returns a dictionary representation of the PlaceInfo object."""</span>
|
||||
<span class="k">pass</span></div></div>
|
||||
|
||||
|
||||
<span class="k">class</span> <span class="nc">PlaceInfo4</span><span class="p">(</span><span class="n">PlaceInfo</span><span class="p">):</span>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta name="color-scheme" content="light dark"><link rel="index" title="Index" href="../../genindex.html" /><link rel="search" title="Search" href="../../search.html" />
|
||||
|
||||
<meta name="generator" content="sphinx-5.3.0, furo 2022.09.29"/>
|
||||
<title>osxphotos.queryoptions - osxphotos 0.58.1 documentation</title>
|
||||
<title>osxphotos.queryoptions - osxphotos 0.60.5 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/styles/furo.css?digest=d81277517bee4d6b0349d71bb2661d4890b5617c" />
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/copybutton.css" />
|
||||
@@ -123,7 +123,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="../../index.html"><div class="brand">osxphotos 0.58.1 documentation</div></a>
|
||||
<a href="../../index.html"><div class="brand">osxphotos 0.60.5 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -146,7 +146,7 @@
|
||||
<div class="sidebar-sticky"><a class="sidebar-brand" href="../../index.html">
|
||||
|
||||
|
||||
<span class="sidebar-brand-text">osxphotos 0.58.1 documentation</span>
|
||||
<span class="sidebar-brand-text">osxphotos 0.60.5 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="../../search.html" role="search">
|
||||
<input class="sidebar-search" placeholder=Search name="q" aria-label="Search">
|
||||
@@ -305,6 +305,10 @@
|
||||
<span class="sd"> uti: list of UTIs to search for</span>
|
||||
<span class="sd"> uuid: list of uuids to search for</span>
|
||||
<span class="sd"> year: search for photos taken in a given year</span>
|
||||
<span class="sd"> syndicated: search for photos that have been shared via syndication ("Shared with You" album via Messages, etc.)</span>
|
||||
<span class="sd"> not_syndicated: search for photos that have not been shared via syndication ("Shared with You" album via Messages, etc.)</span>
|
||||
<span class="sd"> saved_to_library: search for syndicated photos that have been saved to the Photos library</span>
|
||||
<span class="sd"> not_saved_to_library: search for syndicated photos that have not been saved to the Photos library</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="n">added_after</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
@@ -389,6 +393,10 @@
|
||||
<span class="n">uti</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">Iterable</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="n">uuid</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">Iterable</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="n">year</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">Iterable</span><span class="p">[</span><span class="nb">int</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="n">syndicated</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="n">not_syndicated</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="n">saved_to_library</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="n">not_saved_to_library</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">asdict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="n">asdict</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span></div>
|
||||
@@ -458,6 +466,8 @@
|
||||
<span class="p">(</span><span class="s2">"deleted"</span><span class="p">,</span> <span class="s2">"not_deleted"</span><span class="p">),</span>
|
||||
<span class="p">(</span><span class="s2">"deleted"</span><span class="p">,</span> <span class="s2">"deleted_only"</span><span class="p">),</span>
|
||||
<span class="p">(</span><span class="s2">"deleted_only"</span><span class="p">,</span> <span class="s2">"not_deleted"</span><span class="p">),</span>
|
||||
<span class="p">(</span><span class="s2">"syndicated"</span><span class="p">,</span> <span class="s2">"not_syndicated"</span><span class="p">),</span>
|
||||
<span class="p">(</span><span class="s2">"saved_to_library"</span><span class="p">,</span> <span class="s2">"not_saved_to_library"</span><span class="p">),</span>
|
||||
<span class="p">]</span>
|
||||
<span class="c1"># TODO: add option to validate requiring at least one query arg</span>
|
||||
<span class="k">for</span> <span class="n">arg</span><span class="p">,</span> <span class="n">not_arg</span> <span class="ow">in</span> <span class="n">exclusive</span><span class="p">:</span>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta name="color-scheme" content="light dark"><link rel="index" title="Index" href="../../genindex.html" /><link rel="search" title="Search" href="../../search.html" />
|
||||
|
||||
<meta name="generator" content="sphinx-5.3.0, furo 2022.09.29"/>
|
||||
<title>osxphotos.scoreinfo - osxphotos 0.58.1 documentation</title>
|
||||
<title>osxphotos.scoreinfo - osxphotos 0.60.5 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/styles/furo.css?digest=d81277517bee4d6b0349d71bb2661d4890b5617c" />
|
||||
<link rel="stylesheet" type="text/css" href="../../_static/copybutton.css" />
|
||||
@@ -123,7 +123,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="../../index.html"><div class="brand">osxphotos 0.58.1 documentation</div></a>
|
||||
<a href="../../index.html"><div class="brand">osxphotos 0.60.5 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -146,7 +146,7 @@
|
||||
<div class="sidebar-sticky"><a class="sidebar-brand" href="../../index.html">
|
||||
|
||||
|
||||
<span class="sidebar-brand-text">osxphotos 0.58.1 documentation</span>
|
||||
<span class="sidebar-brand-text">osxphotos 0.60.5 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="../../search.html" role="search">
|
||||
<input class="sidebar-search" placeholder=Search name="q" aria-label="Search">
|
||||
@@ -197,7 +197,7 @@
|
||||
<h1>Source code for osxphotos.scoreinfo</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">""" ScoreInfo class to expose computed score info from the library """</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">dataclasses</span> <span class="kn">import</span> <span class="n">dataclass</span><span class="p">,</span> <span class="n">asdict</span>
|
||||
<span class="kn">from</span> <span class="nn">dataclasses</span> <span class="kn">import</span> <span class="n">asdict</span><span class="p">,</span> <span class="n">dataclass</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">._constants</span> <span class="kn">import</span> <span class="n">_PHOTOS_4_VERSION</span>
|
||||
|
||||
|
||||
@@ -361,7 +361,7 @@ Template Substitutions
|
||||
* - {tab}
|
||||
- :A tab: '\t'
|
||||
* - {osxphotos_version}
|
||||
- The osxphotos version, e.g. '0.58.2'
|
||||
- The osxphotos version, e.g. '0.60.7'
|
||||
* - {osxphotos_cmd_line}
|
||||
- The full command line used to run osxphotos
|
||||
* - {album}
|
||||
|
||||
2
docs/_static/documentation_options.js
vendored
2
docs/_static/documentation_options.js
vendored
@@ -1,6 +1,6 @@
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
|
||||
VERSION: '0.58.2',
|
||||
VERSION: '0.60.7',
|
||||
LANGUAGE: 'en',
|
||||
COLLAPSE_INDEX: false,
|
||||
BUILDER: 'html',
|
||||
|
||||
158
docs/cli.html
158
docs/cli.html
@@ -6,7 +6,7 @@
|
||||
<link rel="index" title="Index" href="genindex.html" /><link rel="search" title="Search" href="search.html" /><link rel="next" title="OSXPhotos Template System" href="template_help.html" /><link rel="prev" title="OSXPhotos Tutorial" href="tutorial.html" />
|
||||
|
||||
<meta name="generator" content="sphinx-5.3.0, furo 2022.09.29"/>
|
||||
<title>OSXPhotos Command Line Interface (CLI) - osxphotos 0.58.2 documentation</title>
|
||||
<title>OSXPhotos Command Line Interface (CLI) - osxphotos 0.60.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?digest=d81277517bee4d6b0349d71bb2661d4890b5617c" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css" />
|
||||
@@ -124,7 +124,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="index.html"><div class="brand">osxphotos 0.58.2 documentation</div></a>
|
||||
<a href="index.html"><div class="brand">osxphotos 0.60.7 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -147,7 +147,7 @@
|
||||
<div class="sidebar-sticky"><a class="sidebar-brand" href="index.html">
|
||||
|
||||
|
||||
<span class="sidebar-brand-text">osxphotos 0.58.2 documentation</span>
|
||||
<span class="sidebar-brand-text">osxphotos 0.60.7 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
||||
<input class="sidebar-search" placeholder=Search name="q" aria-label="Search">
|
||||
@@ -211,18 +211,6 @@
|
||||
<dd><p>Show the version and exit.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-library">
|
||||
<span id="cmdoption-osxphotos-db"></span><span class="sig-name descname"><span class="pre">--library</span></span><span class="sig-prename descclassname"></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">--db</span></span><span class="sig-prename descclassname"> <span class="pre"><PHOTOS_LIBRARY_PATH></span></span><a class="headerlink" href="#cmdoption-osxphotos-library" title="Permalink to this definition">#</a></dt>
|
||||
<dd><p>Specify path to Photos library. If not provided, will attempt to find the library to use in the following order: 1. last opened library, 2. system library, 3. ~/Pictures/Photos Library.photoslibrary</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-json">
|
||||
<span class="sig-name descname"><span class="pre">--json</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-osxphotos-json" title="Permalink to this definition">#</a></dt>
|
||||
<dd><p>Print output in JSON format.</p>
|
||||
</dd></dl>
|
||||
|
||||
<section id="osxphotos-about">
|
||||
<h3>about<a class="headerlink" href="#osxphotos-about" title="Permalink to this heading">#</a></h3>
|
||||
<p>Print information about osxphotos including license.</p>
|
||||
@@ -728,6 +716,30 @@ See <cite>osxphotos help timewarp</cite> for more information.</p>
|
||||
<dd><p>Search for photos that are not in iCloud (have not been synched)</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-add-locations-syndicated">
|
||||
<span class="sig-name descname"><span class="pre">--syndicated</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-osxphotos-add-locations-syndicated" title="Permalink to this definition">#</a></dt>
|
||||
<dd><p>Search for photos that have been shared via syndication (‘Shared with You’ album via Messages, etc.)</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-add-locations-not-syndicated">
|
||||
<span class="sig-name descname"><span class="pre">--not-syndicated</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-osxphotos-add-locations-not-syndicated" title="Permalink to this definition">#</a></dt>
|
||||
<dd><p>Search for photos that have not been shared via syndication (‘Shared with You’ album via Messages, etc.)</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-add-locations-saved-to-library">
|
||||
<span class="sig-name descname"><span class="pre">--saved-to-library</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-osxphotos-add-locations-saved-to-library" title="Permalink to this definition">#</a></dt>
|
||||
<dd><p>Search for syndicated photos that have saved to the library</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-add-locations-not-saved-to-library">
|
||||
<span class="sig-name descname"><span class="pre">--not-saved-to-library</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-osxphotos-add-locations-not-saved-to-library" title="Permalink to this definition">#</a></dt>
|
||||
<dd><p>Search for syndicated photos that have not saved to the library</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-add-locations-regex">
|
||||
<span class="sig-name descname"><span class="pre">--regex</span></span><span class="sig-prename descclassname"> <span class="pre"><REGEX</span> <span class="pre">TEMPLATE></span></span><a class="headerlink" href="#cmdoption-osxphotos-add-locations-regex" title="Permalink to this definition">#</a></dt>
|
||||
@@ -812,7 +824,7 @@ Operates on currently selected photos.</p>
|
||||
</div>
|
||||
<p>This will set the title to “California vacation 2023 2023-02-20 001”, and so on,
|
||||
the description to the reverse geolocation place name,
|
||||
and add the keywords to “Family”, “Travel”.</p>
|
||||
and add the keywords “Family” and “Travel”.</p>
|
||||
<p>–title, –description, and –keyword may be any valid template string.
|
||||
See <a class="reference external" href="https://rhettbull.github.io/osxphotos/template_help.html">https://rhettbull.github.io/osxphotos/template_help.html</a>
|
||||
or <cite>osxphotos docs</cite> for more information on the osxphotos template system.</p>
|
||||
@@ -1659,6 +1671,30 @@ to modify this behavior.</p>
|
||||
<dd><p>Search for photos that are not in iCloud (have not been synched)</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-export-syndicated">
|
||||
<span class="sig-name descname"><span class="pre">--syndicated</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-osxphotos-export-syndicated" title="Permalink to this definition">#</a></dt>
|
||||
<dd><p>Search for photos that have been shared via syndication (‘Shared with You’ album via Messages, etc.)</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-export-not-syndicated">
|
||||
<span class="sig-name descname"><span class="pre">--not-syndicated</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-osxphotos-export-not-syndicated" title="Permalink to this definition">#</a></dt>
|
||||
<dd><p>Search for photos that have not been shared via syndication (‘Shared with You’ album via Messages, etc.)</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-export-saved-to-library">
|
||||
<span class="sig-name descname"><span class="pre">--saved-to-library</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-osxphotos-export-saved-to-library" title="Permalink to this definition">#</a></dt>
|
||||
<dd><p>Search for syndicated photos that have saved to the library</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-export-not-saved-to-library">
|
||||
<span class="sig-name descname"><span class="pre">--not-saved-to-library</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-osxphotos-export-not-saved-to-library" title="Permalink to this definition">#</a></dt>
|
||||
<dd><p>Search for syndicated photos that have not saved to the library</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-export-regex">
|
||||
<span class="sig-name descname"><span class="pre">--regex</span></span><span class="sig-prename descclassname"> <span class="pre"><REGEX</span> <span class="pre">TEMPLATE></span></span><a class="headerlink" href="#cmdoption-osxphotos-export-regex" title="Permalink to this definition">#</a></dt>
|
||||
@@ -1857,6 +1893,12 @@ to modify this behavior.</p>
|
||||
<dd><p>Attempt to download missing photos from iCloud. The current implementation uses Applescript to interact with Photos to export the photo which will force Photos to download from iCloud if the photo does not exist on disk. This will be slow and will require internet connection. This obviously only works if the Photos library is synched to iCloud. Note: –download-missing does not currently export all burst images; only the primary photo will be exported–associated burst images will be skipped.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-export-export-aae">
|
||||
<span class="sig-name descname"><span class="pre">--export-aae</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-osxphotos-export-export-aae" title="Permalink to this definition">#</a></dt>
|
||||
<dd><p>Also export an adjustments file detailing edits made to the original. The resulting file is named photoname.AAE. Note that to import these files back to Photos succesfully, you also need to export the edited photo and match the filename format Photos.app expects: –filename ‘IMG_{edited_version?E,}{id:04d}’ –edited-suffix ‘’</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-export-sidecar">
|
||||
<span class="sig-name descname"><span class="pre">--sidecar</span></span><span class="sig-prename descclassname"> <span class="pre"><FORMAT></span></span><a class="headerlink" href="#cmdoption-osxphotos-export-sidecar" title="Permalink to this definition">#</a></dt>
|
||||
@@ -2332,7 +2374,11 @@ to modify this behavior.</p>
|
||||
</section>
|
||||
<section id="osxphotos-import">
|
||||
<h3>import<a class="headerlink" href="#osxphotos-import" title="Permalink to this heading">#</a></h3>
|
||||
<p>Import photos and videos into Photos.</p>
|
||||
<p>Import photos and videos into Photos. Photos will be imported into the
|
||||
most recently opened Photos library.</p>
|
||||
<p>Photos are imported one at a time thus the “Imports” album in Photos will show
|
||||
a new import group for each photo imported. Batch import into a single import
|
||||
group will be added in a future release.</p>
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>osxphotos import <span class="o">[</span>OPTIONS<span class="o">]</span> <span class="o">[</span>FILES<span class="o">]</span>...
|
||||
</pre></div>
|
||||
</div>
|
||||
@@ -2781,6 +2827,12 @@ If the same query option is provided multiple times, they are treated as
|
||||
<dd><p>Print output in JSON format.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-query-count">
|
||||
<span class="sig-name descname"><span class="pre">--count</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-osxphotos-query-count" title="Permalink to this definition">#</a></dt>
|
||||
<dd><p>Print count of photos matching query and exit.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-query-keyword">
|
||||
<span class="sig-name descname"><span class="pre">--keyword</span></span><span class="sig-prename descclassname"> <span class="pre"><KEYWORD></span></span><a class="headerlink" href="#cmdoption-osxphotos-query-keyword" title="Permalink to this definition">#</a></dt>
|
||||
@@ -3225,6 +3277,30 @@ If the same query option is provided multiple times, they are treated as
|
||||
<dd><p>Search for photos that are not in iCloud (have not been synched)</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-query-syndicated">
|
||||
<span class="sig-name descname"><span class="pre">--syndicated</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-osxphotos-query-syndicated" title="Permalink to this definition">#</a></dt>
|
||||
<dd><p>Search for photos that have been shared via syndication (‘Shared with You’ album via Messages, etc.)</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-query-not-syndicated">
|
||||
<span class="sig-name descname"><span class="pre">--not-syndicated</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-osxphotos-query-not-syndicated" title="Permalink to this definition">#</a></dt>
|
||||
<dd><p>Search for photos that have not been shared via syndication (‘Shared with You’ album via Messages, etc.)</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-query-saved-to-library">
|
||||
<span class="sig-name descname"><span class="pre">--saved-to-library</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-osxphotos-query-saved-to-library" title="Permalink to this definition">#</a></dt>
|
||||
<dd><p>Search for syndicated photos that have saved to the library</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-query-not-saved-to-library">
|
||||
<span class="sig-name descname"><span class="pre">--not-saved-to-library</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-osxphotos-query-not-saved-to-library" title="Permalink to this definition">#</a></dt>
|
||||
<dd><p>Search for syndicated photos that have not saved to the library</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-query-regex">
|
||||
<span class="sig-name descname"><span class="pre">--regex</span></span><span class="sig-prename descclassname"> <span class="pre"><REGEX</span> <span class="pre">TEMPLATE></span></span><a class="headerlink" href="#cmdoption-osxphotos-query-regex" title="Permalink to this definition">#</a></dt>
|
||||
@@ -3762,6 +3838,30 @@ If the same query option is provided multiple times, they are treated as
|
||||
<dd><p>Search for photos that are not in iCloud (have not been synched)</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-repl-syndicated">
|
||||
<span class="sig-name descname"><span class="pre">--syndicated</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-osxphotos-repl-syndicated" title="Permalink to this definition">#</a></dt>
|
||||
<dd><p>Search for photos that have been shared via syndication (‘Shared with You’ album via Messages, etc.)</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-repl-not-syndicated">
|
||||
<span class="sig-name descname"><span class="pre">--not-syndicated</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-osxphotos-repl-not-syndicated" title="Permalink to this definition">#</a></dt>
|
||||
<dd><p>Search for photos that have not been shared via syndication (‘Shared with You’ album via Messages, etc.)</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-repl-saved-to-library">
|
||||
<span class="sig-name descname"><span class="pre">--saved-to-library</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-osxphotos-repl-saved-to-library" title="Permalink to this definition">#</a></dt>
|
||||
<dd><p>Search for syndicated photos that have saved to the library</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-repl-not-saved-to-library">
|
||||
<span class="sig-name descname"><span class="pre">--not-saved-to-library</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-osxphotos-repl-not-saved-to-library" title="Permalink to this definition">#</a></dt>
|
||||
<dd><p>Search for syndicated photos that have not saved to the library</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-repl-regex">
|
||||
<span class="sig-name descname"><span class="pre">--regex</span></span><span class="sig-prename descclassname"> <span class="pre"><REGEX</span> <span class="pre">TEMPLATE></span></span><a class="headerlink" href="#cmdoption-osxphotos-repl-regex" title="Permalink to this definition">#</a></dt>
|
||||
@@ -4421,6 +4521,30 @@ two different computers, you can export the metadata to a shared folder.</p>
|
||||
<dd><p>Search for photos that are not in iCloud (have not been synched)</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-sync-syndicated">
|
||||
<span class="sig-name descname"><span class="pre">--syndicated</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-osxphotos-sync-syndicated" title="Permalink to this definition">#</a></dt>
|
||||
<dd><p>Search for photos that have been shared via syndication (‘Shared with You’ album via Messages, etc.)</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-sync-not-syndicated">
|
||||
<span class="sig-name descname"><span class="pre">--not-syndicated</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-osxphotos-sync-not-syndicated" title="Permalink to this definition">#</a></dt>
|
||||
<dd><p>Search for photos that have not been shared via syndication (‘Shared with You’ album via Messages, etc.)</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-sync-saved-to-library">
|
||||
<span class="sig-name descname"><span class="pre">--saved-to-library</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-osxphotos-sync-saved-to-library" title="Permalink to this definition">#</a></dt>
|
||||
<dd><p>Search for syndicated photos that have saved to the library</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-sync-not-saved-to-library">
|
||||
<span class="sig-name descname"><span class="pre">--not-saved-to-library</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-osxphotos-sync-not-saved-to-library" title="Permalink to this definition">#</a></dt>
|
||||
<dd><p>Search for syndicated photos that have not saved to the library</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="std option">
|
||||
<dt class="sig sig-object std" id="cmdoption-osxphotos-sync-regex">
|
||||
<span class="sig-name descname"><span class="pre">--regex</span></span><span class="sig-prename descclassname"> <span class="pre"><REGEX</span> <span class="pre">TEMPLATE></span></span><a class="headerlink" href="#cmdoption-osxphotos-sync-regex" title="Permalink to this definition">#</a></dt>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1"/>
|
||||
<meta name="color-scheme" content="light dark"><link rel="index" title="Index" href="#" /><link rel="search" title="Search" href="search.html" />
|
||||
|
||||
<meta name="generator" content="sphinx-5.3.0, furo 2022.09.29"/><title>Index - osxphotos 0.58.2 documentation</title>
|
||||
<meta name="generator" content="sphinx-5.3.0, furo 2022.09.29"/><title>Index - osxphotos 0.60.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?digest=d81277517bee4d6b0349d71bb2661d4890b5617c" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css" />
|
||||
@@ -122,7 +122,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="index.html"><div class="brand">osxphotos 0.58.2 documentation</div></a>
|
||||
<a href="index.html"><div class="brand">osxphotos 0.60.7 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -145,7 +145,7 @@
|
||||
<div class="sidebar-sticky"><a class="sidebar-brand" href="index.html">
|
||||
|
||||
|
||||
<span class="sidebar-brand-text">osxphotos 0.58.2 documentation</span>
|
||||
<span class="sidebar-brand-text">osxphotos 0.60.7 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
||||
<input class="sidebar-search" placeholder=Search name="q" aria-label="Search">
|
||||
@@ -423,6 +423,13 @@
|
||||
|
||||
<ul>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-export-convert-to-jpeg">osxphotos-export command line option</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
<li>
|
||||
--count
|
||||
|
||||
<ul>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-query-count">osxphotos-query command line option</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
<li>
|
||||
@@ -464,8 +471,6 @@
|
||||
--db
|
||||
|
||||
<ul>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-library">osxphotos command line option</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-albums-library">osxphotos-albums command line option</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-batch-edit-library">osxphotos-batch-edit command line option</a>
|
||||
@@ -766,6 +771,13 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-orphans-export">osxphotos-orphans command line option</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-sync-e">osxphotos-sync command line option</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
<li>
|
||||
--export-aae
|
||||
|
||||
<ul>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-export-export-aae">osxphotos-export command line option</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
<li>
|
||||
@@ -1137,8 +1149,6 @@
|
||||
--json
|
||||
|
||||
<ul>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-json">osxphotos command line option</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-albums-json">osxphotos-albums command line option</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-dump-json">osxphotos-dump command line option</a>
|
||||
@@ -1226,8 +1236,6 @@
|
||||
--library
|
||||
|
||||
<ul>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-library">osxphotos command line option</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-albums-library">osxphotos-albums command line option</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-batch-edit-library">osxphotos-batch-edit command line option</a>
|
||||
@@ -1563,8 +1571,6 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-sync-not-cloudasset">osxphotos-sync command line option</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li>
|
||||
--not-edited
|
||||
|
||||
@@ -1595,6 +1601,8 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-sync-not-favorite">osxphotos-sync command line option</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li>
|
||||
--not-hdr
|
||||
|
||||
@@ -1728,6 +1736,21 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-repl-not-reference">osxphotos-repl command line option</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-sync-not-reference">osxphotos-sync command line option</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
<li>
|
||||
--not-saved-to-library
|
||||
|
||||
<ul>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-add-locations-not-saved-to-library">osxphotos-add-locations command line option</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-export-not-saved-to-library">osxphotos-export command line option</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-query-not-saved-to-library">osxphotos-query command line option</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-repl-not-saved-to-library">osxphotos-repl command line option</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-sync-not-saved-to-library">osxphotos-sync command line option</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
<li>
|
||||
@@ -1786,6 +1809,21 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-repl-not-slow-mo">osxphotos-repl command line option</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-sync-not-slow-mo">osxphotos-sync command line option</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
<li>
|
||||
--not-syndicated
|
||||
|
||||
<ul>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-add-locations-not-syndicated">osxphotos-add-locations command line option</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-export-not-syndicated">osxphotos-export command line option</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-query-not-syndicated">osxphotos-query command line option</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-repl-not-syndicated">osxphotos-repl command line option</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-sync-not-syndicated">osxphotos-sync command line option</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
<li>
|
||||
@@ -2132,6 +2170,21 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-export-save-config">osxphotos-export command line option</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-exportdb-save-config">osxphotos-exportdb command line option</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
<li>
|
||||
--saved-to-library
|
||||
|
||||
<ul>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-add-locations-saved-to-library">osxphotos-add-locations command line option</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-export-saved-to-library">osxphotos-export command line option</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-query-saved-to-library">osxphotos-query command line option</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-repl-saved-to-library">osxphotos-repl command line option</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-sync-saved-to-library">osxphotos-sync command line option</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
<li>
|
||||
@@ -2303,6 +2356,21 @@
|
||||
|
||||
<ul>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-diff-s">osxphotos-diff command line option</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
<li>
|
||||
--syndicated
|
||||
|
||||
<ul>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-add-locations-syndicated">osxphotos-add-locations command line option</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-export-syndicated">osxphotos-export command line option</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-query-syndicated">osxphotos-query command line option</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-repl-syndicated">osxphotos-repl command line option</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-sync-syndicated">osxphotos-sync command line option</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
<li>
|
||||
@@ -2966,10 +3034,16 @@
|
||||
<li><a href="reference.html#osxphotos.QueryOptions.added_before">added_before (osxphotos.QueryOptions attribute)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.QueryOptions.added_in_last">added_in_last (osxphotos.QueryOptions attribute)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.PlaceInfo.address">address (osxphotos.PlaceInfo property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.PlaceInfo.address_str">address_str (osxphotos.PlaceInfo property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.ExifTool.addvalues">addvalues() (osxphotos.ExifTool method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.PhotoInfo.adjustments">adjustments (osxphotos.PhotoInfo property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.PhotoInfo.adjustments_path">adjustments_path (osxphotos.PhotoInfo property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.QueryOptions.album">album (osxphotos.QueryOptions attribute)</a>
|
||||
</li>
|
||||
@@ -2991,10 +3065,10 @@
|
||||
<li><a href="reference.html#osxphotos.PhotosDB.albums">(osxphotos.PhotosDB property)</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="reference.html#osxphotos.PhotosDB.albums_as_dict">albums_as_dict (osxphotos.PhotosDB property)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="reference.html#osxphotos.PhotosDB.albums_shared">albums_shared (osxphotos.PhotosDB property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.PhotosDB.albums_shared_as_dict">albums_shared_as_dict (osxphotos.PhotosDB property)</a>
|
||||
@@ -3012,14 +3086,24 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-run-arg-ARGS">osxphotos-run command line option</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
<li><a href="reference.html#osxphotos.ExifTool.asdict">asdict() (osxphotos.ExifTool method)</a>
|
||||
<li><a href="reference.html#osxphotos.AlbumInfo.asdict">asdict() (osxphotos.AlbumInfo method)</a>
|
||||
|
||||
<ul>
|
||||
<li><a href="reference.html#osxphotos.ExifTool.asdict">(osxphotos.ExifTool method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.FaceInfo.asdict">(osxphotos.FaceInfo method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.FolderInfo.asdict">(osxphotos.FolderInfo method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.ImportInfo.asdict">(osxphotos.ImportInfo method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.MomentInfo.asdict">(osxphotos.MomentInfo method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.PersonInfo.asdict">(osxphotos.PersonInfo method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.PhotoInfo.asdict">(osxphotos.PhotoInfo method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.PlaceInfo.asdict">(osxphotos.PlaceInfo method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.ScoreInfo.asdict">(osxphotos.ScoreInfo method)</a>
|
||||
</li>
|
||||
@@ -3073,6 +3157,8 @@
|
||||
<table style="width: 100%" class="indextable genindextable"><tr>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="reference.html#osxphotos.SearchInfo.camera">camera (osxphotos.SearchInfo property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.FaceInfo.center">center (osxphotos.FaceInfo property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.SearchInfo.city">city (osxphotos.SearchInfo property)</a>
|
||||
</li>
|
||||
@@ -3086,11 +3172,13 @@
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.QueryOptions.cloudasset">cloudasset (osxphotos.QueryOptions attribute)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="reference.html#osxphotos.CommentInfo">CommentInfo (class in osxphotos)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="reference.html#osxphotos.PhotoInfo.comments">comments (osxphotos.PhotoInfo property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.ExportDB.connection">connection (osxphotos.ExportDB property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.ExportOptions.convert_to_jpeg">convert_to_jpeg (osxphotos.ExportOptions attribute)</a>
|
||||
</li>
|
||||
@@ -3099,6 +3187,8 @@
|
||||
<li><a href="reference.html#osxphotos.FileUtilNoOp.copy">copy() (osxphotos.FileUtilNoOp class method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.SearchInfo.country">country (osxphotos.SearchInfo property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.PlaceInfo.country_code">country_code (osxphotos.PlaceInfo property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.ExportDB.create_file_record">create_file_record() (osxphotos.ExportDB method)</a>
|
||||
</li>
|
||||
@@ -3214,14 +3304,16 @@
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.PhotoTemplate.expand_variables_to_str">expand_variables_to_str() (osxphotos.PhotoTemplate method)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="reference.html#osxphotos.PhotoExporter.export">export() (osxphotos.PhotoExporter method)</a>
|
||||
|
||||
<ul>
|
||||
<li><a href="reference.html#osxphotos.PhotoInfo.export">(osxphotos.PhotoInfo method)</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="reference.html#osxphotos.ExportOptions.export_aae">export_aae (osxphotos.ExportOptions attribute)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.ExportOptions.export_as_hardlink">export_as_hardlink (osxphotos.ExportOptions attribute)</a>
|
||||
</li>
|
||||
<li>
|
||||
@@ -3270,7 +3362,11 @@
|
||||
<li><a href="reference.html#osxphotos.PhotoInfo.face_info">(osxphotos.PhotoInfo property)</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
<li><a href="reference.html#osxphotos.FaceInfo.face_rect">face_rect() (osxphotos.FaceInfo method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.ExportOptions.face_regions">face_regions (osxphotos.ExportOptions attribute)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.FaceInfo">FaceInfo (class in osxphotos)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.PersonInfo.favorite">favorite (osxphotos.PersonInfo property)</a>
|
||||
|
||||
@@ -3312,9 +3408,17 @@
|
||||
<li><a href="reference.html#osxphotos.PhotosDB.folder_info">folder_info (osxphotos.PhotosDB property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.AlbumInfo.folder_list">folder_list (osxphotos.AlbumInfo property)</a>
|
||||
|
||||
<ul>
|
||||
<li><a href="reference.html#osxphotos.ProjectInfo.folder_list">(osxphotos.ProjectInfo property)</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
<li><a href="reference.html#osxphotos.AlbumInfo.folder_names">folder_names (osxphotos.AlbumInfo property)</a>
|
||||
|
||||
<ul>
|
||||
<li><a href="reference.html#osxphotos.ProjectInfo.folder_names">(osxphotos.ProjectInfo property)</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
<li><a href="reference.html#osxphotos.FolderInfo">FolderInfo (class in osxphotos)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.PhotosDB.folders">folders (osxphotos.PhotosDB property)</a>
|
||||
@@ -3451,10 +3555,10 @@
|
||||
<li><a href="reference.html#osxphotos.QueryOptions.incloud">(osxphotos.QueryOptions attribute)</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="reference.html#osxphotos.ExportOptions.increment">increment (osxphotos.ExportOptions attribute)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="reference.html#osxphotos.PhotoInfo.intrash">intrash (osxphotos.PhotoInfo property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.is_debug">is_debug() (in module osxphotos)</a>
|
||||
@@ -3462,6 +3566,8 @@
|
||||
<li><a href="reference.html#osxphotos.QueryOptions.is_reference">is_reference (osxphotos.QueryOptions attribute)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.PhotoInfo.iscloudasset">iscloudasset (osxphotos.PhotoInfo property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.PlaceInfo.ishome">ishome (osxphotos.PlaceInfo property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.PhotoInfo.ismissing">ismissing (osxphotos.PhotoInfo property)</a>
|
||||
</li>
|
||||
@@ -3485,11 +3591,11 @@
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.ExportOptions.jpeg_quality">jpeg_quality (osxphotos.ExportOptions attribute)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="reference.html#osxphotos.ExifTool.json">json() (osxphotos.ExifTool method)</a>
|
||||
|
||||
<ul>
|
||||
<li><a href="reference.html#osxphotos.FaceInfo.json">(osxphotos.FaceInfo method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.PersonInfo.json">(osxphotos.PersonInfo method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.PhotoInfo.json">(osxphotos.PhotoInfo method)</a>
|
||||
@@ -3595,10 +3701,10 @@
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.QueryOptions.missing_bursts">missing_bursts (osxphotos.QueryOptions attribute)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="reference.html#osxphotos.MomentInfo.modification_date">modification_date (osxphotos.MomentInfo property)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li>
|
||||
module
|
||||
|
||||
@@ -3613,6 +3719,10 @@
|
||||
<li><a href="reference.html#osxphotos.SearchInfo.month">month (osxphotos.SearchInfo property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.QueryOptions.movies">movies (osxphotos.QueryOptions attribute)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.FaceInfo.mpri_reg_rect">mpri_reg_rect (osxphotos.FaceInfo property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.FaceInfo.mwg_rs_area">mwg_rs_area (osxphotos.FaceInfo property)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
</tr></table>
|
||||
@@ -3622,7 +3732,13 @@
|
||||
<h2>N</h2>
|
||||
<table style="width: 100%" class="indextable genindextable"><tr>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="reference.html#osxphotos.QueryOptions.name">name (osxphotos.QueryOptions attribute)</a>
|
||||
<li><a href="reference.html#osxphotos.PlaceInfo.name">name (osxphotos.PlaceInfo property)</a>
|
||||
|
||||
<ul>
|
||||
<li><a href="reference.html#osxphotos.QueryOptions.name">(osxphotos.QueryOptions attribute)</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
<li><a href="reference.html#osxphotos.PlaceInfo.names">names (osxphotos.PlaceInfo property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.SearchInfo.neighborhoods">neighborhoods (osxphotos.SearchInfo property)</a>
|
||||
</li>
|
||||
@@ -3667,6 +3783,8 @@
|
||||
<li><a href="reference.html#osxphotos.QueryOptions.not_portrait">not_portrait (osxphotos.QueryOptions attribute)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.QueryOptions.not_reference">not_reference (osxphotos.QueryOptions attribute)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.QueryOptions.not_saved_to_library">not_saved_to_library (osxphotos.QueryOptions attribute)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.QueryOptions.not_screenshot">not_screenshot (osxphotos.QueryOptions attribute)</a>
|
||||
</li>
|
||||
@@ -3675,6 +3793,8 @@
|
||||
<li><a href="reference.html#osxphotos.QueryOptions.not_shared">not_shared (osxphotos.QueryOptions attribute)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.QueryOptions.not_slow_mo">not_slow_mo (osxphotos.QueryOptions attribute)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.QueryOptions.not_syndicated">not_syndicated (osxphotos.QueryOptions attribute)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.QueryOptions.not_time_lapse">not_time_lapse (osxphotos.QueryOptions attribute)</a>
|
||||
</li>
|
||||
@@ -3709,12 +3829,6 @@
|
||||
osxphotos command line option
|
||||
|
||||
<ul>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-library">--db</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-json">--json</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-library">--library</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-v">--version</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-v">-v</a>
|
||||
@@ -3829,6 +3943,8 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-add-locations-not-portrait">--not-portrait</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-add-locations-not-reference">--not-reference</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-add-locations-not-saved-to-library">--not-saved-to-library</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-add-locations-not-screenshot">--not-screenshot</a>
|
||||
</li>
|
||||
@@ -3837,6 +3953,8 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-add-locations-not-shared">--not-shared</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-add-locations-not-slow-mo">--not-slow-mo</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-add-locations-not-syndicated">--not-syndicated</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-add-locations-not-time-lapse">--not-time-lapse</a>
|
||||
</li>
|
||||
@@ -3857,6 +3975,8 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-add-locations-query-function">--query-function</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-add-locations-regex">--regex</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-add-locations-saved-to-library">--saved-to-library</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-add-locations-screenshot">--screenshot</a>
|
||||
</li>
|
||||
@@ -3867,6 +3987,8 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-add-locations-shared">--shared</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-add-locations-slow-mo">--slow-mo</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-add-locations-syndicated">--syndicated</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-add-locations-theme">--theme</a>
|
||||
</li>
|
||||
@@ -4113,6 +4235,8 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-export-exiftool-option">--exiftool-option</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-export-exiftool-path">--exiftool-path</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-export-export-aae">--export-aae</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-export-export-as-hardlink">--export-as-hardlink</a>
|
||||
</li>
|
||||
@@ -4233,6 +4357,8 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-export-not-portrait">--not-portrait</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-export-not-reference">--not-reference</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-export-not-saved-to-library">--not-saved-to-library</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-export-not-screenshot">--not-screenshot</a>
|
||||
</li>
|
||||
@@ -4241,6 +4367,8 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-export-not-shared">--not-shared</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-export-not-slow-mo">--not-slow-mo</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-export-not-syndicated">--not-syndicated</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-export-not-time-lapse">--not-time-lapse</a>
|
||||
</li>
|
||||
@@ -4291,6 +4419,8 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-export-retry">--retry</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-export-save-config">--save-config</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-export-saved-to-library">--saved-to-library</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-export-screenshot">--screenshot</a>
|
||||
</li>
|
||||
@@ -4321,6 +4451,8 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-export-slow-mo">--slow-mo</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-export-strip">--strip</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-export-syndicated">--syndicated</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-export-theme">--theme</a>
|
||||
</li>
|
||||
@@ -4526,8 +4658,6 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-import-arg-FILES">FILES</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li>
|
||||
osxphotos-info command line option
|
||||
|
||||
@@ -4541,6 +4671,8 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-info-arg-PHOTOS_LIBRARY">PHOTOS_LIBRARY</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li>
|
||||
osxphotos-inspect command line option
|
||||
|
||||
@@ -4666,6 +4798,8 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-query-burst">--burst</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-query-cloudasset">--cloudasset</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-query-count">--count</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-query-library">--db</a>
|
||||
</li>
|
||||
@@ -4770,6 +4904,8 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-query-not-portrait">--not-portrait</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-query-not-reference">--not-reference</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-query-not-saved-to-library">--not-saved-to-library</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-query-not-screenshot">--not-screenshot</a>
|
||||
</li>
|
||||
@@ -4778,6 +4914,8 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-query-not-shared">--not-shared</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-query-not-slow-mo">--not-slow-mo</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-query-not-syndicated">--not-syndicated</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-query-not-time-lapse">--not-time-lapse</a>
|
||||
</li>
|
||||
@@ -4802,6 +4940,8 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-query-quiet">--quiet</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-query-regex">--regex</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-query-saved-to-library">--saved-to-library</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-query-screenshot">--screenshot</a>
|
||||
</li>
|
||||
@@ -4812,6 +4952,8 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-query-shared">--shared</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-query-slow-mo">--slow-mo</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-query-syndicated">--syndicated</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-query-time-lapse">--time-lapse</a>
|
||||
</li>
|
||||
@@ -4953,6 +5095,8 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-repl-not-portrait">--not-portrait</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-repl-not-reference">--not-reference</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-repl-not-saved-to-library">--not-saved-to-library</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-repl-not-screenshot">--not-screenshot</a>
|
||||
</li>
|
||||
@@ -4961,6 +5105,8 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-repl-not-shared">--not-shared</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-repl-not-slow-mo">--not-slow-mo</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-repl-not-syndicated">--not-syndicated</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-repl-not-time-lapse">--not-time-lapse</a>
|
||||
</li>
|
||||
@@ -4981,6 +5127,8 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-repl-query-function">--query-function</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-repl-regex">--regex</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-repl-saved-to-library">--saved-to-library</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-repl-screenshot">--screenshot</a>
|
||||
</li>
|
||||
@@ -4991,6 +5139,8 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-repl-shared">--shared</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-repl-slow-mo">--slow-mo</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-repl-syndicated">--syndicated</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-repl-time-lapse">--time-lapse</a>
|
||||
</li>
|
||||
@@ -5165,12 +5315,16 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-sync-not-portrait">--not-portrait</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-sync-not-reference">--not-reference</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-sync-not-saved-to-library">--not-saved-to-library</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-sync-not-screenshot">--not-screenshot</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-sync-not-selfie">--not-selfie</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-sync-not-slow-mo">--not-slow-mo</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-sync-not-syndicated">--not-syndicated</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-sync-not-time-lapse">--not-time-lapse</a>
|
||||
</li>
|
||||
@@ -5193,6 +5347,8 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-sync-regex">--regex</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-sync-R">--report</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-sync-saved-to-library">--saved-to-library</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-sync-screenshot">--screenshot</a>
|
||||
</li>
|
||||
@@ -5203,6 +5359,8 @@
|
||||
<li><a href="cli.html#cmdoption-osxphotos-sync-s">--set</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-sync-slow-mo">--slow-mo</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-sync-syndicated">--syndicated</a>
|
||||
</li>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-sync-theme">--theme</a>
|
||||
</li>
|
||||
@@ -5434,9 +5592,11 @@
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.QueryOptions.person">person (osxphotos.QueryOptions attribute)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.PhotoInfo.person_info">person_info (osxphotos.PhotoInfo property)</a>
|
||||
<li><a href="reference.html#osxphotos.FaceInfo.person_info">person_info (osxphotos.FaceInfo property)</a>
|
||||
|
||||
<ul>
|
||||
<li><a href="reference.html#osxphotos.PhotoInfo.person_info">(osxphotos.PhotoInfo property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.PhotosDB.person_info">(osxphotos.PhotosDB property)</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
@@ -5451,6 +5611,8 @@
|
||||
</li>
|
||||
</ul></li>
|
||||
<li><a href="reference.html#osxphotos.PhotosDB.persons_as_dict">persons_as_dict (osxphotos.PhotosDB property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.FaceInfo.photo">photo (osxphotos.FaceInfo property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.AlbumInfo.photo_index">photo_index() (osxphotos.AlbumInfo method)</a>
|
||||
</li>
|
||||
@@ -5470,10 +5632,10 @@
|
||||
<li><a href="reference.html#osxphotos.QueryOptions.photos">(osxphotos.QueryOptions attribute)</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
<li><a href="reference.html#osxphotos.PhotosDB.photos">photos() (osxphotos.PhotosDB method)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="reference.html#osxphotos.PhotosDB.photos">photos() (osxphotos.PhotosDB method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.PhotosDB.photos_by_uuid">photos_by_uuid() (osxphotos.PhotosDB method)</a>
|
||||
</li>
|
||||
<li>
|
||||
@@ -5510,6 +5672,8 @@
|
||||
<li><a href="reference.html#osxphotos.PhotoTemplate">PhotoTemplate (class in osxphotos)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.ExifTool.pid">pid (osxphotos.ExifTool property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.FaceInfo.pitch">pitch (osxphotos.FaceInfo property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.MomentInfo.pk">pk (osxphotos.MomentInfo property)</a>
|
||||
</li>
|
||||
@@ -5582,10 +5746,10 @@
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.PhotoTemplate.render">render() (osxphotos.PhotoTemplate method)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="reference.html#osxphotos.ExportOptions.render_options">render_options (osxphotos.ExportOptions attribute)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="reference.html#osxphotos.PhotoInfo.render_template">render_template() (osxphotos.PhotoInfo method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.ExportOptions.replace_keywords">replace_keywords (osxphotos.ExportOptions attribute)</a>
|
||||
@@ -5593,6 +5757,10 @@
|
||||
<li><a href="reference.html#osxphotos.ExportOptions.rich">rich (osxphotos.ExportOptions attribute)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.FileUtilNoOp.rmdir">rmdir() (osxphotos.FileUtilNoOp class method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.FaceInfo.roll">roll (osxphotos.FaceInfo property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.FaceInfo.roll_pitch_yaw">roll_pitch_yaw() (osxphotos.FaceInfo method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.ExifTool.run_commands">run_commands() (osxphotos.ExifTool method)</a>
|
||||
</li>
|
||||
@@ -5604,6 +5772,12 @@
|
||||
<h2>S</h2>
|
||||
<table style="width: 100%" class="indextable genindextable"><tr>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="reference.html#osxphotos.PhotoInfo.saved_to_library">saved_to_library (osxphotos.PhotoInfo property)</a>
|
||||
|
||||
<ul>
|
||||
<li><a href="reference.html#osxphotos.QueryOptions.saved_to_library">(osxphotos.QueryOptions attribute)</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
<li><a href="reference.html#osxphotos.PhotoInfo.score">score (osxphotos.PhotoInfo property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.ScoreInfo">ScoreInfo (class in osxphotos)</a>
|
||||
@@ -5651,6 +5825,8 @@
|
||||
<li><a href="reference.html#osxphotos.ExportOptions.sidecar">sidecar (osxphotos.ExportOptions attribute)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.ExportOptions.sidecar_drop_ext">sidecar_drop_ext (osxphotos.ExportOptions attribute)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.FaceInfo.size_pixels">size_pixels (osxphotos.FaceInfo property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.PhotoInfo.slow_mo">slow_mo (osxphotos.PhotoInfo property)</a>
|
||||
|
||||
@@ -5685,6 +5861,12 @@
|
||||
|
||||
<ul>
|
||||
<li><a href="cli.html#cmdoption-osxphotos-help-arg-SUBTOPIC">osxphotos-help command line option</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
<li><a href="reference.html#osxphotos.PhotoInfo.syndicated">syndicated (osxphotos.PhotoInfo property)</a>
|
||||
|
||||
<ul>
|
||||
<li><a href="reference.html#osxphotos.QueryOptions.syndicated">(osxphotos.QueryOptions attribute)</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
</ul></td>
|
||||
@@ -5695,6 +5877,8 @@
|
||||
<h2>T</h2>
|
||||
<table style="width: 100%" class="indextable genindextable"><tr>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="reference.html#osxphotos.PhotoInfo.tables">tables() (osxphotos.PhotoInfo method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.SearchInfo.text_found">text_found (osxphotos.SearchInfo property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.PhotoInfo.time_lapse">time_lapse (osxphotos.PhotoInfo property)</a>
|
||||
@@ -5709,6 +5893,8 @@
|
||||
|
||||
<ul>
|
||||
<li><a href="reference.html#osxphotos.FolderInfo.title">(osxphotos.FolderInfo property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.ImportInfo.title">(osxphotos.ImportInfo property)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#osxphotos.MomentInfo.title">(osxphotos.MomentInfo property)</a>
|
||||
</li>
|
||||
@@ -5837,6 +6023,10 @@
|
||||
<section id="Y" class="genindex-section">
|
||||
<h2>Y</h2>
|
||||
<table style="width: 100%" class="indextable genindextable"><tr>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="reference.html#osxphotos.FaceInfo.yaw">yaw (osxphotos.FaceInfo property)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="reference.html#osxphotos.QueryOptions.year">year (osxphotos.QueryOptions attribute)</a>
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<link rel="index" title="Index" href="genindex.html" /><link rel="search" title="Search" href="search.html" /><link rel="next" title="OSXPhotos" href="overview.html" />
|
||||
|
||||
<meta name="generator" content="sphinx-5.3.0, furo 2022.09.29"/>
|
||||
<title>osxphotos 0.58.2 documentation</title>
|
||||
<title>osxphotos 0.60.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?digest=d81277517bee4d6b0349d71bb2661d4890b5617c" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css" />
|
||||
@@ -124,7 +124,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="#"><div class="brand">osxphotos 0.58.2 documentation</div></a>
|
||||
<a href="#"><div class="brand">osxphotos 0.60.7 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -147,7 +147,7 @@
|
||||
<div class="sidebar-sticky"><a class="sidebar-brand" href="#">
|
||||
|
||||
|
||||
<span class="sidebar-brand-text">osxphotos 0.58.2 documentation</span>
|
||||
<span class="sidebar-brand-text">osxphotos 0.60.7 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
||||
<input class="sidebar-search" placeholder=Search name="q" aria-label="Search">
|
||||
@@ -284,6 +284,7 @@
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="reference.html">OSXPhotos Python Reference</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="reference.html#osxphotos.AlbumInfo"><code class="docutils literal notranslate"><span class="pre">AlbumInfo</span></code></a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.AlbumInfo.asdict"><code class="docutils literal notranslate"><span class="pre">AlbumInfo.asdict()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.AlbumInfo.folder_list"><code class="docutils literal notranslate"><span class="pre">AlbumInfo.folder_list</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.AlbumInfo.folder_names"><code class="docutils literal notranslate"><span class="pre">AlbumInfo.folder_names</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.AlbumInfo.parent"><code class="docutils literal notranslate"><span class="pre">AlbumInfo.parent</span></code></a></li>
|
||||
@@ -308,6 +309,7 @@
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="reference.html#osxphotos.ExportDB"><code class="docutils literal notranslate"><span class="pre">ExportDB</span></code></a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.ExportDB.close"><code class="docutils literal notranslate"><span class="pre">ExportDB.close()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.ExportDB.connection"><code class="docutils literal notranslate"><span class="pre">ExportDB.connection</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.ExportDB.create_file_record"><code class="docutils literal notranslate"><span class="pre">ExportDB.create_file_record()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.ExportDB.create_or_get_file_record"><code class="docutils literal notranslate"><span class="pre">ExportDB.create_or_get_file_record()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.ExportDB.delete_data_for_filepath"><code class="docutils literal notranslate"><span class="pre">ExportDB.delete_data_for_filepath()</span></code></a></li>
|
||||
@@ -359,6 +361,7 @@
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.ExportOptions.render_options"><code class="docutils literal notranslate"><span class="pre">ExportOptions.render_options</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.ExportOptions.replace_keywords"><code class="docutils literal notranslate"><span class="pre">ExportOptions.replace_keywords</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.ExportOptions.rich"><code class="docutils literal notranslate"><span class="pre">ExportOptions.rich</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.ExportOptions.export_aae"><code class="docutils literal notranslate"><span class="pre">ExportOptions.export_aae</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.ExportOptions.sidecar_drop_ext"><code class="docutils literal notranslate"><span class="pre">ExportOptions.sidecar_drop_ext</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.ExportOptions.sidecar"><code class="docutils literal notranslate"><span class="pre">ExportOptions.sidecar</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.ExportOptions.strip"><code class="docutils literal notranslate"><span class="pre">ExportOptions.strip</span></code></a></li>
|
||||
@@ -382,6 +385,22 @@
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.ExportResults.datetime"><code class="docutils literal notranslate"><span class="pre">ExportResults.datetime</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="reference.html#osxphotos.FaceInfo"><code class="docutils literal notranslate"><span class="pre">FaceInfo</span></code></a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.FaceInfo.asdict"><code class="docutils literal notranslate"><span class="pre">FaceInfo.asdict()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.FaceInfo.center"><code class="docutils literal notranslate"><span class="pre">FaceInfo.center</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.FaceInfo.face_rect"><code class="docutils literal notranslate"><span class="pre">FaceInfo.face_rect()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.FaceInfo.json"><code class="docutils literal notranslate"><span class="pre">FaceInfo.json()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.FaceInfo.mpri_reg_rect"><code class="docutils literal notranslate"><span class="pre">FaceInfo.mpri_reg_rect</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.FaceInfo.mwg_rs_area"><code class="docutils literal notranslate"><span class="pre">FaceInfo.mwg_rs_area</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.FaceInfo.person_info"><code class="docutils literal notranslate"><span class="pre">FaceInfo.person_info</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.FaceInfo.photo"><code class="docutils literal notranslate"><span class="pre">FaceInfo.photo</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.FaceInfo.pitch"><code class="docutils literal notranslate"><span class="pre">FaceInfo.pitch</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.FaceInfo.roll"><code class="docutils literal notranslate"><span class="pre">FaceInfo.roll</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.FaceInfo.roll_pitch_yaw"><code class="docutils literal notranslate"><span class="pre">FaceInfo.roll_pitch_yaw()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.FaceInfo.size_pixels"><code class="docutils literal notranslate"><span class="pre">FaceInfo.size_pixels</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.FaceInfo.yaw"><code class="docutils literal notranslate"><span class="pre">FaceInfo.yaw</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="reference.html#osxphotos.FileUtil"><code class="docutils literal notranslate"><span class="pre">FileUtil</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="reference.html#osxphotos.FileUtilNoOp"><code class="docutils literal notranslate"><span class="pre">FileUtilNoOp</span></code></a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.FileUtilNoOp.convert_to_jpeg"><code class="docutils literal notranslate"><span class="pre">FileUtilNoOp.convert_to_jpeg()</span></code></a></li>
|
||||
@@ -397,6 +416,7 @@
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="reference.html#osxphotos.FolderInfo"><code class="docutils literal notranslate"><span class="pre">FolderInfo</span></code></a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.FolderInfo.album_info"><code class="docutils literal notranslate"><span class="pre">FolderInfo.album_info</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.FolderInfo.asdict"><code class="docutils literal notranslate"><span class="pre">FolderInfo.asdict()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.FolderInfo.parent"><code class="docutils literal notranslate"><span class="pre">FolderInfo.parent</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.FolderInfo.subfolders"><code class="docutils literal notranslate"><span class="pre">FolderInfo.subfolders</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.FolderInfo.title"><code class="docutils literal notranslate"><span class="pre">FolderInfo.title</span></code></a></li>
|
||||
@@ -404,7 +424,9 @@
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="reference.html#osxphotos.ImportInfo"><code class="docutils literal notranslate"><span class="pre">ImportInfo</span></code></a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.ImportInfo.asdict"><code class="docutils literal notranslate"><span class="pre">ImportInfo.asdict()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.ImportInfo.photos"><code class="docutils literal notranslate"><span class="pre">ImportInfo.photos</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.ImportInfo.title"><code class="docutils literal notranslate"><span class="pre">ImportInfo.title</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="reference.html#osxphotos.LikeInfo"><code class="docutils literal notranslate"><span class="pre">LikeInfo</span></code></a></li>
|
||||
@@ -439,6 +461,7 @@
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="reference.html#osxphotos.PhotoInfo"><code class="docutils literal notranslate"><span class="pre">PhotoInfo</span></code></a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.PhotoInfo.adjustments"><code class="docutils literal notranslate"><span class="pre">PhotoInfo.adjustments</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.PhotoInfo.adjustments_path"><code class="docutils literal notranslate"><span class="pre">PhotoInfo.adjustments_path</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.PhotoInfo.album_info"><code class="docutils literal notranslate"><span class="pre">PhotoInfo.album_info</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.PhotoInfo.albums"><code class="docutils literal notranslate"><span class="pre">PhotoInfo.albums</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.PhotoInfo.asdict"><code class="docutils literal notranslate"><span class="pre">PhotoInfo.asdict()</span></code></a></li>
|
||||
@@ -512,6 +535,7 @@
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.PhotoInfo.project_info"><code class="docutils literal notranslate"><span class="pre">PhotoInfo.project_info</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.PhotoInfo.raw_original"><code class="docutils literal notranslate"><span class="pre">PhotoInfo.raw_original</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.PhotoInfo.render_template"><code class="docutils literal notranslate"><span class="pre">PhotoInfo.render_template()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.PhotoInfo.saved_to_library"><code class="docutils literal notranslate"><span class="pre">PhotoInfo.saved_to_library</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.PhotoInfo.score"><code class="docutils literal notranslate"><span class="pre">PhotoInfo.score</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.PhotoInfo.screenshot"><code class="docutils literal notranslate"><span class="pre">PhotoInfo.screenshot</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.PhotoInfo.search_info"><code class="docutils literal notranslate"><span class="pre">PhotoInfo.search_info</span></code></a></li>
|
||||
@@ -519,6 +543,8 @@
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.PhotoInfo.selfie"><code class="docutils literal notranslate"><span class="pre">PhotoInfo.selfie</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.PhotoInfo.shared"><code class="docutils literal notranslate"><span class="pre">PhotoInfo.shared</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.PhotoInfo.slow_mo"><code class="docutils literal notranslate"><span class="pre">PhotoInfo.slow_mo</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.PhotoInfo.syndicated"><code class="docutils literal notranslate"><span class="pre">PhotoInfo.syndicated</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.PhotoInfo.tables"><code class="docutils literal notranslate"><span class="pre">PhotoInfo.tables()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.PhotoInfo.time_lapse"><code class="docutils literal notranslate"><span class="pre">PhotoInfo.time_lapse</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.PhotoInfo.title"><code class="docutils literal notranslate"><span class="pre">PhotoInfo.title</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.PhotoInfo.tzoffset"><code class="docutils literal notranslate"><span class="pre">PhotoInfo.tzoffset</span></code></a></li>
|
||||
@@ -584,8 +610,21 @@
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.PhotosDB.query"><code class="docutils literal notranslate"><span class="pre">PhotosDB.query()</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="reference.html#osxphotos.PlaceInfo"><code class="docutils literal notranslate"><span class="pre">PlaceInfo</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="reference.html#osxphotos.ProjectInfo"><code class="docutils literal notranslate"><span class="pre">ProjectInfo</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="reference.html#osxphotos.PlaceInfo"><code class="docutils literal notranslate"><span class="pre">PlaceInfo</span></code></a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.PlaceInfo.address"><code class="docutils literal notranslate"><span class="pre">PlaceInfo.address</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.PlaceInfo.address_str"><code class="docutils literal notranslate"><span class="pre">PlaceInfo.address_str</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.PlaceInfo.asdict"><code class="docutils literal notranslate"><span class="pre">PlaceInfo.asdict()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.PlaceInfo.country_code"><code class="docutils literal notranslate"><span class="pre">PlaceInfo.country_code</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.PlaceInfo.ishome"><code class="docutils literal notranslate"><span class="pre">PlaceInfo.ishome</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.PlaceInfo.name"><code class="docutils literal notranslate"><span class="pre">PlaceInfo.name</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.PlaceInfo.names"><code class="docutils literal notranslate"><span class="pre">PlaceInfo.names</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="reference.html#osxphotos.ProjectInfo"><code class="docutils literal notranslate"><span class="pre">ProjectInfo</span></code></a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.ProjectInfo.folder_list"><code class="docutils literal notranslate"><span class="pre">ProjectInfo.folder_list</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.ProjectInfo.folder_names"><code class="docutils literal notranslate"><span class="pre">ProjectInfo.folder_names</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="reference.html#osxphotos.QueryOptions"><code class="docutils literal notranslate"><span class="pre">QueryOptions</span></code></a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.QueryOptions.added_after"><code class="docutils literal notranslate"><span class="pre">QueryOptions.added_after</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.QueryOptions.added_before"><code class="docutils literal notranslate"><span class="pre">QueryOptions.added_before</span></code></a></li>
|
||||
@@ -667,6 +706,10 @@
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.QueryOptions.uti"><code class="docutils literal notranslate"><span class="pre">QueryOptions.uti</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.QueryOptions.uuid"><code class="docutils literal notranslate"><span class="pre">QueryOptions.uuid</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.QueryOptions.year"><code class="docutils literal notranslate"><span class="pre">QueryOptions.year</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.QueryOptions.syndicated"><code class="docutils literal notranslate"><span class="pre">QueryOptions.syndicated</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.QueryOptions.not_syndicated"><code class="docutils literal notranslate"><span class="pre">QueryOptions.not_syndicated</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.QueryOptions.saved_to_library"><code class="docutils literal notranslate"><span class="pre">QueryOptions.saved_to_library</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="reference.html#osxphotos.QueryOptions.not_saved_to_library"><code class="docutils literal notranslate"><span class="pre">QueryOptions.not_saved_to_library</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="reference.html#osxphotos.ScoreInfo"><code class="docutils literal notranslate"><span class="pre">ScoreInfo</span></code></a><ul>
|
||||
|
||||
BIN
docs/objects.inv
BIN
docs/objects.inv
Binary file not shown.
@@ -6,7 +6,7 @@
|
||||
<link rel="index" title="Index" href="genindex.html" /><link rel="search" title="Search" href="search.html" /><link rel="next" title="OSXPhotos Tutorial" href="tutorial.html" /><link rel="prev" title="Welcome to OSXPhotos’s documentation!" href="index.html" />
|
||||
|
||||
<meta name="generator" content="sphinx-5.3.0, furo 2022.09.29"/>
|
||||
<title>OSXPhotos - osxphotos 0.58.2 documentation</title>
|
||||
<title>OSXPhotos - osxphotos 0.60.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?digest=d81277517bee4d6b0349d71bb2661d4890b5617c" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css" />
|
||||
@@ -124,7 +124,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="index.html"><div class="brand">osxphotos 0.58.2 documentation</div></a>
|
||||
<a href="index.html"><div class="brand">osxphotos 0.60.7 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -147,7 +147,7 @@
|
||||
<div class="sidebar-sticky"><a class="sidebar-brand" href="index.html">
|
||||
|
||||
|
||||
<span class="sidebar-brand-text">osxphotos 0.58.2 documentation</span>
|
||||
<span class="sidebar-brand-text">osxphotos 0.60.7 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
||||
<input class="sidebar-search" placeholder=Search name="q" aria-label="Search">
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<link rel="index" title="Index" href="genindex.html" /><link rel="search" title="Search" href="search.html" /><link rel="next" title="OSXPhotos Python Reference" href="reference.html" /><link rel="prev" title="OSXPhotos Template System" href="template_help.html" />
|
||||
|
||||
<meta name="generator" content="sphinx-5.3.0, furo 2022.09.29"/>
|
||||
<title>OSXPhotos Python Package Overview - osxphotos 0.58.2 documentation</title>
|
||||
<title>OSXPhotos Python Package Overview - osxphotos 0.60.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?digest=d81277517bee4d6b0349d71bb2661d4890b5617c" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css" />
|
||||
@@ -124,7 +124,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="index.html"><div class="brand">osxphotos 0.58.2 documentation</div></a>
|
||||
<a href="index.html"><div class="brand">osxphotos 0.60.7 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -147,7 +147,7 @@
|
||||
<div class="sidebar-sticky"><a class="sidebar-brand" href="index.html">
|
||||
|
||||
|
||||
<span class="sidebar-brand-text">osxphotos 0.58.2 documentation</span>
|
||||
<span class="sidebar-brand-text">osxphotos 0.60.7 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
||||
<input class="sidebar-search" placeholder=Search name="q" aria-label="Search">
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1"/>
|
||||
<meta name="color-scheme" content="light dark"><link rel="index" title="Index" href="genindex.html" /><link rel="search" title="Search" href="search.html" />
|
||||
|
||||
<meta name="generator" content="sphinx-5.3.0, furo 2022.09.29"/><title>Python Module Index - osxphotos 0.58.2 documentation</title>
|
||||
<meta name="generator" content="sphinx-5.3.0, furo 2022.09.29"/><title>Python Module Index - osxphotos 0.60.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?digest=d81277517bee4d6b0349d71bb2661d4890b5617c" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css" />
|
||||
@@ -122,7 +122,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="index.html"><div class="brand">osxphotos 0.58.2 documentation</div></a>
|
||||
<a href="index.html"><div class="brand">osxphotos 0.60.7 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -145,7 +145,7 @@
|
||||
<div class="sidebar-sticky"><a class="sidebar-brand" href="index.html">
|
||||
|
||||
|
||||
<span class="sidebar-brand-text">osxphotos 0.58.2 documentation</span>
|
||||
<span class="sidebar-brand-text">osxphotos 0.60.7 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
||||
<input class="sidebar-search" placeholder=Search name="q" aria-label="Search">
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -4,7 +4,7 @@
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1"/>
|
||||
<meta name="color-scheme" content="light dark"><link rel="index" title="Index" href="genindex.html" /><link rel="search" title="Search" href="#" />
|
||||
|
||||
<meta name="generator" content="sphinx-5.3.0, furo 2022.09.29"/><title>Search - osxphotos 0.58.2 documentation</title><link rel="stylesheet" type="text/css" href="_static/pygments.css" />
|
||||
<meta name="generator" content="sphinx-5.3.0, furo 2022.09.29"/><title>Search - osxphotos 0.60.7 documentation</title><link rel="stylesheet" type="text/css" href="_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?digest=d81277517bee4d6b0349d71bb2661d4890b5617c" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo-extensions.css?digest=30d1aed668e5c3a91c3e3bf6a60b675221979f0e" />
|
||||
@@ -121,7 +121,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="index.html"><div class="brand">osxphotos 0.58.2 documentation</div></a>
|
||||
<a href="index.html"><div class="brand">osxphotos 0.60.7 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -144,7 +144,7 @@
|
||||
<div class="sidebar-sticky"><a class="sidebar-brand" href="index.html">
|
||||
|
||||
|
||||
<span class="sidebar-brand-text">osxphotos 0.58.2 documentation</span>
|
||||
<span class="sidebar-brand-text">osxphotos 0.60.7 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="#" role="search">
|
||||
<input class="sidebar-search" placeholder=Search name="q" aria-label="Search">
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -6,7 +6,7 @@
|
||||
<link rel="index" title="Index" href="genindex.html" /><link rel="search" title="Search" href="search.html" /><link rel="next" title="OSXPhotos Python Package Overview" href="package_overview.html" /><link rel="prev" title="OSXPhotos Command Line Interface (CLI)" href="cli.html" />
|
||||
|
||||
<meta name="generator" content="sphinx-5.3.0, furo 2022.09.29"/>
|
||||
<title>OSXPhotos Template System - osxphotos 0.58.2 documentation</title>
|
||||
<title>OSXPhotos Template System - osxphotos 0.60.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?digest=d81277517bee4d6b0349d71bb2661d4890b5617c" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css" />
|
||||
@@ -124,7 +124,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="index.html"><div class="brand">osxphotos 0.58.2 documentation</div></a>
|
||||
<a href="index.html"><div class="brand">osxphotos 0.60.7 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -147,7 +147,7 @@
|
||||
<div class="sidebar-sticky"><a class="sidebar-brand" href="index.html">
|
||||
|
||||
|
||||
<span class="sidebar-brand-text">osxphotos 0.58.2 documentation</span>
|
||||
<span class="sidebar-brand-text">osxphotos 0.60.7 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
||||
<input class="sidebar-search" placeholder=Search name="q" aria-label="Search">
|
||||
@@ -613,7 +613,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="row-odd"><td><p>{osxphotos_version}</p></td>
|
||||
<td><p>The osxphotos version, e.g. ‘0.58.2’</p></td>
|
||||
<td><p>The osxphotos version, e.g. ‘0.60.7’</p></td>
|
||||
</tr>
|
||||
<tr class="row-even"><td><p>{osxphotos_cmd_line}</p></td>
|
||||
<td><p>The full command line used to run osxphotos</p></td>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<link rel="index" title="Index" href="genindex.html" /><link rel="search" title="Search" href="search.html" /><link rel="next" title="OSXPhotos Command Line Interface (CLI)" href="cli.html" /><link rel="prev" title="OSXPhotos" href="overview.html" />
|
||||
|
||||
<meta name="generator" content="sphinx-5.3.0, furo 2022.09.29"/>
|
||||
<title>OSXPhotos Tutorial - osxphotos 0.58.2 documentation</title>
|
||||
<title>OSXPhotos Tutorial - osxphotos 0.60.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?digest=d81277517bee4d6b0349d71bb2661d4890b5617c" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css" />
|
||||
@@ -124,7 +124,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="index.html"><div class="brand">osxphotos 0.58.2 documentation</div></a>
|
||||
<a href="index.html"><div class="brand">osxphotos 0.60.7 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -147,7 +147,7 @@
|
||||
<div class="sidebar-sticky"><a class="sidebar-brand" href="index.html">
|
||||
|
||||
|
||||
<span class="sidebar-brand-text">osxphotos 0.58.2 documentation</span>
|
||||
<span class="sidebar-brand-text">osxphotos 0.60.7 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
||||
<input class="sidebar-search" placeholder=Search name="q" aria-label="Search">
|
||||
|
||||
@@ -361,7 +361,7 @@ Template Substitutions
|
||||
* - {tab}
|
||||
- :A tab: '\t'
|
||||
* - {osxphotos_version}
|
||||
- The osxphotos version, e.g. '0.58.2'
|
||||
- The osxphotos version, e.g. '0.60.7'
|
||||
* - {osxphotos_cmd_line}
|
||||
- The full command line used to run osxphotos
|
||||
* - {album}
|
||||
|
||||
@@ -21,7 +21,6 @@ from osxphotos.sqlitekvstore import SQLiteKVStore
|
||||
|
||||
|
||||
class Latitude(click.ParamType):
|
||||
|
||||
name = "Latitude"
|
||||
|
||||
def convert(self, value, param, ctx):
|
||||
@@ -37,7 +36,6 @@ class Latitude(click.ParamType):
|
||||
|
||||
|
||||
class Longitude(click.ParamType):
|
||||
|
||||
name = "Longitude"
|
||||
|
||||
def convert(self, value, param, ctx):
|
||||
|
||||
@@ -23,10 +23,7 @@ to your function. You can then do whatever you want with the photos.
|
||||
from __future__ import annotations
|
||||
|
||||
import osxphotos
|
||||
from osxphotos.cli import (
|
||||
selection_command,
|
||||
verbose,
|
||||
)
|
||||
from osxphotos.cli import selection_command, verbose
|
||||
|
||||
|
||||
@selection_command
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
import sys
|
||||
|
||||
import osxphotos
|
||||
import click
|
||||
|
||||
import osxphotos
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.argument("album1")
|
||||
|
||||
52
examples/concurrent_export.py
Normal file
52
examples/concurrent_export.py
Normal file
@@ -0,0 +1,52 @@
|
||||
"""Example for concurrent export of photos using osxphotos.PhotoExporter.export()
|
||||
|
||||
Note: concurrent export can only be used on Python 3.11 and later due to the way
|
||||
python's sqlite3 module is implemented. See https://docs.python.org/3/library/sqlite3.html#sqlite3.threadsafety
|
||||
for more information.
|
||||
"""
|
||||
|
||||
import concurrent.futures
|
||||
import os
|
||||
import time
|
||||
|
||||
import click
|
||||
|
||||
import osxphotos
|
||||
from osxphotos.cli import echo, query_command, verbose
|
||||
|
||||
|
||||
@query_command()
|
||||
@click.option(
|
||||
"--workers",
|
||||
metavar="WORKERS",
|
||||
help="Maximum number of worker threads to use for export. "
|
||||
"If not specified, it will default to the number of processors on the machine, multiplied by 5.",
|
||||
type=int,
|
||||
)
|
||||
@click.argument(
|
||||
"export_dir",
|
||||
type=click.Path(exists=True, file_okay=False, dir_okay=True, writable=True),
|
||||
)
|
||||
def export(workers, export_dir, photos: list[osxphotos.PhotoInfo], **kwargs):
|
||||
"""Export photos to EXPORT_DIR using concurrent export.
|
||||
Use --workers to specify the number of worker threads to use.
|
||||
|
||||
This simple example exports only the original photo and does not export
|
||||
edited versions, live photos, etc.
|
||||
"""
|
||||
workers = workers or os.cpu_count() * 5
|
||||
echo(f"Exporting {len(photos)} photos to {export_dir} using {workers} workers")
|
||||
start_t = time.perf_counter()
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=workers) as executor:
|
||||
futures = [executor.submit(p.export, export_dir) for p in photos]
|
||||
exported = []
|
||||
for future in concurrent.futures.as_completed(futures):
|
||||
exported.extend(future.result())
|
||||
end_t = time.perf_counter()
|
||||
echo(
|
||||
f"Exported {len(exported)} photos to {export_dir} in {end_t-start_t:.4f} seconds"
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
export()
|
||||
@@ -1,6 +1,7 @@
|
||||
import osxphotos
|
||||
import os.path
|
||||
|
||||
import osxphotos
|
||||
|
||||
|
||||
def main():
|
||||
db = osxphotos.utils.get_system_library_path()
|
||||
|
||||
@@ -32,7 +32,7 @@ import osxphotos
|
||||
default=False,
|
||||
)
|
||||
def export(export_path, default_album, library_path, edited):
|
||||
""" Export all photos, organized by album """
|
||||
"""Export all photos, organized by album"""
|
||||
export_path = os.path.expanduser(export_path)
|
||||
library_path = os.path.expanduser(library_path) if library_path else None
|
||||
|
||||
@@ -66,11 +66,11 @@ def export(export_path, default_album, library_path, edited):
|
||||
os.makedirs(dest_dir)
|
||||
|
||||
filename = p.original_filename
|
||||
# export the photo but only if --edited, photo has adjustments, and
|
||||
# export the photo but only if --edited, photo has adjustments, and
|
||||
# path_edited is not None (can be None if edited photo is missing)
|
||||
if edited and p.hasadjustments and p.path_edited:
|
||||
# export edited version
|
||||
# use original filename with _edited appended but make sure suffix is
|
||||
# use original filename with _edited appended but make sure suffix is
|
||||
# same as edited file
|
||||
edited_filename = f"{pathlib.Path(filename).stem}_edited{pathlib.Path(p.path_edited).suffix}"
|
||||
exported = p.export(dest_dir, edited_filename, edited=True)
|
||||
|
||||
@@ -32,7 +32,7 @@ import osxphotos
|
||||
default=None,
|
||||
)
|
||||
def export(export_path, library_path, uuid):
|
||||
""" export photos to export_path and draw faces """
|
||||
"""export photos to export_path and draw faces"""
|
||||
library_path = os.path.expanduser(library_path) if library_path else None
|
||||
if library_path is not None:
|
||||
photosdb = osxphotos.PhotosDB(library_path)
|
||||
@@ -61,7 +61,7 @@ def export(export_path, library_path, uuid):
|
||||
|
||||
|
||||
def get_circle_points(xy, radius):
|
||||
""" Returns tuples of (x0, y0), (x1, y1) for a circle centered at x, y with radius
|
||||
"""Returns tuples of (x0, y0), (x1, y1) for a circle centered at x, y with radius
|
||||
|
||||
Arguments:
|
||||
xy: tuple of x, y coordinates
|
||||
|
||||
126
examples/export_previews.py
Normal file
126
examples/export_previews.py
Normal file
@@ -0,0 +1,126 @@
|
||||
""" Export previews for photos in the Photos library
|
||||
|
||||
To run this with osxphotos on currently selected photos:
|
||||
|
||||
osxphotos run export_previews.py --selected export_path
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pathlib
|
||||
import shutil
|
||||
|
||||
import click
|
||||
|
||||
import osxphotos
|
||||
from osxphotos.cli import echo, echo_error, query_command, verbose
|
||||
from osxphotos.cli.export import get_dirnames_from_template, get_filenames_from_template
|
||||
from osxphotos.cli.param_types import TemplateString
|
||||
from osxphotos.utils import pluralize
|
||||
|
||||
|
||||
@query_command
|
||||
@click.option("--dry-run", is_flag=True, help="Dry run, don't actually export")
|
||||
@click.option(
|
||||
"--directory",
|
||||
type=TemplateString(),
|
||||
help="Directory to export to under export_path. This is an osxphotos template string. "
|
||||
"For example, to export previews to directories based on creation date: "
|
||||
"--directory '{created.year}/{created.mm}/{created.dd}' ",
|
||||
)
|
||||
@click.option(
|
||||
"--filename",
|
||||
"filename_template",
|
||||
type=TemplateString(),
|
||||
help="Filename for exported preview. "
|
||||
"This is an osxphotos template string; "
|
||||
"for example, to export previews to filename based on creation date: "
|
||||
"--filename '{original_name}-{created.year}-{created.mm}-{created.dd}' ",
|
||||
)
|
||||
@click.argument(
|
||||
"export_dir", type=click.Path(exists=True, file_okay=False, dir_okay=True)
|
||||
)
|
||||
def export_previews(
|
||||
photos: list[osxphotos.PhotoInfo],
|
||||
dry_run: bool,
|
||||
directory: str,
|
||||
filename_template: str,
|
||||
export_dir: str,
|
||||
**kwargs,
|
||||
):
|
||||
"""Export previews for photos in the Photos library.
|
||||
|
||||
Pass one or more query options to select photos to export or use without query options
|
||||
to export all images.
|
||||
|
||||
If --directory is passed, the previews will be exported to subdirectories under export_path
|
||||
based on the template string passed to --directory. For example, to export previews to
|
||||
directories based on creation date: --directory '{created.year}/{created.mm}/{created.dd}'
|
||||
|
||||
If --filename is passed, the previews will be exported with the filename specified by the
|
||||
template string passed to --filename. For example, to export previews to filename based on
|
||||
creation date: --filename '{original_name}-{created.year}-{created.mm}-{created.dd}'
|
||||
|
||||
If --dry-run is passed, the previews will not actually be exported but the export will be
|
||||
simulated and the export paths printed to stdout.
|
||||
"""
|
||||
|
||||
verbose(f"Found {len(photos)} photo(s)")
|
||||
count = 0
|
||||
for photo in photos:
|
||||
try:
|
||||
# first derivative is the largest preview, so use that one
|
||||
preview = pathlib.Path(photo.path_derivatives[0])
|
||||
except IndexError:
|
||||
echo(f"No preview for {photo.original_filename} ({photo.uuid})")
|
||||
continue
|
||||
|
||||
verbose(f"Found preview for {photo.original_filename}: {preview}")
|
||||
count += export_preview_to_directory_with_filename(
|
||||
photo, preview, export_dir, directory, filename_template, dry_run
|
||||
)
|
||||
echo(f"Exported {count} preview {pluralize(count, 'image', 'images')}")
|
||||
|
||||
|
||||
def export_preview_to_directory_with_filename(
|
||||
photo: osxphotos.PhotoInfo,
|
||||
preview_path: pathlib.Path,
|
||||
export_dir: str,
|
||||
directory: str,
|
||||
filename_template: str,
|
||||
dry_run: bool,
|
||||
) -> int:
|
||||
"""Export preview for photo to directory with filename; returns count of images exported"""
|
||||
count = 0
|
||||
for dirname in get_dirnames_from_template(
|
||||
photo=photo,
|
||||
directory=directory,
|
||||
export_by_date=False,
|
||||
dest=export_dir,
|
||||
dry_run=dry_run,
|
||||
):
|
||||
for filename in get_filenames_from_template(
|
||||
photo=photo,
|
||||
filename_template=filename_template,
|
||||
export_dir=export_dir,
|
||||
dest_path=dirname,
|
||||
original_name=True,
|
||||
):
|
||||
# need to change filename extension to match preview
|
||||
filename = pathlib.Path(filename).with_suffix(preview_path.suffix)
|
||||
dest_path = pathlib.Path(dirname) / filename
|
||||
echo(
|
||||
f"Exporting preview for {photo.original_filename} ({photo.uuid}) to {dest_path}"
|
||||
)
|
||||
if not dry_run:
|
||||
try:
|
||||
shutil.copy(preview_path, dest_path)
|
||||
except Exception as e:
|
||||
echo_error(f"Error exporting preview: {e}")
|
||||
continue
|
||||
count += 1
|
||||
return count
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
export_previews()
|
||||
@@ -77,7 +77,9 @@ def place_folder(photo: osxphotos.PhotoInfo) -> str:
|
||||
return ""
|
||||
|
||||
|
||||
def photos_folders(photo: osxphotos.PhotoInfo, options: osxphotos.phototemplate.RenderOptions, **kwargs) -> Union[List, str]:
|
||||
def photos_folders(
|
||||
photo: osxphotos.PhotoInfo, options: osxphotos.phototemplate.RenderOptions, **kwargs
|
||||
) -> Union[List, str]:
|
||||
"""template function for use with --directory to export photos in a folder structure similar to Photos
|
||||
|
||||
Args:
|
||||
|
||||
@@ -29,7 +29,9 @@ def main():
|
||||
exported = photo.export(tempdir.name, use_photos_export=True, timeout=300)
|
||||
if photo.hasadjustments:
|
||||
exported.extend(
|
||||
photo.export(tempdir.name, use_photos_export=True, edited=True, timeout=300)
|
||||
photo.export(
|
||||
tempdir.name, use_photos_export=True, edited=True, timeout=300
|
||||
)
|
||||
)
|
||||
for filename in exported:
|
||||
print(f"Removing temporary file {filename}")
|
||||
|
||||
@@ -10,7 +10,7 @@ from osxphotos._constants import TIME_DELTA
|
||||
|
||||
@dataclass
|
||||
class Comment:
|
||||
""" Class for shared photo comments """
|
||||
"""Class for shared photo comments"""
|
||||
|
||||
uuid: str
|
||||
sort_fok: int
|
||||
@@ -22,7 +22,7 @@ class Comment:
|
||||
|
||||
@dataclass
|
||||
class Like:
|
||||
""" Class for shared photo likes """
|
||||
"""Class for shared photo likes"""
|
||||
|
||||
uuid: str
|
||||
sort_fok: int
|
||||
@@ -32,10 +32,10 @@ class Like:
|
||||
|
||||
|
||||
def get_shared_person_info(photosdb, hashed_person_id):
|
||||
""" returns tuple of (first name, last name, full name)
|
||||
for person invited to shared album with
|
||||
"""returns tuple of (first name, last name, full name)
|
||||
for person invited to shared album with
|
||||
ZINVITEEHASHEDPERSONID = hashed_person_id
|
||||
|
||||
|
||||
Args:
|
||||
photosdb: a osxphotos.PhotosDB object
|
||||
hashed_person_id: str, value of ZINVITEEHASHEDPERSONID to lookup
|
||||
@@ -66,12 +66,12 @@ def get_shared_person_info(photosdb, hashed_person_id):
|
||||
|
||||
|
||||
def get_comments(photosdb, uuid):
|
||||
""" return comments and likes, if any, for photo with uuid
|
||||
"""return comments and likes, if any, for photo with uuid
|
||||
|
||||
Args:
|
||||
photosdb: a osxphotos.PhotosDB object
|
||||
uuid: uuid of the photo
|
||||
|
||||
|
||||
Returns:
|
||||
tuple of (list of comments as Comment objects or [] if no comments, list of likes as Like objects or [] if no likes)
|
||||
"""
|
||||
|
||||
@@ -15,14 +15,14 @@ import time
|
||||
import click
|
||||
|
||||
import osxphotos
|
||||
from osxphotos.cli import get_photos_db, _list_libraries
|
||||
from osxphotos.cli import _list_libraries, get_photos_db
|
||||
|
||||
|
||||
def show(photo):
|
||||
""" open image with default image viewer
|
||||
|
||||
Note: This is for debugging only -- it will actually open any filetype which could
|
||||
be very, very bad.
|
||||
"""open image with default image viewer
|
||||
|
||||
Note: This is for debugging only -- it will actually open any filetype which could
|
||||
be very, very bad.
|
||||
|
||||
Args:
|
||||
photo: PhotoInfo object or a path to a photo on disk
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
""" Example function for use with osxphotos import --post-function option """
|
||||
|
||||
import typing as t
|
||||
import photoscript
|
||||
import pathlib
|
||||
import typing as t
|
||||
|
||||
import photoscript
|
||||
|
||||
from osxphotos.cli.import_cli import ReportRecord
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import os.path
|
||||
|
||||
import osxphotos
|
||||
|
||||
|
||||
def main():
|
||||
db = os.path.expanduser("~/Pictures/Photos Library.photoslibrary")
|
||||
photosdb = osxphotos.PhotosDB(db)
|
||||
@@ -15,11 +16,14 @@ def main():
|
||||
print(photosdb.albums_as_dict)
|
||||
|
||||
# find all photos with Keyword = Foo and containing John Smith
|
||||
photos = photosdb.photos(keywords=["Foo"],persons=["John Smith"])
|
||||
photos = photosdb.photos(keywords=["Foo"], persons=["John Smith"])
|
||||
|
||||
# find all photos that include Alice Smith but do not contain the keyword Bar
|
||||
photos = [p for p in photosdb.photos(persons=["Alice Smith"])
|
||||
if p not in photosdb.photos(keywords=["Bar"]) ]
|
||||
photos = [
|
||||
p
|
||||
for p in photosdb.photos(persons=["Alice Smith"])
|
||||
if p not in photosdb.photos(keywords=["Bar"])
|
||||
]
|
||||
for p in photos:
|
||||
print(
|
||||
p.uuid,
|
||||
@@ -34,5 +38,6 @@ def main():
|
||||
p.path,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
|
||||
from typing import List
|
||||
|
||||
|
||||
def myfilter(values: List[str]) -> List[str]:
|
||||
""" Custom filter to append "foo-" to template value """
|
||||
"""Custom filter to append "foo-" to template value"""
|
||||
values = ["foo-" + val for val in values]
|
||||
return values
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ from typing import Callable
|
||||
|
||||
from osxphotos import ExportResults, PhotoInfo
|
||||
from osxphotos.exiftool import ExifTool
|
||||
from osxphotos.utils import normalize_unicode
|
||||
from osxphotos.unicode import normalize_unicode
|
||||
|
||||
# Update this for your custom keyword to rating mapping
|
||||
RATINGS = {
|
||||
|
||||
@@ -13,18 +13,22 @@ from .exiftool import ExifTool
|
||||
from .export_db import ExportDB, ExportDBTemp
|
||||
from .fileutil import FileUtil, FileUtilNoOp
|
||||
from .momentinfo import MomentInfo
|
||||
from .personinfo import PersonInfo
|
||||
from .personinfo import FaceInfo, PersonInfo
|
||||
from .photoexporter import ExportOptions, ExportResults, PhotoExporter
|
||||
from .photoinfo import PhotoInfo
|
||||
from .photosalbum import PhotosAlbum, PhotosAlbumPhotoScript
|
||||
from .photosdb import PhotosDB
|
||||
from .photosdb._photosdb_process_comments import CommentInfo, LikeInfo
|
||||
from .phototables import PhotoTables
|
||||
from .phototemplate import PhotoTemplate
|
||||
from .placeinfo import PlaceInfo
|
||||
from .platform import is_macos
|
||||
from .queryoptions import QueryOptions
|
||||
from .scoreinfo import ScoreInfo
|
||||
from .searchinfo import SearchInfo
|
||||
|
||||
if is_macos:
|
||||
from .photosalbum import PhotosAlbum, PhotosAlbumPhotoScript
|
||||
|
||||
# configure logging; every module in osxphotos should use this logger
|
||||
logging.basicConfig(
|
||||
level=logging.DEBUG,
|
||||
@@ -44,6 +48,7 @@ __all__ = [
|
||||
"ExportDBTemp",
|
||||
"ExportOptions",
|
||||
"ExportResults",
|
||||
"FaceInfo",
|
||||
"FileUtil",
|
||||
"FileUtilNoOp",
|
||||
"FolderInfo",
|
||||
@@ -53,6 +58,7 @@ __all__ = [
|
||||
"PersonInfo",
|
||||
"PhotoExporter",
|
||||
"PhotoInfo",
|
||||
"PhotoTables",
|
||||
"PhotoTemplate",
|
||||
"PhotosAlbum",
|
||||
"PhotosAlbumPhotoScript",
|
||||
|
||||
@@ -2,10 +2,14 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import os.path
|
||||
import sqlite3
|
||||
from datetime import datetime
|
||||
from enum import Enum
|
||||
|
||||
logger: logging.Logger = logging.getLogger("osxphotos")
|
||||
|
||||
APP_NAME = "osxphotos"
|
||||
|
||||
OSXPHOTOS_URL = "https://github.com/RhetTbull/osxphotos"
|
||||
@@ -14,9 +18,6 @@ OSXPHOTOS_URL = "https://github.com/RhetTbull/osxphotos"
|
||||
# Apple Epoch is Jan 1, 2001
|
||||
TIME_DELTA = (datetime(2001, 1, 1, 0, 0) - datetime(1970, 1, 1, 0, 0)).total_seconds()
|
||||
|
||||
# Unicode format to use for comparing strings
|
||||
UNICODE_FORMAT = "NFC"
|
||||
|
||||
# which Photos library database versions have been tested
|
||||
# Photos 2.0 (10.12.6) == 2622
|
||||
# Photos 3.0 (10.13.6) == 3301
|
||||
@@ -124,6 +125,8 @@ _TESTED_OS_VERSIONS = [
|
||||
("13", "0"),
|
||||
("13", "1"),
|
||||
("13", "2"),
|
||||
("13", "3"),
|
||||
("13", "4"),
|
||||
]
|
||||
|
||||
# Photos 5 has persons who are empty string if unidentified face
|
||||
@@ -464,3 +467,12 @@ PROFILE_SORT_KEYS = [
|
||||
UUID_PATTERN = (
|
||||
r"[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"
|
||||
)
|
||||
# Reference: https://docs.python.org/3/library/sqlite3.html?highlight=sqlite3%20threadsafety#sqlite3.threadsafety
|
||||
# and https://docs.python.org/3/library/sqlite3.html?highlight=sqlite3%20threadsafety#sqlite3.connect
|
||||
# 3: serialized mode; Threads may share the module, connections and cursors
|
||||
# 3 is the default in the python.org python 3.11 distribution
|
||||
# earlier versions of python.org python 3.x default to 1 which means threads may not share
|
||||
# sqlite3 connections and thus PhotoInfo.export() cannot be used in a multithreaded environment
|
||||
# pass SQLITE_CHECK_SAME_THREAD to sqlite3.connect() to enable multithreaded access on systems that support it
|
||||
SQLITE_CHECK_SAME_THREAD = not sqlite3.threadsafety == 3
|
||||
logger.debug(f"{SQLITE_CHECK_SAME_THREAD=}, {sqlite3.threadsafety=}")
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
""" version info """
|
||||
|
||||
__version__ = "0.58.2"
|
||||
__version__ = "0.60.7"
|
||||
|
||||
@@ -18,6 +18,7 @@ from ._constants import (
|
||||
_PHOTOS_4_VERSION,
|
||||
_PHOTOS_5_ALBUM_KIND,
|
||||
_PHOTOS_5_FOLDER_KIND,
|
||||
_PHOTOS_5_VERSION,
|
||||
TIME_DELTA,
|
||||
AlbumSortOrder,
|
||||
)
|
||||
@@ -49,9 +50,8 @@ def sort_list_by_keys(values, sort_keys):
|
||||
ValueError: raised if len(values) != len(sort_keys)
|
||||
"""
|
||||
if len(values) != len(sort_keys):
|
||||
return ValueError("values and sort_keys must have same length")
|
||||
|
||||
return list(zip(*sorted(zip(sort_keys, values))))[1]
|
||||
raise ValueError("values and sort_keys must be same length")
|
||||
return [x for _, x in sorted(zip(sort_keys, values))]
|
||||
|
||||
|
||||
class AlbumInfoBaseClass:
|
||||
@@ -61,7 +61,7 @@ class AlbumInfoBaseClass:
|
||||
including folders, photos, etc.
|
||||
"""
|
||||
|
||||
def __init__(self, db=None, uuid=None):
|
||||
def __init__(self, db, uuid):
|
||||
self._uuid = uuid
|
||||
self._db = db
|
||||
self._title = self._db._dbalbum_details[uuid]["title"]
|
||||
@@ -121,7 +121,8 @@ class AlbumInfoBaseClass:
|
||||
@property
|
||||
def end_date(self):
|
||||
"""For Albums, return end date (most recent image) of album or None for albums with no images
|
||||
For Import Sessions, return end date of import sessions (when import was completed)"""
|
||||
For Import Sessions, return end date of import sessions (when import was completed)
|
||||
"""
|
||||
try:
|
||||
return self._end_date
|
||||
except AttributeError:
|
||||
@@ -163,6 +164,16 @@ class AlbumInfoBaseClass:
|
||||
self._owner = None
|
||||
return self._owner
|
||||
|
||||
def asdict(self):
|
||||
"""Return album info as a dict; does not include photos"""
|
||||
return {
|
||||
"uuid": self.uuid,
|
||||
"creation_date": self.creation_date,
|
||||
"start_date": self.start_date,
|
||||
"end_date": self.end_date,
|
||||
"owner": self.owner,
|
||||
}
|
||||
|
||||
def __len__(self):
|
||||
"""return number of photos contained in album"""
|
||||
return len(self.photos)
|
||||
@@ -174,6 +185,10 @@ class AlbumInfo(AlbumInfoBaseClass):
|
||||
including folders, photos, etc.
|
||||
"""
|
||||
|
||||
def __init__(self, db, uuid):
|
||||
super().__init__(db=db, uuid=uuid)
|
||||
self._title = self._db._dbalbum_details[uuid]["title"]
|
||||
|
||||
@property
|
||||
def title(self):
|
||||
"""return title / name of album"""
|
||||
@@ -205,10 +220,11 @@ class AlbumInfo(AlbumInfoBaseClass):
|
||||
|
||||
@property
|
||||
def folder_names(self):
|
||||
"""return hierarchical list of folders the album is contained in
|
||||
"""Return hierarchical list of folders the album is contained in
|
||||
the folder list is in form:
|
||||
["Top level folder", "sub folder 1", "sub folder 2", ...]
|
||||
returns empty list if album is not in any folders"""
|
||||
or empty list if album is not in any folders
|
||||
"""
|
||||
|
||||
try:
|
||||
return self._folder_names
|
||||
@@ -218,10 +234,9 @@ class AlbumInfo(AlbumInfoBaseClass):
|
||||
|
||||
@property
|
||||
def folder_list(self):
|
||||
"""return hierarchical list of folders the album is contained in
|
||||
as list of FolderInfo objects in form
|
||||
["Top level folder", "sub folder 1", "sub folder 2", ...]
|
||||
returns empty list if album is not in any folders"""
|
||||
"""Returns list of FolderInfo objects for each folder the album is contained in
|
||||
or empty list if album is not in any folders
|
||||
"""
|
||||
|
||||
try:
|
||||
return self._folders
|
||||
@@ -246,7 +261,7 @@ class AlbumInfo(AlbumInfoBaseClass):
|
||||
parent_pk = self._db._dbalbum_details[self._uuid]["parentfolder"]
|
||||
self._parent = (
|
||||
FolderInfo(db=self._db, uuid=self._db._dbalbums_pk[parent_pk])
|
||||
if parent_pk != self._db._folder_root_pk
|
||||
if parent_pk is not None and parent_pk != self._db._folder_root_pk
|
||||
else None
|
||||
)
|
||||
return self._parent
|
||||
@@ -281,27 +296,79 @@ class AlbumInfo(AlbumInfoBaseClass):
|
||||
f"Photo with uuid {photo.uuid} does not appear to be in this album"
|
||||
)
|
||||
|
||||
def asdict(self):
|
||||
"""Return album info as a dict; does not include photos"""
|
||||
dict_data = super().asdict()
|
||||
dict_data["title"] = self.title
|
||||
dict_data["folder_names"] = self.folder_names
|
||||
dict_data["folder_list"] = [f.uuid for f in self.folder_list]
|
||||
dict_data["sort_order"] = self.sort_order
|
||||
dict_data["parent"] = self.parent.uuid if self.parent else None
|
||||
return dict_data
|
||||
|
||||
|
||||
class ImportInfo(AlbumInfoBaseClass):
|
||||
"""Information about import sessions"""
|
||||
|
||||
def __init__(self, db, uuid):
|
||||
self._uuid = uuid
|
||||
self._db = db
|
||||
|
||||
if self._db._db_version >= _PHOTOS_5_VERSION:
|
||||
return super().__init__(db=db, uuid=uuid)
|
||||
|
||||
import_session = self._db._db_import_group[self._uuid]
|
||||
try:
|
||||
self._creation_date_timestamp = import_session[3]
|
||||
except (ValueError, TypeError, KeyError):
|
||||
self._creation_date_timestamp = datetime(1970, 1, 1)
|
||||
self._start_date_timestamp = self._creation_date_timestamp
|
||||
self._end_date_timestamp = self._creation_date_timestamp
|
||||
self._title = import_session[2]
|
||||
self._local_tz = get_local_tz(
|
||||
datetime.fromtimestamp(self._creation_date_timestamp + TIME_DELTA)
|
||||
)
|
||||
|
||||
@property
|
||||
def title(self):
|
||||
"""return title / name of import session"""
|
||||
return self._title
|
||||
|
||||
@property
|
||||
def photos(self):
|
||||
"""return list of photos contained in import session"""
|
||||
try:
|
||||
return self._photos
|
||||
except AttributeError:
|
||||
uuid_list, sort_order = zip(
|
||||
*[
|
||||
(uuid, self._db._dbphotos[uuid]["fok_import_session"])
|
||||
for uuid in self._db._dbphotos
|
||||
if self._db._dbphotos[uuid]["import_uuid"] == self.uuid
|
||||
if self._db._db_version >= _PHOTOS_5_VERSION:
|
||||
uuid_list, sort_order = zip(
|
||||
*[
|
||||
(uuid, self._db._dbphotos[uuid]["fok_import_session"])
|
||||
for uuid in self._db._dbphotos
|
||||
if self._db._dbphotos[uuid]["import_uuid"] == self.uuid
|
||||
]
|
||||
)
|
||||
sorted_uuid = sort_list_by_keys(uuid_list, sort_order)
|
||||
self._photos = self._db.photos_by_uuid(sorted_uuid)
|
||||
else:
|
||||
import_photo_uuids = [
|
||||
u
|
||||
for u in self._db._dbphotos
|
||||
if self._db._dbphotos[u]["import_uuid"] == self.uuid
|
||||
]
|
||||
)
|
||||
sorted_uuid = sort_list_by_keys(uuid_list, sort_order)
|
||||
self._photos = self._db.photos_by_uuid(sorted_uuid)
|
||||
self._photos = self._db.photos_by_uuid(import_photo_uuids)
|
||||
return self._photos
|
||||
|
||||
def asdict(self):
|
||||
"""Return import info as a dict; does not include photos"""
|
||||
return {
|
||||
"uuid": self.uuid,
|
||||
"creation_date": self.creation_date,
|
||||
"start_date": self.start_date,
|
||||
"end_date": self.end_date,
|
||||
"title": self.title,
|
||||
}
|
||||
|
||||
def __bool__(self):
|
||||
"""Always returns True
|
||||
A photo without an import session will return None for import_info,
|
||||
@@ -309,13 +376,32 @@ class ImportInfo(AlbumInfoBaseClass):
|
||||
"""
|
||||
return True
|
||||
|
||||
|
||||
class ProjectInfo(AlbumInfo):
|
||||
"""
|
||||
ProjectInfo with info about projects
|
||||
Projects are cards, calendars, slideshows, etc.
|
||||
"""
|
||||
|
||||
...
|
||||
@property
|
||||
def folder_names(self):
|
||||
"""Return hierarchical list of folders the album is contained in
|
||||
the folder list is in form:
|
||||
["Top level folder", "sub folder 1", "sub folder 2", ...]
|
||||
or empty list if album is not in any folders
|
||||
"""
|
||||
|
||||
# projects are not in folders
|
||||
return []
|
||||
|
||||
@property
|
||||
def folder_list(self):
|
||||
"""Returns list of FolderInfo objects for each folder the album is contained in
|
||||
or empty list if album is not in any folders
|
||||
"""
|
||||
|
||||
# projects are not in folders
|
||||
return []
|
||||
|
||||
|
||||
class FolderInfo:
|
||||
@@ -386,7 +472,7 @@ class FolderInfo:
|
||||
parent_pk = self._db._dbalbum_details[self._uuid]["parentfolder"]
|
||||
self._parent = (
|
||||
FolderInfo(db=self._db, uuid=self._db._dbalbums_pk[parent_pk])
|
||||
if parent_pk != self._db._folder_root_pk
|
||||
if parent_pk is not None and parent_pk != self._db._folder_root_pk
|
||||
else None
|
||||
)
|
||||
return self._parent
|
||||
@@ -416,6 +502,16 @@ class FolderInfo:
|
||||
self._folders = folders
|
||||
return self._folders
|
||||
|
||||
def asdict(self):
|
||||
"""Return folder info as a dict"""
|
||||
return {
|
||||
"title": self.title,
|
||||
"uuid": self.uuid,
|
||||
"parent": self.parent.uuid if self.parent is not None else None,
|
||||
"subfolders": [f.uuid for f in self.subfolders],
|
||||
"albums": [a.uuid for a in self.album_info],
|
||||
}
|
||||
|
||||
def __len__(self):
|
||||
"""returns count of folders + albums contained in the folder"""
|
||||
return len(self.subfolders) + len(self.album_info)
|
||||
|
||||
@@ -13,6 +13,7 @@ from osxphotos.debug import (
|
||||
set_debug,
|
||||
wrap_function,
|
||||
)
|
||||
from osxphotos.platform import is_macos
|
||||
|
||||
# apply any debug functions
|
||||
# need to do this before importing anything else so that the debug functions
|
||||
@@ -44,9 +45,7 @@ if args.get("--debug", False):
|
||||
print("Debugging enabled", file=sys.stderr)
|
||||
|
||||
from .about import about
|
||||
from .add_locations import add_locations
|
||||
from .albums import albums
|
||||
from .batch_edit import batch_edit
|
||||
from .cli import cli_main
|
||||
from .cli_commands import (
|
||||
abort,
|
||||
@@ -67,7 +66,6 @@ from .export import export
|
||||
from .exportdb import exportdb
|
||||
from .grep import grep
|
||||
from .help import help
|
||||
from .import_cli import import_cli
|
||||
from .info import info
|
||||
from .install_uninstall_run import install, run, uninstall
|
||||
from .keywords import keywords
|
||||
@@ -76,19 +74,24 @@ from .labels import labels
|
||||
from .list import _list_libraries, list_libraries
|
||||
from .orphans import orphans
|
||||
from .persons import persons
|
||||
from .photo_inspect import photo_inspect
|
||||
from .places import places
|
||||
from .query import query
|
||||
from .repl import repl
|
||||
from .show_command import show
|
||||
from .snap_diff import diff, snap
|
||||
from .sync import sync
|
||||
from .theme import theme
|
||||
from .timewarp import timewarp
|
||||
from .tutorial import tutorial
|
||||
from .uuid import uuid
|
||||
from .version import version
|
||||
|
||||
if is_macos:
|
||||
from .add_locations import add_locations
|
||||
from .batch_edit import batch_edit
|
||||
from .import_cli import import_cli
|
||||
from .photo_inspect import photo_inspect
|
||||
from .show_command import show
|
||||
from .sync import sync
|
||||
from .timewarp import timewarp
|
||||
from .uuid import uuid
|
||||
|
||||
install_traceback()
|
||||
|
||||
__all__ = [
|
||||
|
||||
@@ -5,9 +5,9 @@ from __future__ import annotations
|
||||
import datetime
|
||||
|
||||
import click
|
||||
import photoscript
|
||||
|
||||
import osxphotos
|
||||
from osxphotos.platform import assert_macos
|
||||
from osxphotos.queryoptions import IncompatibleQueryOptions, query_options_from_kwargs
|
||||
from osxphotos.utils import pluralize
|
||||
|
||||
@@ -18,6 +18,10 @@ from .param_types import TimeOffset
|
||||
from .rich_progress import rich_progress
|
||||
from .verbose import get_verbose_console, verbose_print
|
||||
|
||||
assert_macos()
|
||||
|
||||
import photoscript
|
||||
|
||||
|
||||
def get_location(
|
||||
photos: list[osxphotos.PhotoInfo], idx: int, window: datetime.timedelta
|
||||
|
||||
@@ -9,12 +9,16 @@ import json
|
||||
import sys
|
||||
|
||||
import click
|
||||
import photoscript
|
||||
|
||||
import osxphotos
|
||||
from osxphotos.phototemplate import RenderOptions
|
||||
from osxphotos.platform import assert_macos
|
||||
from osxphotos.sqlitekvstore import SQLiteKVStore
|
||||
|
||||
assert_macos()
|
||||
|
||||
import photoscript
|
||||
|
||||
from .cli_commands import echo, echo_error, selection_command, verbose
|
||||
from .kvstore import kvstore
|
||||
from .param_types import Latitude, Longitude, TemplateString
|
||||
@@ -88,7 +92,7 @@ def batch_edit(
|
||||
|
||||
This will set the title to "California vacation 2023 2023-02-20 001", and so on,
|
||||
the description to the reverse geolocation place name,
|
||||
and add the keywords to "Family", "Travel".
|
||||
and add the keywords "Family" and "Travel".
|
||||
|
||||
--title, --description, and --keyword may be any valid template string.
|
||||
See https://rhettbull.github.io/osxphotos/template_help.html
|
||||
|
||||
@@ -9,12 +9,11 @@ import click
|
||||
|
||||
from osxphotos._constants import PROFILE_SORT_KEYS
|
||||
from osxphotos._version import __version__
|
||||
from osxphotos.platform import is_macos
|
||||
|
||||
from .about import about
|
||||
from .add_locations import add_locations
|
||||
from .albums import albums
|
||||
from .batch_edit import batch_edit
|
||||
from .cli_params import DB_OPTION, DEBUG_OPTIONS, JSON_OPTION, VERSION_OPTION
|
||||
from .cli_params import DEBUG_OPTIONS, VERSION_OPTION
|
||||
from .common import OSXPHOTOS_HIDDEN
|
||||
from .debug_dump import debug_dump
|
||||
from .docs import docs_command
|
||||
@@ -24,7 +23,6 @@ from .export import export
|
||||
from .exportdb import exportdb
|
||||
from .grep import grep
|
||||
from .help import help
|
||||
from .import_cli import import_cli
|
||||
from .info import info
|
||||
from .install_uninstall_run import install, run, uninstall
|
||||
from .keywords import keywords
|
||||
@@ -32,19 +30,24 @@ from .labels import labels
|
||||
from .list import list_libraries
|
||||
from .orphans import orphans
|
||||
from .persons import persons
|
||||
from .photo_inspect import photo_inspect
|
||||
from .places import places
|
||||
from .query import query
|
||||
from .repl import repl
|
||||
from .show_command import show
|
||||
from .snap_diff import diff, snap
|
||||
from .sync import sync
|
||||
from .theme import theme
|
||||
from .timewarp import timewarp
|
||||
from .tutorial import tutorial
|
||||
from .uuid import uuid
|
||||
from .version import version
|
||||
|
||||
if is_macos:
|
||||
from .add_locations import add_locations
|
||||
from .batch_edit import batch_edit
|
||||
from .import_cli import import_cli
|
||||
from .photo_inspect import photo_inspect
|
||||
from .show_command import show
|
||||
from .sync import sync
|
||||
from .timewarp import timewarp
|
||||
from .uuid import uuid
|
||||
|
||||
|
||||
# Click CLI object & context settings
|
||||
class CLI_Obj:
|
||||
@@ -59,8 +62,6 @@ CTX_SETTINGS = dict(help_option_names=["-h", "--help"])
|
||||
|
||||
@click.group(context_settings=CTX_SETTINGS)
|
||||
@VERSION_OPTION
|
||||
@DB_OPTION
|
||||
@JSON_OPTION
|
||||
@DEBUG_OPTIONS
|
||||
@click.option(
|
||||
"--profile", is_flag=True, hidden=OSXPHOTOS_HIDDEN, help="Enable profiling"
|
||||
@@ -80,12 +81,12 @@ CTX_SETTINGS = dict(help_option_names=["-h", "--help"])
|
||||
"Default = 'cumulative'.",
|
||||
)
|
||||
@click.pass_context
|
||||
def cli_main(ctx, db, json_, profile, profile_sort, **kwargs):
|
||||
def cli_main(ctx, profile, profile_sort, **kwargs):
|
||||
"""osxphotos: the multi-tool for your Photos library"""
|
||||
# Note: kwargs is used to catch any debug options passed in
|
||||
# the debug options are handled in cli/__init__.py
|
||||
# before this function is called
|
||||
ctx.obj = CLI_Obj(db=db, json=json_, group=cli_main)
|
||||
ctx.obj = CLI_Obj(group=cli_main)
|
||||
if profile:
|
||||
click.echo("Profiling...")
|
||||
profile_sort = profile_sort or ["cumulative"]
|
||||
@@ -106,11 +107,9 @@ def cli_main(ctx, db, json_, profile, profile_sort, **kwargs):
|
||||
|
||||
|
||||
# install CLI commands
|
||||
for command in [
|
||||
commands = [
|
||||
about,
|
||||
add_locations,
|
||||
albums,
|
||||
batch_edit,
|
||||
debug_dump,
|
||||
diff,
|
||||
docs_command,
|
||||
@@ -120,7 +119,6 @@ for command in [
|
||||
exportdb,
|
||||
grep,
|
||||
help,
|
||||
import_cli,
|
||||
info,
|
||||
install,
|
||||
keywords,
|
||||
@@ -128,19 +126,28 @@ for command in [
|
||||
list_libraries,
|
||||
orphans,
|
||||
persons,
|
||||
photo_inspect,
|
||||
places,
|
||||
query,
|
||||
repl,
|
||||
run,
|
||||
show,
|
||||
snap,
|
||||
sync,
|
||||
theme,
|
||||
timewarp,
|
||||
tutorial,
|
||||
uninstall,
|
||||
uuid,
|
||||
version,
|
||||
]:
|
||||
]
|
||||
|
||||
if is_macos:
|
||||
commands += [
|
||||
add_locations,
|
||||
batch_edit,
|
||||
import_cli,
|
||||
photo_inspect,
|
||||
show,
|
||||
sync,
|
||||
timewarp,
|
||||
uuid,
|
||||
]
|
||||
|
||||
for command in commands:
|
||||
cli_main.add_command(command)
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
"""Common options & parameters for osxphotos CLI commands"""
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import functools
|
||||
from textwrap import dedent
|
||||
from typing import Any, Callable
|
||||
|
||||
import click
|
||||
|
||||
from ..platform import is_macos
|
||||
from .common import OSXPHOTOS_HIDDEN, print_version
|
||||
from .param_types import *
|
||||
|
||||
@@ -25,6 +29,49 @@ __all__ = [
|
||||
]
|
||||
|
||||
|
||||
def validate_selected(ctx, param, value):
|
||||
""" "Validate photos are actually selected when --selected is used"""
|
||||
|
||||
if not value:
|
||||
# --selected not used, just return
|
||||
return value
|
||||
|
||||
# imports here to avoid conflict with linux port
|
||||
# TODO: fix this once linux port is complete
|
||||
import photoscript
|
||||
from applescript import ScriptError
|
||||
|
||||
selection = None
|
||||
with contextlib.suppress(ScriptError):
|
||||
# ScriptError raised if selection made in edit mode or Smart Albums (on older versions of Photos)
|
||||
selection = photoscript.PhotosLibrary().selection
|
||||
|
||||
if not selection:
|
||||
click.echo(
|
||||
dedent(
|
||||
"""
|
||||
--selected option used but no photos selected in Photos.
|
||||
|
||||
To select photos in Photos use one of the following methods:
|
||||
|
||||
- Select a single photo: Click the photo, or press the arrow keys to quickly navigate to and select the photo.
|
||||
|
||||
- Select a group of adjacent photos in a day: Click the first photo, then hold down the Shift key while you click the last photo.
|
||||
You can also hold down Shift and press the arrow keys, or simply drag to enclose the photos within the selection rectangle.
|
||||
|
||||
- Select photos in a day that are not adjacent to each other: Hold down the Command key as you click each photo.
|
||||
|
||||
- Deselect specific photos: Hold down the Command key and click the photos you want to deselect.
|
||||
|
||||
- Deselect all photos: Click an empty space in the window (not a photo).
|
||||
"""
|
||||
),
|
||||
err=True,
|
||||
)
|
||||
ctx.exit(1)
|
||||
return value
|
||||
|
||||
|
||||
def _param_memo(f: Callable[..., Any], param: click.Parameter) -> None:
|
||||
"""Add param to the list of params for a click.Command
|
||||
This is directly from the click source code and
|
||||
@@ -544,6 +591,26 @@ _QUERY_PARAMETERS_DICT = {
|
||||
is_flag=True,
|
||||
help="Search for photos that are not in iCloud (have not been synched)",
|
||||
),
|
||||
"--syndicated": click.Option(
|
||||
["--syndicated"],
|
||||
is_flag=True,
|
||||
help="Search for photos that have been shared via syndication ('Shared with You' album via Messages, etc.)",
|
||||
),
|
||||
"--not-syndicated": click.Option(
|
||||
["--not-syndicated"],
|
||||
is_flag=True,
|
||||
help="Search for photos that have not been shared via syndication ('Shared with You' album via Messages, etc.)",
|
||||
),
|
||||
"--saved-to-library": click.Option(
|
||||
["--saved-to-library"],
|
||||
is_flag=True,
|
||||
help="Search for syndicated photos that have saved to the library",
|
||||
),
|
||||
"--not-saved-to-library": click.Option(
|
||||
["--not-saved-to-library"],
|
||||
is_flag=True,
|
||||
help="Search for syndicated photos that have not saved to the library",
|
||||
),
|
||||
"--regex": click.Option(
|
||||
["--regex"],
|
||||
metavar="REGEX TEMPLATE",
|
||||
@@ -557,6 +624,7 @@ _QUERY_PARAMETERS_DICT = {
|
||||
["--selected"],
|
||||
is_flag=True,
|
||||
help="Filter for photos that are currently selected in Photos.",
|
||||
callback=validate_selected,
|
||||
),
|
||||
"--exif": click.Option(
|
||||
["--exif"],
|
||||
@@ -597,6 +665,9 @@ _QUERY_PARAMETERS_DICT = {
|
||||
),
|
||||
}
|
||||
|
||||
if not is_macos:
|
||||
del _QUERY_PARAMETERS_DICT["--selected"]
|
||||
|
||||
|
||||
def QUERY_OPTIONS(
|
||||
wrapped=None, *, exclude: list[str] | None = None
|
||||
|
||||
@@ -119,7 +119,9 @@ def rich_echo(
|
||||
# if not outputting to terminal, use a huge width to avoid wrapping
|
||||
# otherwise tests fail
|
||||
width = 10_000
|
||||
console = get_rich_console() or Console(theme=theme or get_rich_theme(), width=width)
|
||||
console = get_rich_console() or Console(
|
||||
theme=theme or get_rich_theme(), width=width
|
||||
)
|
||||
if markdown:
|
||||
message = Markdown(message)
|
||||
# Markdown always adds a new line so disable unless explicitly specified
|
||||
|
||||
@@ -15,7 +15,8 @@ from xdg import xdg_config_home, xdg_data_home
|
||||
import osxphotos
|
||||
from osxphotos._constants import APP_NAME
|
||||
from osxphotos._version import __version__
|
||||
from osxphotos.utils import get_latest_version, get_macos_version
|
||||
from osxphotos.platform import get_macos_version
|
||||
from osxphotos.utils import get_latest_version
|
||||
|
||||
# used to show/hide hidden commands
|
||||
OSXPHOTOS_HIDDEN = not bool(os.getenv("OSXPHOTOS_SHOW_HIDDEN", default=False))
|
||||
|
||||
@@ -1,19 +1,30 @@
|
||||
"""Detect dark mode on MacOS >= 10.14"""
|
||||
"""Detect dark mode on MacOS >= 10.14 or fake it elsewhere"""
|
||||
|
||||
import objc
|
||||
import Foundation
|
||||
from osxphotos.platform import is_macos
|
||||
|
||||
if is_macos:
|
||||
import Foundation
|
||||
import objc
|
||||
|
||||
def theme():
|
||||
with objc.autorelease_pool():
|
||||
user_defaults = Foundation.NSUserDefaults.standardUserDefaults()
|
||||
system_theme = user_defaults.stringForKey_("AppleInterfaceStyle")
|
||||
return "dark" if system_theme == "Dark" else "light"
|
||||
def theme():
|
||||
with objc.autorelease_pool():
|
||||
user_defaults = Foundation.NSUserDefaults.standardUserDefaults()
|
||||
system_theme = user_defaults.stringForKey_("AppleInterfaceStyle")
|
||||
return "dark" if system_theme == "Dark" else "light"
|
||||
|
||||
def is_dark_mode():
|
||||
return theme() == "dark"
|
||||
|
||||
def is_dark_mode():
|
||||
return theme() == "dark"
|
||||
def is_light_mode():
|
||||
return theme() == "light"
|
||||
|
||||
else:
|
||||
|
||||
def is_light_mode():
|
||||
return theme() == "light"
|
||||
def theme():
|
||||
return "light"
|
||||
|
||||
def is_dark_mode():
|
||||
return theme() == "dark"
|
||||
|
||||
def is_light_mode():
|
||||
return theme() == "light"
|
||||
|
||||
@@ -57,8 +57,8 @@ def dump(
|
||||
print_template,
|
||||
):
|
||||
"""Print list of all photos & associated info from the Photos library.
|
||||
|
||||
NOTE: dump is DEPRECATED and will be removed in a future release.
|
||||
|
||||
NOTE: dump is DEPRECATED and will be removed in a future release.
|
||||
Use `osxphotos query` instead.
|
||||
"""
|
||||
|
||||
|
||||
@@ -12,13 +12,6 @@ import time
|
||||
from typing import Iterable, List, Optional, Tuple
|
||||
|
||||
import click
|
||||
from osxmetadata import (
|
||||
MDITEM_ATTRIBUTE_DATA,
|
||||
MDITEM_ATTRIBUTE_SHORT_NAMES,
|
||||
OSXMetaData,
|
||||
Tag,
|
||||
)
|
||||
from osxmetadata.constants import _TAGS_NAMES
|
||||
|
||||
import osxphotos
|
||||
from osxphotos._constants import (
|
||||
@@ -47,25 +40,31 @@ from osxphotos.datetime_formatter import DateTimeFormatter
|
||||
from osxphotos.debug import is_debug
|
||||
from osxphotos.exiftool import get_exiftool_path
|
||||
from osxphotos.export_db import ExportDB, ExportDBInMemory
|
||||
from osxphotos.fileutil import FileUtil, FileUtilNoOp, FileUtilShUtil
|
||||
from osxphotos.fileutil import FileUtilMacOS, FileUtilNoOp, FileUtilShUtil
|
||||
from osxphotos.path_utils import is_valid_filepath, sanitize_filename, sanitize_filepath
|
||||
from osxphotos.photoexporter import ExportOptions, ExportResults, PhotoExporter
|
||||
from osxphotos.photoinfo import PhotoInfoNone
|
||||
from osxphotos.photokit import (
|
||||
check_photokit_authorization,
|
||||
request_photokit_authorization,
|
||||
)
|
||||
from osxphotos.photosalbum import PhotosAlbum
|
||||
from osxphotos.phototemplate import PhotoTemplate, RenderOptions
|
||||
from osxphotos.platform import get_macos_version, is_macos
|
||||
from osxphotos.queryoptions import load_uuid_from_file, query_options_from_kwargs
|
||||
from osxphotos.unicode import normalize_fs_path
|
||||
from osxphotos.uti import get_preferred_uti_extension
|
||||
from osxphotos.utils import (
|
||||
format_sec_to_hhmmss,
|
||||
get_macos_version,
|
||||
normalize_fs_path,
|
||||
pluralize,
|
||||
under_test,
|
||||
)
|
||||
from osxphotos.utils import format_sec_to_hhmmss, pluralize, under_test
|
||||
|
||||
if is_macos:
|
||||
from osxmetadata import (
|
||||
MDITEM_ATTRIBUTE_DATA,
|
||||
MDITEM_ATTRIBUTE_SHORT_NAMES,
|
||||
OSXMetaData,
|
||||
Tag,
|
||||
)
|
||||
from osxmetadata.constants import _TAGS_NAMES
|
||||
|
||||
from osxphotos.photokit import (
|
||||
check_photokit_authorization,
|
||||
request_photokit_authorization,
|
||||
)
|
||||
from osxphotos.photosalbum import PhotosAlbum
|
||||
|
||||
from .cli_commands import logger
|
||||
from .cli_params import (
|
||||
@@ -298,6 +297,14 @@ from .verbose import get_verbose_console, verbose_print
|
||||
"Note: --download-missing does not currently export all burst images; "
|
||||
"only the primary photo will be exported--associated burst images will be skipped.",
|
||||
)
|
||||
@click.option(
|
||||
"--export-aae",
|
||||
is_flag=True,
|
||||
help="Also export an adjustments file detailing edits made to the original. "
|
||||
"The resulting file is named photoname.AAE. "
|
||||
"Note that to import these files back to Photos succesfully, you also need to "
|
||||
"export the edited photo and match the filename format Photos.app expects: "
|
||||
"--filename 'IMG_{edited_version?E,}{id:04d}' --edited-suffix ''")
|
||||
@click.option(
|
||||
"--sidecar",
|
||||
default=None,
|
||||
@@ -851,9 +858,9 @@ def export(
|
||||
retry,
|
||||
save_config,
|
||||
screenshot,
|
||||
selected,
|
||||
selfie,
|
||||
shared,
|
||||
export_aae,
|
||||
sidecar,
|
||||
sidecar_drop_ext,
|
||||
skip_bursts,
|
||||
@@ -883,6 +890,11 @@ def export(
|
||||
verbose_flag,
|
||||
xattr_template,
|
||||
year,
|
||||
syndicated,
|
||||
not_syndicated,
|
||||
saved_to_library,
|
||||
not_saved_to_library,
|
||||
selected=False, # Isn't provided on unsupported platforms
|
||||
# debug, # debug, watch, breakpoint handled in cli/__init__.py
|
||||
# watch,
|
||||
# breakpoint,
|
||||
@@ -911,7 +923,8 @@ def export(
|
||||
|
||||
# capture locals for use with ConfigOptions before changing any of them
|
||||
locals_ = locals()
|
||||
set_crash_data("locals", locals_)
|
||||
crash_data = locals_.copy()
|
||||
set_crash_data("locals", crash_data)
|
||||
|
||||
# config expects --verbose to be named "verbose" not "verbose_flag"
|
||||
locals_["verbose"] = verbose_flag
|
||||
@@ -1072,6 +1085,7 @@ def export(
|
||||
selected = cfg.selected
|
||||
selfie = cfg.selfie
|
||||
shared = cfg.shared
|
||||
export_aae = cfg.export_aae
|
||||
sidecar = cfg.sidecar
|
||||
sidecar_drop_ext = cfg.sidecar_drop_ext
|
||||
skip_bursts = cfg.skip_bursts
|
||||
@@ -1102,6 +1116,11 @@ def export(
|
||||
verbose_flag = cfg.verbose
|
||||
xattr_template = cfg.xattr_template
|
||||
year = cfg.year
|
||||
syndicated = cfg.syndicated
|
||||
not_syndicated = cfg.not_syndicated
|
||||
saved_to_library = cfg.saved_to_library
|
||||
not_saved_to_library = cfg.not_saved_to_library
|
||||
|
||||
# config file might have changed verbose
|
||||
verbose = verbose_print(verbose=verbose_flag, timestamp=timestamp, theme=theme)
|
||||
verbose(f"Loaded options from file [filepath]{load_config}")
|
||||
@@ -1110,7 +1129,10 @@ def export(
|
||||
|
||||
verbose(f"osxphotos version: {__version__}")
|
||||
verbose(f"Python version: {sys.version}")
|
||||
verbose(f"Platform: {platform.platform()}, {'.'.join(get_macos_version())}")
|
||||
if is_macos:
|
||||
verbose(f"Platform: {platform.platform()}, {'.'.join(get_macos_version())}")
|
||||
else:
|
||||
verbose(f"Platform: {platform.platform()}")
|
||||
verbose(f"Verbose level: {verbose_flag}")
|
||||
|
||||
# validate options
|
||||
@@ -1147,6 +1169,8 @@ def export(
|
||||
("slow_mo", "not_slow_mo"),
|
||||
("time_lapse", "not_time_lapse"),
|
||||
("title", "no_title"),
|
||||
("syndicated", "not_syndicated"),
|
||||
("saved_to_library", "not_saved_to_library"),
|
||||
]
|
||||
dependent_options = [
|
||||
("append", ("report")),
|
||||
@@ -1324,7 +1348,7 @@ def export(
|
||||
if ramdb
|
||||
else ExportDB(dbfile=export_db_path, export_dir=dest)
|
||||
)
|
||||
fileutil = FileUtilShUtil if alt_copy else FileUtil
|
||||
fileutil = FileUtilShUtil if alt_copy or not is_macos else FileUtilMacOS
|
||||
|
||||
if verbose:
|
||||
if export_db.was_created:
|
||||
@@ -1427,21 +1451,22 @@ def export(
|
||||
photo_num = 0
|
||||
num_exported = 0
|
||||
limit_str = f" (limit = [num]{limit}[/num])" if limit else ""
|
||||
# hack to avoid passing all the options to export_photo
|
||||
kwargs = {
|
||||
k: v
|
||||
for k, v in locals().items()
|
||||
if k in inspect.getfullargspec(export_photo).args
|
||||
}
|
||||
kwargs["export_dir"] = dest
|
||||
kwargs["export_preview"] = preview
|
||||
with rich_progress(console=get_verbose_console(), mock=no_progress) as progress:
|
||||
task = progress.add_task(
|
||||
f"Exporting [num]{num_photos}[/] photos{limit_str}", total=num_photos
|
||||
)
|
||||
for p in photos:
|
||||
photo_num += 1
|
||||
# hack to avoid passing all the options to export_photo
|
||||
kwargs = {
|
||||
k: v
|
||||
for k, v in locals().items()
|
||||
if k in inspect.getfullargspec(export_photo).args
|
||||
}
|
||||
kwargs["photo"] = p
|
||||
kwargs["export_dir"] = dest
|
||||
kwargs["export_preview"] = preview
|
||||
kwargs["photo_num"] = photo_num
|
||||
export_results = export_photo(**kwargs)
|
||||
if post_function:
|
||||
for function in post_function:
|
||||
@@ -1630,6 +1655,7 @@ def export(
|
||||
+ results.exif_updated
|
||||
+ results.touched
|
||||
+ results.converted_to_jpeg
|
||||
+ results.aae_written
|
||||
+ results.sidecar_json_written
|
||||
+ results.sidecar_json_skipped
|
||||
+ results.sidecar_exiftool_written
|
||||
@@ -1687,6 +1713,7 @@ def export_photo(
|
||||
dest=None,
|
||||
verbose=None,
|
||||
export_by_date=None,
|
||||
export_aae=None,
|
||||
sidecar=None,
|
||||
sidecar_drop_ext=False,
|
||||
update=None,
|
||||
@@ -1711,7 +1738,7 @@ def export_photo(
|
||||
keyword_template=None,
|
||||
description_template=None,
|
||||
export_db=None,
|
||||
fileutil=FileUtil,
|
||||
fileutil=FileUtilShUtil,
|
||||
dry_run=None,
|
||||
touch_file=None,
|
||||
edited_suffix="_edited",
|
||||
@@ -1775,6 +1802,7 @@ def export_photo(
|
||||
preview_suffix: str, template to use as suffix for preview images
|
||||
replace_keywords: if True, --keyword-template replaces keywords instead of adding keywords
|
||||
retry: retry up to retry # of times if there's an error
|
||||
export_aae: bool; if True, will also save adjustments
|
||||
sidecar_drop_ext: bool; if True, drops photo extension from sidecar name
|
||||
sidecar: list zero, 1 or 2 of ["json","xmp"] of sidecar variety to export
|
||||
skip_original_if_edited: bool; if True does not export original if photo has been edited
|
||||
@@ -1941,6 +1969,7 @@ def export_photo(
|
||||
preview_suffix=rendered_preview_suffix,
|
||||
replace_keywords=replace_keywords,
|
||||
retry=retry,
|
||||
export_aae=export_aae,
|
||||
sidecar_drop_ext=sidecar_drop_ext,
|
||||
sidecar_flags=sidecar_flags,
|
||||
touch_file=touch_file,
|
||||
@@ -2057,6 +2086,7 @@ def export_photo(
|
||||
preview_suffix=rendered_preview_suffix,
|
||||
replace_keywords=replace_keywords,
|
||||
retry=retry,
|
||||
export_aae=export_aae,
|
||||
sidecar_drop_ext=sidecar_drop_ext,
|
||||
sidecar_flags=sidecar_flags if not export_original else 0,
|
||||
touch_file=touch_file,
|
||||
@@ -2144,6 +2174,7 @@ def export_photo_to_directory(
|
||||
preview_suffix,
|
||||
replace_keywords,
|
||||
retry,
|
||||
export_aae,
|
||||
sidecar_drop_ext,
|
||||
sidecar_flags,
|
||||
touch_file,
|
||||
@@ -2208,6 +2239,7 @@ def export_photo_to_directory(
|
||||
render_options=render_options,
|
||||
replace_keywords=replace_keywords,
|
||||
rich=True,
|
||||
export_aae=export_aae,
|
||||
sidecar=sidecar_flags,
|
||||
sidecar_drop_ext=sidecar_drop_ext,
|
||||
tmpdir=tmpdir,
|
||||
@@ -2253,7 +2285,7 @@ def export_photo_to_directory(
|
||||
err=True,
|
||||
)
|
||||
if tries > retry:
|
||||
results.error.append((str(pathlib.Path(dest) / filename), e))
|
||||
results.error.append((str(pathlib.Path(dest) / filename), str(e)))
|
||||
break
|
||||
else:
|
||||
rich_echo(
|
||||
|
||||
@@ -19,14 +19,14 @@ from osxphotos.export_db_utils import (
|
||||
export_db_backup,
|
||||
export_db_check_signatures,
|
||||
export_db_get_errors,
|
||||
export_db_get_last_library,
|
||||
export_db_get_last_run,
|
||||
export_db_get_version,
|
||||
export_db_migrate_photos_library,
|
||||
export_db_save_config_to_file,
|
||||
export_db_touch_files,
|
||||
export_db_update_signatures,
|
||||
export_db_vacuum,
|
||||
export_db_migrate_photos_library,
|
||||
export_db_get_last_library,
|
||||
)
|
||||
from osxphotos.utils import pluralize
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import re
|
||||
import typing as t
|
||||
|
||||
import click
|
||||
from osxmetadata import MDITEM_ATTRIBUTE_DATA, MDITEM_ATTRIBUTE_SHORT_NAMES
|
||||
from rich.console import Console
|
||||
from rich.markdown import Markdown
|
||||
|
||||
@@ -21,6 +20,10 @@ from osxphotos.phototemplate import (
|
||||
TEMPLATE_SUBSTITUTIONS_PATHLIB,
|
||||
get_template_help,
|
||||
)
|
||||
from osxphotos.platform import is_macos
|
||||
|
||||
if is_macos:
|
||||
from osxmetadata import MDITEM_ATTRIBUTE_DATA, MDITEM_ATTRIBUTE_SHORT_NAMES
|
||||
|
||||
from .click_rich_echo import rich_echo_via_pager
|
||||
from .color_themes import get_theme
|
||||
@@ -249,68 +252,73 @@ class ExportCommand(click.Command):
|
||||
+ f"rebuilding the '{OSXPHOTOS_EXPORT_DB}' database."
|
||||
)
|
||||
formatter.write("\n")
|
||||
formatter.write(
|
||||
rich_text("## Extended Attributes", width=formatter.width, markdown=True)
|
||||
)
|
||||
formatter.write("\n")
|
||||
formatter.write_text(
|
||||
"""
|
||||
Some options (currently '--finder-tag-template', '--finder-tag-keywords', '-xattr-template') write
|
||||
additional metadata accessible by Spotlight to facilitate searching.
|
||||
For example, --finder-tag-keyword writes all keywords (including any specified by '--keyword-template'
|
||||
or other options) to Finder tags that are searchable in Spotlight using the syntax: 'tag:tagname'.
|
||||
For example, if you have images with keyword "Travel" then using '--finder-tag-keywords' you could quickly
|
||||
find those images in the Finder by typing 'tag:Travel' in the Spotlight search bar.
|
||||
Finder tags are written to the 'com.apple.metadata:_kMDItemUserTags' extended attribute.
|
||||
Unlike EXIF metadata, extended attributes do not modify the actual file;
|
||||
the metadata is written to extended attributes associated with the file and the Spotlight metadata database.
|
||||
Most cloud storage services do not synch extended attributes.
|
||||
Dropbox does sync them and any changes to a file's extended attributes
|
||||
will cause Dropbox to re-sync the files.
|
||||
|
||||
The following attributes may be used with '--xattr-template':
|
||||
|
||||
"""
|
||||
)
|
||||
|
||||
# build help text from all the attribute names
|
||||
# passed to click.HelpFormatter.write_dl for formatting
|
||||
attr_tuples = [
|
||||
(
|
||||
rich_text("[bold]Attribute[/bold]", width=formatter.width),
|
||||
rich_text("[bold]Description[/bold]", width=formatter.width),
|
||||
if is_macos:
|
||||
formatter.write(
|
||||
rich_text(
|
||||
"## Extended Attributes", width=formatter.width, markdown=True
|
||||
)
|
||||
)
|
||||
]
|
||||
for attr_key in sorted(EXTENDED_ATTRIBUTE_NAMES):
|
||||
# get short and long name
|
||||
attr = MDITEM_ATTRIBUTE_SHORT_NAMES[attr_key]
|
||||
short_name = MDITEM_ATTRIBUTE_DATA[attr]["short_name"]
|
||||
long_name = MDITEM_ATTRIBUTE_DATA[attr]["name"]
|
||||
constant = MDITEM_ATTRIBUTE_DATA[attr]["xattr_constant"]
|
||||
formatter.write("\n")
|
||||
formatter.write_text(
|
||||
"""
|
||||
Some options (currently '--finder-tag-template', '--finder-tag-keywords', '-xattr-template') write
|
||||
additional metadata accessible by Spotlight to facilitate searching.
|
||||
For example, --finder-tag-keyword writes all keywords (including any specified by '--keyword-template'
|
||||
or other options) to Finder tags that are searchable in Spotlight using the syntax: 'tag:tagname'.
|
||||
For example, if you have images with keyword "Travel" then using '--finder-tag-keywords' you could quickly
|
||||
find those images in the Finder by typing 'tag:Travel' in the Spotlight search bar.
|
||||
Finder tags are written to the 'com.apple.metadata:_kMDItemUserTags' extended attribute.
|
||||
Unlike EXIF metadata, extended attributes do not modify the actual file;
|
||||
the metadata is written to extended attributes associated with the file and the Spotlight metadata database.
|
||||
Most cloud storage services do not synch extended attributes.
|
||||
Dropbox does sync them and any changes to a file's extended attributes
|
||||
will cause Dropbox to re-sync the files.
|
||||
|
||||
# get help text
|
||||
description = MDITEM_ATTRIBUTE_DATA[attr]["description"]
|
||||
type_ = MDITEM_ATTRIBUTE_DATA[attr]["help_type"]
|
||||
attr_help = f"{long_name}; {constant}; {description}; {type_}"
|
||||
The following attributes may be used with '--xattr-template':
|
||||
|
||||
# add to list
|
||||
attr_tuples.append((short_name, attr_help))
|
||||
"""
|
||||
)
|
||||
|
||||
formatter.write_dl(attr_tuples)
|
||||
formatter.write("\n")
|
||||
formatter.write_text(
|
||||
"For additional information on extended attributes see: https://developer.apple.com/documentation/coreservices/file_metadata/mditem/common_metadata_attribute_keys"
|
||||
)
|
||||
formatter.write("\n")
|
||||
formatter.write(
|
||||
rich_text("## Templating System", width=formatter.width, markdown=True)
|
||||
)
|
||||
formatter.write("\n")
|
||||
help_text += formatter.getvalue()
|
||||
help_text += template_help(width=formatter.width)
|
||||
formatter = click.HelpFormatter(width=HELP_WIDTH)
|
||||
# build help text from all the attribute names
|
||||
# passed to click.HelpFormatter.write_dl for formatting
|
||||
attr_tuples = [
|
||||
(
|
||||
rich_text("[bold]Attribute[/bold]", width=formatter.width),
|
||||
rich_text("[bold]Description[/bold]", width=formatter.width),
|
||||
)
|
||||
]
|
||||
for attr_key in sorted(EXTENDED_ATTRIBUTE_NAMES):
|
||||
# get short and long name
|
||||
attr = MDITEM_ATTRIBUTE_SHORT_NAMES[attr_key]
|
||||
short_name = MDITEM_ATTRIBUTE_DATA[attr]["short_name"]
|
||||
long_name = MDITEM_ATTRIBUTE_DATA[attr]["name"]
|
||||
constant = MDITEM_ATTRIBUTE_DATA[attr]["xattr_constant"]
|
||||
|
||||
# get help text
|
||||
description = MDITEM_ATTRIBUTE_DATA[attr]["description"]
|
||||
type_ = MDITEM_ATTRIBUTE_DATA[attr]["help_type"]
|
||||
attr_help = f"{long_name}; {constant}; {description}; {type_}"
|
||||
|
||||
# add to list
|
||||
attr_tuples.append((short_name, attr_help))
|
||||
|
||||
formatter.write_dl(attr_tuples)
|
||||
formatter.write("\n")
|
||||
formatter.write_text(
|
||||
"For additional information on extended attributes see: https://developer.apple.com/documentation/coreservices/file_metadata/mditem/common_metadata_attribute_keys"
|
||||
)
|
||||
formatter.write("\n")
|
||||
formatter.write(
|
||||
rich_text("## Templating System", width=formatter.width, markdown=True)
|
||||
)
|
||||
formatter.write("\n")
|
||||
help_text += formatter.getvalue()
|
||||
help_text += template_help(width=formatter.width)
|
||||
formatter = click.HelpFormatter(width=HELP_WIDTH)
|
||||
|
||||
formatter.write("\n")
|
||||
|
||||
formatter.write("\n")
|
||||
formatter.write_text(
|
||||
"With the --directory and --filename options you may specify a template for the "
|
||||
+ "export directory or filename, respectively. "
|
||||
|
||||
@@ -20,12 +20,11 @@ from textwrap import dedent
|
||||
from typing import Callable, Dict, List, Optional, Tuple, Union
|
||||
|
||||
import click
|
||||
from photoscript import Photo, PhotosLibrary
|
||||
from rich.console import Console
|
||||
from rich.markdown import Markdown
|
||||
from strpdatetime import strpdatetime
|
||||
|
||||
from osxphotos._constants import _OSXPHOTOS_NONE_SENTINEL
|
||||
from osxphotos._constants import _OSXPHOTOS_NONE_SENTINEL, SQLITE_CHECK_SAME_THREAD
|
||||
from osxphotos._version import __version__
|
||||
from osxphotos.cli.cli_params import TIMESTAMP_OPTION, VERBOSE_OPTION
|
||||
from osxphotos.cli.common import get_data_dir
|
||||
@@ -42,9 +41,15 @@ from osxphotos.exiftool import ExifToolCaching, get_exiftool_path
|
||||
from osxphotos.photoinfo import PhotoInfoNone
|
||||
from osxphotos.photosalbum import PhotosAlbumPhotoScript
|
||||
from osxphotos.phototemplate import PhotoTemplate, RenderOptions
|
||||
from osxphotos.platform import assert_macos
|
||||
from osxphotos.sqlitekvstore import SQLiteKVStore
|
||||
from osxphotos.unicode import normalize_unicode
|
||||
from osxphotos.utils import pluralize
|
||||
|
||||
assert_macos()
|
||||
|
||||
from photoscript import Photo, PhotosLibrary
|
||||
|
||||
from .cli_params import THEME_OPTION
|
||||
from .click_rich_echo import rich_click_echo, rich_echo_error
|
||||
from .rich_progress import rich_progress
|
||||
@@ -77,7 +82,8 @@ def echo(message, emoji=True, **kwargs):
|
||||
class PhotoInfoFromFile:
|
||||
"""Mock PhotoInfo class for a file to be imported
|
||||
|
||||
Returns None for most attributes but allows some templates like exiftool and created to work correctly"""
|
||||
Returns None for most attributes but allows some templates like exiftool and created to work correctly
|
||||
"""
|
||||
|
||||
def __init__(self, filepath: Union[str, Path], exiftool: Optional[str] = None):
|
||||
self._path = str(filepath)
|
||||
@@ -353,11 +359,12 @@ def set_photo_metadata(
|
||||
merge_keywords: bool,
|
||||
) -> MetaData:
|
||||
"""Set metadata (title, description, keywords) for a Photo object"""
|
||||
photo.title = metadata.title
|
||||
photo.description = metadata.description
|
||||
photo.title = normalize_unicode(metadata.title)
|
||||
photo.description = normalize_unicode(metadata.description)
|
||||
keywords = metadata.keywords.copy()
|
||||
keywords =normalize_unicode(keywords)
|
||||
if merge_keywords:
|
||||
if old_keywords := photo.keywords:
|
||||
if old_keywords := normalize_unicode(photo.keywords):
|
||||
keywords.extend(old_keywords)
|
||||
keywords = list(set(keywords))
|
||||
photo.keywords = keywords
|
||||
@@ -416,7 +423,7 @@ def set_photo_title(
|
||||
verbose(
|
||||
f"Setting title of photo [filename]{filepath.name}[/] to '{title_text[0]}'"
|
||||
)
|
||||
photo.title = title_text[0]
|
||||
photo.title = normalize_unicode(title_text[0])
|
||||
return title_text[0]
|
||||
else:
|
||||
return ""
|
||||
@@ -444,7 +451,7 @@ def set_photo_description(
|
||||
verbose(
|
||||
f"Setting description of photo [filename]{filepath.name}[/] to '{description_text[0]}'"
|
||||
)
|
||||
photo.description = description_text[0]
|
||||
photo.description = normalize_unicode(description_text[0])
|
||||
return description_text[0]
|
||||
else:
|
||||
return ""
|
||||
@@ -465,8 +472,9 @@ def set_photo_keywords(
|
||||
kw = render_photo_template(filepath, relative_filepath, keyword, exiftool_path)
|
||||
keywords.extend(kw)
|
||||
if keywords:
|
||||
keywords = normalize_unicode(keywords)
|
||||
if merge:
|
||||
if old_keywords := photo.keywords:
|
||||
if old_keywords := normalize_unicode(photo.keywords):
|
||||
keywords.extend(old_keywords)
|
||||
keywords = list(set(keywords))
|
||||
verbose(f"Setting keywords of photo [filename]{filepath.name}[/] to {keywords}")
|
||||
@@ -745,7 +753,7 @@ def write_sqlite_report(
|
||||
|
||||
file_exists = os.path.isfile(report_file)
|
||||
|
||||
conn = sqlite3.connect(report_file)
|
||||
conn = sqlite3.connect(report_file, check_same_thread=SQLITE_CHECK_SAME_THREAD)
|
||||
c = conn.cursor()
|
||||
|
||||
if not append or not file_exists:
|
||||
@@ -1414,7 +1422,13 @@ def import_cli(
|
||||
verbose_flag,
|
||||
walk,
|
||||
):
|
||||
"""Import photos and videos into Photos."""
|
||||
"""Import photos and videos into Photos. Photos will be imported into the
|
||||
most recently opened Photos library.
|
||||
|
||||
Photos are imported one at a time thus the "Imports" album in Photos will show
|
||||
a new import group for each photo imported. Batch import into a single import
|
||||
group will be added in a future release.
|
||||
"""
|
||||
|
||||
verbose = verbose_print(verbose=verbose_flag, timestamp=timestamp, theme=theme)
|
||||
|
||||
|
||||
@@ -68,7 +68,6 @@ class PathOrStdin(click.Path):
|
||||
|
||||
|
||||
class DateTimeISO8601(click.ParamType):
|
||||
|
||||
name = "DATETIME"
|
||||
|
||||
def convert(self, value, param, ctx):
|
||||
@@ -82,7 +81,6 @@ class DateTimeISO8601(click.ParamType):
|
||||
|
||||
|
||||
class BitMathSize(click.ParamType):
|
||||
|
||||
name = "BITMATH"
|
||||
|
||||
def convert(self, value, param, ctx):
|
||||
@@ -102,7 +100,6 @@ class BitMathSize(click.ParamType):
|
||||
|
||||
|
||||
class TimeISO8601(click.ParamType):
|
||||
|
||||
name = "TIME"
|
||||
|
||||
def convert(self, value, param, ctx):
|
||||
@@ -141,7 +138,6 @@ class FunctionCall(click.ParamType):
|
||||
|
||||
|
||||
class ExportDBType(click.ParamType):
|
||||
|
||||
name = "EXPORTDB"
|
||||
|
||||
def convert(self, value, param, ctx):
|
||||
@@ -279,7 +275,6 @@ class StrpDateTimePattern(click.ParamType):
|
||||
|
||||
|
||||
class Latitude(click.ParamType):
|
||||
|
||||
name = "Latitude"
|
||||
|
||||
def convert(self, value, param, ctx):
|
||||
@@ -295,7 +290,6 @@ class Latitude(click.ParamType):
|
||||
|
||||
|
||||
class Longitude(click.ParamType):
|
||||
|
||||
name = "Longitude"
|
||||
|
||||
def convert(self, value, param, ctx):
|
||||
|
||||
@@ -13,8 +13,6 @@ from typing import Generator, List, Optional, Tuple
|
||||
|
||||
import bitmath
|
||||
import click
|
||||
from applescript import ScriptError
|
||||
from photoscript import PhotosLibrary
|
||||
from rich.console import Console
|
||||
from rich.layout import Layout
|
||||
from rich.live import Live
|
||||
@@ -22,10 +20,17 @@ from rich.panel import Panel
|
||||
|
||||
from osxphotos import PhotoInfo, PhotosDB
|
||||
from osxphotos._constants import _UNKNOWN_PERSON, search_category_factory
|
||||
from osxphotos.platform import assert_macos
|
||||
from osxphotos.rich_utils import add_rich_markup_tag
|
||||
from osxphotos.text_detection import detect_text as detect_text_in_photo
|
||||
from osxphotos.utils import dd_to_dms_str
|
||||
|
||||
assert_macos()
|
||||
|
||||
from applescript import ScriptError
|
||||
from photoscript import PhotosLibrary
|
||||
|
||||
from osxphotos.text_detection import detect_text as detect_text_in_photo
|
||||
|
||||
from .cli_params import DB_OPTION, THEME_OPTION
|
||||
from .color_themes import get_theme
|
||||
from .common import get_photos_db
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
"""query command for osxphotos CLI"""
|
||||
|
||||
import sys
|
||||
|
||||
import click
|
||||
|
||||
import osxphotos
|
||||
@@ -9,10 +11,13 @@ from osxphotos.cli.click_rich_echo import (
|
||||
set_rich_theme,
|
||||
)
|
||||
from osxphotos.debug import set_debug
|
||||
from osxphotos.photosalbum import PhotosAlbum
|
||||
from osxphotos.phototemplate import RenderOptions
|
||||
from osxphotos.platform import assert_macos, is_macos
|
||||
from osxphotos.queryoptions import query_options_from_kwargs
|
||||
|
||||
if is_macos:
|
||||
from osxphotos.photosalbum import PhotosAlbum
|
||||
|
||||
from .cli_params import (
|
||||
DB_ARGUMENT,
|
||||
DB_OPTION,
|
||||
@@ -20,6 +25,7 @@ from .cli_params import (
|
||||
FIELD_OPTION,
|
||||
JSON_OPTION,
|
||||
QUERY_OPTIONS,
|
||||
make_click_option_decorator,
|
||||
)
|
||||
from .color_themes import get_default_theme
|
||||
from .common import CLI_COLOR_ERROR, CLI_COLOR_WARNING, OSXPHOTOS_HIDDEN, get_photos_db
|
||||
@@ -27,20 +33,29 @@ from .list import _list_libraries
|
||||
from .print_photo_info import print_photo_fields, print_photo_info
|
||||
from .verbose import get_verbose_console
|
||||
|
||||
MACOS_OPTIONS = make_click_option_decorator(
|
||||
*[
|
||||
click.Option(
|
||||
["--add-to-album"],
|
||||
metavar="ALBUM",
|
||||
help="Add all photos from query to album ALBUM in Photos. Album ALBUM will be created "
|
||||
"if it doesn't exist. All photos in the query results will be added to this album. "
|
||||
"This only works if the Photos library being queried is the last-opened (default) library in Photos. "
|
||||
"This feature is currently experimental. I don't know how well it will work on large query sets.",
|
||||
),
|
||||
]
|
||||
if is_macos
|
||||
else []
|
||||
)
|
||||
|
||||
|
||||
@click.command()
|
||||
@DB_OPTION
|
||||
@JSON_OPTION
|
||||
@click.option("--count", is_flag=True, help="Print count of photos matching query and exit.")
|
||||
@QUERY_OPTIONS
|
||||
@DELETED_OPTIONS
|
||||
@click.option(
|
||||
"--add-to-album",
|
||||
metavar="ALBUM",
|
||||
help="Add all photos from query to album ALBUM in Photos. Album ALBUM will be created "
|
||||
"if it doesn't exist. All photos in the query results will be added to this album. "
|
||||
"This only works if the Photos library being queried is the last-opened (default) library in Photos. "
|
||||
"This feature is currently experimental. I don't know how well it will work on large query sets.",
|
||||
)
|
||||
@MACOS_OPTIONS
|
||||
@click.option(
|
||||
"--quiet",
|
||||
is_flag=True,
|
||||
@@ -68,10 +83,11 @@ def query(
|
||||
db,
|
||||
field,
|
||||
json_,
|
||||
count,
|
||||
print_template,
|
||||
quiet,
|
||||
add_to_album,
|
||||
photos_library,
|
||||
add_to_album=False,
|
||||
**kwargs,
|
||||
):
|
||||
"""Query the Photos database using 1 or more search options;
|
||||
@@ -123,7 +139,13 @@ def query(
|
||||
# below needed for to make CliRunner work for testing
|
||||
cli_json = cli_obj.json if cli_obj is not None else None
|
||||
|
||||
if count:
|
||||
click.echo(len(photos))
|
||||
return
|
||||
|
||||
if add_to_album and photos:
|
||||
assert_macos()
|
||||
|
||||
album_query = PhotosAlbum(add_to_album, verbose=None)
|
||||
photo_len = len(photos)
|
||||
photo_word = "photos" if photo_len > 1 else "photo"
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
"""repl command for osxphotos CLI"""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import pathlib
|
||||
import re
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
from functools import partial
|
||||
from typing import List
|
||||
|
||||
import click
|
||||
import photoscript
|
||||
from rich import pretty, print
|
||||
|
||||
import osxphotos
|
||||
@@ -16,6 +20,7 @@ from osxphotos._constants import _PHOTOS_4_VERSION
|
||||
from osxphotos.cli.click_rich_echo import rich_echo_error as echo_error
|
||||
from osxphotos.photoinfo import PhotoInfo
|
||||
from osxphotos.photosdb import PhotosDB
|
||||
from osxphotos.platform import assert_macos, is_macos
|
||||
from osxphotos.pyrepl import embed_repl
|
||||
from osxphotos.queryoptions import (
|
||||
IncompatibleQueryOptions,
|
||||
@@ -23,6 +28,10 @@ from osxphotos.queryoptions import (
|
||||
query_options_from_kwargs,
|
||||
)
|
||||
|
||||
if is_macos:
|
||||
import photoscript
|
||||
from applescript import ScriptError
|
||||
|
||||
from .cli_params import DB_ARGUMENT, DB_OPTION, DELETED_OPTIONS, QUERY_OPTIONS
|
||||
from .common import get_photos_db
|
||||
|
||||
@@ -52,7 +61,9 @@ def repl(ctx, cli_obj, db, emacs, beta, **kwargs):
|
||||
import logging
|
||||
|
||||
from objexplore import explore
|
||||
from photoscript import Album, Photo, PhotosLibrary
|
||||
|
||||
if is_macos:
|
||||
from photoscript import Album, Photo, PhotosLibrary
|
||||
from rich import inspect as _inspect
|
||||
|
||||
from osxphotos import ExifTool, PhotoInfo, PhotosDB
|
||||
@@ -92,6 +103,7 @@ def repl(ctx, cli_obj, db, emacs, beta, **kwargs):
|
||||
get_photo = photosdb.get_photo
|
||||
show = _show_photo
|
||||
spotlight = _spotlight_photo
|
||||
find = partial(_find_in_library, photosdb)
|
||||
get_selected = _get_selected(photosdb)
|
||||
try:
|
||||
selected = get_selected()
|
||||
@@ -121,28 +133,31 @@ def repl(ctx, cli_obj, db, emacs, beta, **kwargs):
|
||||
)
|
||||
print(f"\nThe following functions may be helpful:")
|
||||
print(
|
||||
f"- get_photo(uuid): return a PhotoInfo object for photo with uuid; e.g. get_photo('B13F4485-94E0-41CD-AF71-913095D62E31')"
|
||||
"- get_photo(uuid): return a PhotoInfo object for photo with uuid; e.g. get_photo('B13F4485-94E0-41CD-AF71-913095D62E31')"
|
||||
)
|
||||
print(
|
||||
f"- get_selected(); return list of PhotoInfo objects for photos selected in Photos"
|
||||
"- get_selected(); return list of PhotoInfo objects for photos selected in Photos"
|
||||
)
|
||||
print(
|
||||
f"- show(photo): open a photo object in the default viewer; e.g. show(selected[0])"
|
||||
"- show(photo): open a photo object in the default viewer; e.g. show(selected[0])"
|
||||
)
|
||||
print(
|
||||
f"- show(path): open a file at path in the default viewer; e.g. show('/path/to/photo.jpg')"
|
||||
"- show(path): open a file at path in the default viewer; e.g. show('/path/to/photo.jpg')"
|
||||
)
|
||||
print(f"- spotlight(photo): open a photo and spotlight it in Photos")
|
||||
print("- spotlight(photo): open a photo and spotlight it in Photos")
|
||||
# print(
|
||||
# f"- help(object): print help text including list of methods for object; for example, help(PhotosDB)"
|
||||
# )
|
||||
print(
|
||||
f"- inspect(object): print information about an object; e.g. inspect(PhotoInfo)"
|
||||
"- inspect(object): print information about an object; e.g. inspect(PhotoInfo)"
|
||||
)
|
||||
print(
|
||||
f"- explore(object): interactively explore an object with objexplore; e.g. explore(PhotoInfo)"
|
||||
"- explore(object): interactively explore an object with objexplore; e.g. explore(PhotoInfo)"
|
||||
)
|
||||
print(f"- q, quit, quit(), exit, exit(): exit this interactive shell\n")
|
||||
print(
|
||||
"- find(text): search for files matching text in Photos library; e.g. find('B13F4485')"
|
||||
)
|
||||
print("- q, quit, quit(), exit, exit(): exit this interactive shell\n")
|
||||
|
||||
embed_repl(
|
||||
globals=globals(),
|
||||
@@ -191,15 +206,23 @@ def _get_selected(photosdb):
|
||||
"""get list of PhotoInfo objects for photos selected in Photos"""
|
||||
|
||||
def get_selected():
|
||||
selected = photoscript.PhotosLibrary().selection
|
||||
if not selected:
|
||||
return []
|
||||
return photosdb.photos(uuid=[p.uuid for p in selected])
|
||||
assert_macos()
|
||||
try:
|
||||
selected = photoscript.PhotosLibrary().selection
|
||||
except ScriptError as e:
|
||||
# some photos (e.g. shared items) can't be selected and raise ScriptError:
|
||||
# applescript.ScriptError: Photos got an error: Can’t get media item id "34C26DFA-0CEA-4DB7-8FDA-B87789B3209D/L0/001". (-1728) app='Photos' range=16820-16873
|
||||
# In this case, we can parse the UUID from the error (though this only works for a single selected item)
|
||||
if match := re.match(r".*Can’t get media item id \"(.*)\".*", str(e)):
|
||||
uuid = match[1].split("/")[0]
|
||||
return photosdb.photos(uuid=[uuid])
|
||||
return photosdb.photos(uuid=[p.uuid for p in selected]) if selected else []
|
||||
|
||||
return get_selected
|
||||
|
||||
|
||||
def _spotlight_photo(photo: PhotoInfo):
|
||||
assert_macos()
|
||||
photo_ = photoscript.Photo(photo.uuid)
|
||||
photo_.spotlight()
|
||||
|
||||
@@ -217,3 +240,20 @@ def _query_photos(photosdb: PhotosDB, query_options: QueryOptions) -> List:
|
||||
) from e
|
||||
|
||||
return photos
|
||||
|
||||
|
||||
def _find_in_library(photosdb: PhotosDB, search_str: str) -> list[str]:
|
||||
"""Find files in Photos library matching search_str using find command"""
|
||||
# this is a quick and dirty way to find files in the Photos library
|
||||
# e.g. those matching a UUID or a filename
|
||||
library_path = photosdb.library_path
|
||||
if not library_path:
|
||||
raise ValueError("Could not find Photos library")
|
||||
|
||||
search_str = shlex.quote(search_str)
|
||||
library_path = shlex.quote(library_path)
|
||||
cmd = f"find {library_path} | grep {search_str}"
|
||||
output = subprocess.check_output(cmd, shell=True, universal_newlines=True)
|
||||
|
||||
# Split the output into lines and return as a list
|
||||
return output.strip().split("\n")
|
||||
|
||||
@@ -12,6 +12,7 @@ from abc import ABC, abstractmethod
|
||||
from contextlib import suppress
|
||||
from typing import Dict, Union
|
||||
|
||||
from osxphotos._constants import SQLITE_CHECK_SAME_THREAD
|
||||
from osxphotos.export_db import OSXPHOTOS_ABOUT_STRING
|
||||
from osxphotos.photoexporter import ExportResults
|
||||
from osxphotos.sqlite_utils import sqlite_columns
|
||||
@@ -181,7 +182,9 @@ class ExportReportWriterSQLite(ReportWriterABC):
|
||||
with suppress(FileNotFoundError):
|
||||
os.unlink(self.output_file)
|
||||
|
||||
self._conn = sqlite3.connect(self.output_file)
|
||||
self._conn = sqlite3.connect(
|
||||
self.output_file, check_same_thread=SQLITE_CHECK_SAME_THREAD
|
||||
)
|
||||
self._create_tables()
|
||||
self.report_id = self._generate_report_id()
|
||||
|
||||
@@ -533,7 +536,9 @@ class SyncReportWriterSQLite(ReportWriterABC):
|
||||
with suppress(FileNotFoundError):
|
||||
os.unlink(self.output_file)
|
||||
|
||||
self._conn = sqlite3.connect(self.output_file)
|
||||
self._conn = sqlite3.connect(
|
||||
self.output_file, check_same_thread=SQLITE_CHECK_SAME_THREAD
|
||||
)
|
||||
self._create_tables()
|
||||
self.report_id = self._generate_report_id()
|
||||
|
||||
|
||||
@@ -7,12 +7,16 @@ import click
|
||||
|
||||
from osxphotos._constants import UUID_PATTERN
|
||||
from osxphotos.export_db_utils import get_uuid_for_filepath
|
||||
from osxphotos.photosdb.photosdb_utils import get_photos_library_version
|
||||
from osxphotos.platform import assert_macos
|
||||
from osxphotos.utils import get_last_library_path
|
||||
|
||||
assert_macos()
|
||||
|
||||
from osxphotos.photoscript_utils import (
|
||||
photoscript_object_from_name,
|
||||
photoscript_object_from_uuid,
|
||||
)
|
||||
from osxphotos.photosdb.photosdb_utils import get_photos_library_version
|
||||
from osxphotos.utils import get_last_library_path
|
||||
|
||||
from .cli_commands import echo, echo_error
|
||||
from .cli_params import DB_OPTION
|
||||
|
||||
@@ -9,13 +9,13 @@ import pathlib
|
||||
from typing import Any, Callable, Literal
|
||||
|
||||
import click
|
||||
import photoscript
|
||||
|
||||
from osxphotos import PhotoInfo, PhotosDB, __version__
|
||||
from osxphotos.photoinfo import PhotoInfoNone
|
||||
from osxphotos.photosalbum import PhotosAlbum
|
||||
from osxphotos.photosdb.photosdb_utils import get_db_version
|
||||
from osxphotos.phototemplate import PhotoTemplate, RenderOptions
|
||||
from osxphotos.platform import assert_macos
|
||||
from osxphotos.queryoptions import (
|
||||
IncompatibleQueryOptions,
|
||||
QueryOptions,
|
||||
@@ -24,6 +24,10 @@ from osxphotos.queryoptions import (
|
||||
from osxphotos.sqlitekvstore import SQLiteKVStore
|
||||
from osxphotos.utils import pluralize
|
||||
|
||||
assert_macos()
|
||||
|
||||
import photoscript
|
||||
|
||||
from .cli_params import (
|
||||
DB_OPTION,
|
||||
QUERY_OPTIONS,
|
||||
@@ -167,6 +171,7 @@ def get_photo_metadata(photos: list[PhotoInfo]) -> str:
|
||||
photos_dict[k] = v
|
||||
elif photos_dict[k] and v != photos_dict[k]:
|
||||
photos_dict[k] = f"{photos_dict[k]} {v}"
|
||||
|
||||
# convert photos_dict to JSON string
|
||||
# wouldn't it be nice if json encoder handled datetimes...
|
||||
def default(o):
|
||||
|
||||
@@ -7,7 +7,6 @@ from functools import partial
|
||||
from textwrap import dedent
|
||||
|
||||
import click
|
||||
from photoscript import PhotosLibrary
|
||||
from rich.console import Console
|
||||
|
||||
from osxphotos._constants import APP_NAME
|
||||
@@ -25,10 +24,16 @@ from osxphotos.photodates import (
|
||||
update_photo_from_function,
|
||||
update_photo_time_for_new_timezone,
|
||||
)
|
||||
from osxphotos.photosalbum import PhotosAlbumPhotoScript
|
||||
from osxphotos.phototz import PhotoTimeZone, PhotoTimeZoneUpdater
|
||||
from osxphotos.platform import assert_macos
|
||||
from osxphotos.utils import noop, pluralize
|
||||
|
||||
assert_macos()
|
||||
|
||||
from photoscript import PhotosLibrary
|
||||
|
||||
from osxphotos.photosalbum import PhotosAlbumPhotoScript
|
||||
|
||||
from .cli_params import THEME_OPTION, TIMESTAMP_OPTION, VERBOSE_OPTION
|
||||
from .click_rich_echo import rich_click_echo as echo
|
||||
from .click_rich_echo import rich_echo_error as echo_error
|
||||
@@ -164,7 +169,7 @@ See also `osxphotos help timewarp` for more information on the timewarp
|
||||
command which can be used to change the time zone of photos after import.
|
||||
|
||||
|
||||
"""
|
||||
""" # noqa: E501
|
||||
),
|
||||
width=formatter.width,
|
||||
markdown=True,
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
"""uuid command for osxphotos CLI"""
|
||||
|
||||
import click
|
||||
|
||||
from osxphotos.platform import assert_macos
|
||||
|
||||
assert_macos()
|
||||
|
||||
import photoscript
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
"""about command for osxphotos CLI"""
|
||||
|
||||
import click
|
||||
import os
|
||||
|
||||
import click
|
||||
import packaging
|
||||
|
||||
from osxphotos._constants import OSXPHOTOS_URL
|
||||
from osxphotos._version import __version__
|
||||
|
||||
from .common import get_latest_version
|
||||
import packaging
|
||||
|
||||
|
||||
@click.command(name="version")
|
||||
|
||||
@@ -5,12 +5,17 @@ from typing import Callable, List, Optional, Tuple
|
||||
|
||||
from osxphotos import PhotosDB
|
||||
from osxphotos.exiftool import ExifTool
|
||||
from photoscript import Photo
|
||||
|
||||
from .datetime_utils import datetime_naive_to_local, datetime_to_new_tz
|
||||
from .platform import assert_macos
|
||||
from .utils import noop
|
||||
|
||||
assert_macos()
|
||||
|
||||
from photoscript import Photo
|
||||
|
||||
from .exif_datetime_updater import get_exif_date_time_offset
|
||||
from .phototz import PhotoTimeZone
|
||||
from .utils import noop
|
||||
|
||||
ExifDiff = namedtuple(
|
||||
"ExifDiff",
|
||||
|
||||
@@ -50,7 +50,7 @@ class ConfigOptions:
|
||||
try:
|
||||
arg = args[attr]
|
||||
# don't test 'not arg'; need to handle empty strings as valid values
|
||||
if arg is None or arg == False:
|
||||
if arg is None or arg is False:
|
||||
if type(self._attrs[attr]) == tuple:
|
||||
setattr(self, attr, ())
|
||||
else:
|
||||
|
||||
@@ -21,6 +21,7 @@ __all__ = [
|
||||
"utc_offset_seconds",
|
||||
]
|
||||
|
||||
|
||||
# TODO: look at https://github.com/regebro/tzlocal for more robust implementation
|
||||
def get_local_tz(dt: datetime.datetime) -> datetime.tzinfo:
|
||||
"""Return local timezone as datetime.timezone tzinfo for dt
|
||||
@@ -207,4 +208,3 @@ def utc_offset_seconds(dt: datetime.datetime) -> int:
|
||||
return dt.tzinfo.utcoffset(dt).total_seconds()
|
||||
else:
|
||||
raise ValueError("dt does not have timezone info")
|
||||
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -16,7 +16,7 @@ from rich import print
|
||||
|
||||
from osxphotos.photoinfo import PhotoInfo
|
||||
|
||||
from ._constants import OSXPHOTOS_EXPORT_DB
|
||||
from ._constants import OSXPHOTOS_EXPORT_DB, SQLITE_CHECK_SAME_THREAD
|
||||
from ._version import __version__
|
||||
from .configoptions import ConfigOptions
|
||||
from .export_db import OSXPHOTOS_EXPORTDB_VERSION, ExportDB
|
||||
@@ -50,7 +50,7 @@ def export_db_get_version(
|
||||
dbfile: Union[str, pathlib.Path]
|
||||
) -> Tuple[Optional[int], Optional[int]]:
|
||||
"""returns version from export database as tuple of (osxphotos version, export_db version)"""
|
||||
conn = sqlite3.connect(str(dbfile))
|
||||
conn = sqlite3.connect(str(dbfile), check_same_thread=SQLITE_CHECK_SAME_THREAD)
|
||||
c = conn.cursor()
|
||||
if row := c.execute(
|
||||
"SELECT osxphotos, exportdb FROM version ORDER BY id DESC LIMIT 1;"
|
||||
@@ -61,7 +61,7 @@ def export_db_get_version(
|
||||
|
||||
def export_db_vacuum(dbfile: Union[str, pathlib.Path]) -> None:
|
||||
"""Vacuum export database"""
|
||||
conn = sqlite3.connect(str(dbfile))
|
||||
conn = sqlite3.connect(str(dbfile), check_same_thread=SQLITE_CHECK_SAME_THREAD)
|
||||
c = conn.cursor()
|
||||
c.execute("VACUUM;")
|
||||
conn.commit()
|
||||
@@ -79,7 +79,7 @@ def export_db_update_signatures(
|
||||
"""
|
||||
export_dir = pathlib.Path(export_dir)
|
||||
fileutil = FileUtil
|
||||
conn = sqlite3.connect(str(dbfile))
|
||||
conn = sqlite3.connect(str(dbfile), check_same_thread=SQLITE_CHECK_SAME_THREAD)
|
||||
c = conn.cursor()
|
||||
c.execute("SELECT filepath_normalized, filepath FROM export_data;")
|
||||
rows = c.fetchall()
|
||||
@@ -114,7 +114,7 @@ def export_db_get_last_run(
|
||||
export_db: Union[str, pathlib.Path]
|
||||
) -> Tuple[Optional[str], Optional[str]]:
|
||||
"""Get last run from export database"""
|
||||
conn = sqlite3.connect(str(export_db))
|
||||
conn = sqlite3.connect(str(export_db), check_same_thread=SQLITE_CHECK_SAME_THREAD)
|
||||
c = conn.cursor()
|
||||
if row := c.execute(
|
||||
"SELECT datetime, args FROM runs ORDER BY id DESC LIMIT 1;"
|
||||
@@ -127,7 +127,7 @@ def export_db_get_errors(
|
||||
export_db: Union[str, pathlib.Path]
|
||||
) -> Tuple[Optional[str], Optional[str]]:
|
||||
"""Get errors from export database"""
|
||||
conn = sqlite3.connect(str(export_db))
|
||||
conn = sqlite3.connect(str(export_db), check_same_thread=SQLITE_CHECK_SAME_THREAD)
|
||||
c = conn.cursor()
|
||||
results = c.execute(
|
||||
"SELECT filepath, uuid, timestamp, error FROM export_data WHERE error is not null ORDER BY timestamp DESC;"
|
||||
@@ -145,7 +145,7 @@ def export_db_save_config_to_file(
|
||||
"""Save export_db last run config to file"""
|
||||
export_db = pathlib.Path(export_db)
|
||||
config_file = pathlib.Path(config_file)
|
||||
conn = sqlite3.connect(str(export_db))
|
||||
conn = sqlite3.connect(str(export_db), check_same_thread=SQLITE_CHECK_SAME_THREAD)
|
||||
c = conn.cursor()
|
||||
row = c.execute("SELECT config FROM config ORDER BY id DESC LIMIT 1;").fetchone()
|
||||
if not row:
|
||||
@@ -163,7 +163,7 @@ def export_db_get_config(
|
||||
export_db: path to export database
|
||||
override: if True, any loaded config values will overwrite existing values in config
|
||||
"""
|
||||
conn = sqlite3.connect(str(export_db))
|
||||
conn = sqlite3.connect(str(export_db), check_same_thread=SQLITE_CHECK_SAME_THREAD)
|
||||
c = conn.cursor()
|
||||
row = c.execute("SELECT config FROM config ORDER BY id DESC LIMIT 1;").fetchone()
|
||||
return (
|
||||
@@ -184,7 +184,7 @@ def export_db_check_signatures(
|
||||
"""
|
||||
export_dir = pathlib.Path(export_dir)
|
||||
fileutil = FileUtil
|
||||
conn = sqlite3.connect(str(dbfile))
|
||||
conn = sqlite3.connect(str(dbfile), check_same_thread=SQLITE_CHECK_SAME_THREAD)
|
||||
c = conn.cursor()
|
||||
c.execute("SELECT filepath_normalized, filepath FROM export_data;")
|
||||
rows = c.fetchall()
|
||||
@@ -236,7 +236,7 @@ def export_db_touch_files(
|
||||
)
|
||||
exportdb.close()
|
||||
|
||||
conn = sqlite3.connect(str(dbfile))
|
||||
conn = sqlite3.connect(str(dbfile), check_same_thread=SQLITE_CHECK_SAME_THREAD)
|
||||
c = conn.cursor()
|
||||
if row := c.execute(
|
||||
"SELECT config FROM config ORDER BY id DESC LIMIT 1;"
|
||||
@@ -318,7 +318,7 @@ def export_db_migrate_photos_library(
|
||||
and update the UUIDs in the export database
|
||||
"""
|
||||
verbose(f"Loading data from export database {dbfile}")
|
||||
conn = sqlite3.connect(str(dbfile))
|
||||
conn = sqlite3.connect(str(dbfile), check_same_thread=SQLITE_CHECK_SAME_THREAD)
|
||||
c = conn.cursor()
|
||||
results = c.execute("SELECT uuid, photoinfo FROM photoinfo;").fetchall()
|
||||
exportdb_uuids = {}
|
||||
@@ -495,7 +495,7 @@ def export_db_get_last_library(dbpath: Union[str, pathlib.Path]) -> str:
|
||||
str: name of library used to export from or "" if not found
|
||||
"""
|
||||
dbpath = pathlib.Path(dbpath)
|
||||
conn = sqlite3.connect(str(dbpath))
|
||||
conn = sqlite3.connect(str(dbpath), check_same_thread=SQLITE_CHECK_SAME_THREAD)
|
||||
c = conn.cursor()
|
||||
if results := c.execute(
|
||||
"""
|
||||
|
||||
@@ -9,9 +9,12 @@ import typing as t
|
||||
from abc import ABC, abstractmethod
|
||||
from tempfile import TemporaryDirectory
|
||||
|
||||
import Foundation
|
||||
|
||||
from .imageconverter import ImageConverter
|
||||
from .platform import is_macos
|
||||
from .unicode import normalize_fs_path
|
||||
|
||||
if is_macos:
|
||||
import Foundation
|
||||
|
||||
__all__ = ["FileUtilABC", "FileUtilMacOS", "FileUtilShUtil", "FileUtil", "FileUtilNoOp"]
|
||||
|
||||
@@ -90,6 +93,9 @@ class FileUtilMacOS(FileUtilABC):
|
||||
if src is None or dest is None:
|
||||
raise ValueError("src and dest must not be None", src, dest)
|
||||
|
||||
src = normalize_fs_path(src)
|
||||
dest = normalize_fs_path(dest)
|
||||
|
||||
if not os.path.isfile(src):
|
||||
raise FileNotFoundError("src file does not appear to exist", src)
|
||||
|
||||
@@ -115,6 +121,9 @@ class FileUtilMacOS(FileUtilABC):
|
||||
OSError if copy fails
|
||||
TypeError if either path is None
|
||||
"""
|
||||
src = normalize_fs_path(src)
|
||||
dest = normalize_fs_path(dest)
|
||||
|
||||
if not isinstance(src, pathlib.Path):
|
||||
src = pathlib.Path(src)
|
||||
|
||||
@@ -135,6 +144,7 @@ class FileUtilMacOS(FileUtilABC):
|
||||
@classmethod
|
||||
def unlink(cls, filepath):
|
||||
"""unlink filepath; if it's pathlib.Path, use Path.unlink, otherwise use os.unlink"""
|
||||
filepath = normalize_fs_path(filepath)
|
||||
if isinstance(filepath, pathlib.Path):
|
||||
filepath.unlink()
|
||||
else:
|
||||
@@ -143,6 +153,7 @@ class FileUtilMacOS(FileUtilABC):
|
||||
@classmethod
|
||||
def rmdir(cls, dirpath):
|
||||
"""remove directory filepath; dirpath must be empty"""
|
||||
dirpath = normalize_fs_path(dirpath)
|
||||
if isinstance(dirpath, pathlib.Path):
|
||||
dirpath.rmdir()
|
||||
else:
|
||||
@@ -151,6 +162,7 @@ class FileUtilMacOS(FileUtilABC):
|
||||
@classmethod
|
||||
def utime(cls, path, times):
|
||||
"""Set the access and modified time of path."""
|
||||
path = normalize_fs_path(path)
|
||||
os.utime(path, times=times)
|
||||
|
||||
@classmethod
|
||||
@@ -166,6 +178,9 @@ class FileUtilMacOS(FileUtilABC):
|
||||
Does not do a byte-by-byte comparison.
|
||||
"""
|
||||
|
||||
f1 = normalize_fs_path(f1)
|
||||
f2 = normalize_fs_path(f2)
|
||||
|
||||
s1 = cls._sig(os.stat(f1))
|
||||
if mtime1 is not None:
|
||||
s1 = (s1[0], s1[1], int(mtime1))
|
||||
@@ -188,6 +203,7 @@ class FileUtilMacOS(FileUtilABC):
|
||||
if not s2:
|
||||
return False
|
||||
|
||||
f1 = normalize_fs_path(f1)
|
||||
s1 = cls._sig(os.stat(f1))
|
||||
if s1[0] != stat.S_IFREG or s2[0] != stat.S_IFREG:
|
||||
return False
|
||||
@@ -196,6 +212,7 @@ class FileUtilMacOS(FileUtilABC):
|
||||
@classmethod
|
||||
def file_sig(cls, f1):
|
||||
"""return os.stat signature for file f1 as tuple of (mode, size, mtime)"""
|
||||
f1 = normalize_fs_path(f1)
|
||||
return cls._sig(os.stat(f1))
|
||||
|
||||
@classmethod
|
||||
@@ -210,6 +227,8 @@ class FileUtilMacOS(FileUtilABC):
|
||||
Returns:
|
||||
True if success, otherwise False
|
||||
"""
|
||||
src_file = normalize_fs_path(src_file)
|
||||
dest_file = normalize_fs_path(dest_file)
|
||||
converter = ImageConverter()
|
||||
return converter.write_jpeg(
|
||||
src_file, dest_file, compression_quality=compression_quality
|
||||
@@ -227,6 +246,8 @@ class FileUtilMacOS(FileUtilABC):
|
||||
Name of renamed file (dest)
|
||||
|
||||
"""
|
||||
src = normalize_fs_path(src)
|
||||
dest = normalize_fs_path(dest)
|
||||
os.rename(str(src), str(dest))
|
||||
return dest
|
||||
|
||||
@@ -271,6 +292,9 @@ class FileUtilShUtil(FileUtilMacOS):
|
||||
OSError if copy fails
|
||||
TypeError if either path is None
|
||||
"""
|
||||
src = normalize_fs_path(src)
|
||||
dest = normalize_fs_path(dest)
|
||||
|
||||
if not isinstance(src, pathlib.Path):
|
||||
src = pathlib.Path(src)
|
||||
|
||||
@@ -288,7 +312,7 @@ class FileUtilShUtil(FileUtilMacOS):
|
||||
return True
|
||||
|
||||
|
||||
class FileUtil(FileUtilMacOS):
|
||||
class FileUtil(FileUtilShUtil):
|
||||
"""Various file utilities"""
|
||||
|
||||
pass
|
||||
|
||||
169
osxphotos/frozen_photoinfo.py
Normal file
169
osxphotos/frozen_photoinfo.py
Normal file
@@ -0,0 +1,169 @@
|
||||
"""Freeze a PhotoInfo object to allow it to be used in concurrent.futures."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import datetime
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
from types import SimpleNamespace
|
||||
from typing import Any
|
||||
|
||||
from osxmetadata import OSXMetaData
|
||||
|
||||
import osxphotos
|
||||
|
||||
from ._constants import TEXT_DETECTION_CONFIDENCE_THRESHOLD
|
||||
from .exiftool import ExifToolCaching, get_exiftool_path
|
||||
from .phototemplate import PhotoTemplate, RenderOptions
|
||||
from .text_detection import detect_text
|
||||
|
||||
|
||||
def frozen_photoinfo_factory(photo: "osxphotos.photoinfo.PhotoInfo") -> SimpleNamespace:
|
||||
"""Return a frozen SimpleNamespace object for a PhotoInfo object"""
|
||||
photo_json = photo.json()
|
||||
|
||||
def _object_hook(d: dict[Any, Any]):
|
||||
if not d:
|
||||
return d
|
||||
|
||||
# if d key matches a ISO 8601 datetime ('2023-03-24T06:46:57.690786', '2019-07-04T16:24:01-07:00', '2019-07-04T16:24:01+07:00'), convert to datetime
|
||||
# fromisoformat will also handle dates with timezone offset in form +0700, etc.
|
||||
for k, v in d.items():
|
||||
if isinstance(v, str) and re.match(
|
||||
r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[.]?\d*[+-]?\d{2}[:]?\d{2}?", v
|
||||
):
|
||||
d[k] = datetime.datetime.fromisoformat(v)
|
||||
return SimpleNamespace(**d)
|
||||
|
||||
frozen = json.loads(photo_json, object_hook=lambda d: _object_hook(d))
|
||||
|
||||
# add on json() method to frozen object
|
||||
def _json(*args):
|
||||
return photo_json
|
||||
|
||||
frozen.json = _json
|
||||
|
||||
# add hexdigest property to frozen object
|
||||
frozen.hexdigest = photo.hexdigest
|
||||
|
||||
# add on detected_text method to frozen object
|
||||
frozen = _add_detected_text(frozen)
|
||||
|
||||
# add on exiftool property to frozen object
|
||||
frozen = _add_exiftool(frozen, photo)
|
||||
|
||||
# add on render_template method to frozen object
|
||||
frozen = _add_render_template(frozen)
|
||||
|
||||
# add on the _db property to frozen object
|
||||
# frozen objects don't really have a _db class but some things expect it (e.g. _db._beta)
|
||||
frozen._db = SimpleNamespace(_beta=photo._db._beta)
|
||||
|
||||
return frozen
|
||||
|
||||
|
||||
def _add_detected_text(frozen: SimpleNamespace) -> SimpleNamespace:
|
||||
"""Add detected_text method to frozen PhotoInfo object"""
|
||||
|
||||
def detected_text(confidence_threshold=TEXT_DETECTION_CONFIDENCE_THRESHOLD):
|
||||
"""Detects text in photo and returns lists of results as (detected text, confidence)
|
||||
|
||||
confidence_threshold: float between 0.0 and 1.0. If text detection confidence is below this threshold,
|
||||
text will not be returned. Default is TEXT_DETECTION_CONFIDENCE_THRESHOLD
|
||||
|
||||
If photo is edited, uses the edited photo, otherwise the original; falls back to the preview image if neither edited or original is available
|
||||
|
||||
Returns: list of (detected text, confidence) tuples
|
||||
"""
|
||||
|
||||
try:
|
||||
return frozen._detected_text_cache[confidence_threshold]
|
||||
except (AttributeError, KeyError) as e:
|
||||
if isinstance(e, AttributeError):
|
||||
frozen._detected_text_cache = {}
|
||||
|
||||
try:
|
||||
detected_text = frozen._detected_text()
|
||||
except Exception as e:
|
||||
logging.warning(f"Error detecting text in photo {frozen.uuid}: {e}")
|
||||
detected_text = []
|
||||
|
||||
frozen._detected_text_cache[confidence_threshold] = [
|
||||
(text, confidence)
|
||||
for text, confidence in detected_text
|
||||
if confidence >= confidence_threshold
|
||||
]
|
||||
return frozen._detected_text_cache[confidence_threshold]
|
||||
|
||||
def _detected_text():
|
||||
"""detect text in photo, either from cached extended attribute or by attempting text detection"""
|
||||
path = (
|
||||
frozen.path_edited
|
||||
if frozen.hasadjustments and frozen.path_edited
|
||||
else frozen.path
|
||||
)
|
||||
path = path or frozen.path_derivatives[0] if frozen.path_derivatives else None
|
||||
if not path:
|
||||
return []
|
||||
|
||||
md = OSXMetaData(path)
|
||||
try:
|
||||
|
||||
def decoder(val):
|
||||
"""Decode value from JSON"""
|
||||
return json.loads(val.decode("utf-8"))
|
||||
|
||||
detected_text = md.get_xattr(
|
||||
"osxphotos.metadata:detected_text", decode=decoder
|
||||
)
|
||||
except KeyError:
|
||||
detected_text = None
|
||||
if detected_text is None:
|
||||
orientation = frozen.orientation or None
|
||||
detected_text = detect_text(path, orientation)
|
||||
|
||||
def encoder(obj):
|
||||
"""Encode value as JSON"""
|
||||
val = json.dumps(obj)
|
||||
return val.encode("utf-8")
|
||||
|
||||
md.set_xattr(
|
||||
"osxphotos.metadata:detected_text", detected_text, encode=encoder
|
||||
)
|
||||
return detected_text
|
||||
|
||||
frozen.detected_text = detected_text
|
||||
frozen._detected_text = _detected_text
|
||||
|
||||
return frozen
|
||||
|
||||
|
||||
def _add_exiftool(
|
||||
frozen: SimpleNamespace, photo: "osxphotos.photoinfo.PhotoInfo"
|
||||
) -> SimpleNamespace:
|
||||
"""Add exiftool property to frozen PhotoInfo object"""
|
||||
frozen._exiftool_path = photo._db._exiftool_path or None
|
||||
return frozen
|
||||
|
||||
|
||||
def _add_render_template(frozen: SimpleNamespace) -> SimpleNamespace:
|
||||
"""Add render_template method to frozen PhotoInfo object"""
|
||||
|
||||
def render_template(template_str: str, options: RenderOptions | None = None):
|
||||
"""Renders a template string for PhotoInfo instance using PhotoTemplate
|
||||
|
||||
Args:
|
||||
template_str: a template string with fields to render
|
||||
options: a RenderOptions instance
|
||||
|
||||
Returns:
|
||||
([rendered_strings], [unmatched]): tuple of list of rendered strings and list of unmatched template values
|
||||
"""
|
||||
options = options or RenderOptions()
|
||||
template = PhotoTemplate(frozen, exiftool_path=frozen._exiftool_path)
|
||||
return template.render(template_str, options)
|
||||
|
||||
frozen.render_template = render_template
|
||||
return frozen
|
||||
@@ -5,16 +5,20 @@
|
||||
# reference: https://stackoverflow.com/questions/59330149/coreimage-ciimage-write-jpg-is-shifting-colors-macos/59334308#59334308
|
||||
|
||||
import pathlib
|
||||
|
||||
import objc
|
||||
import Metal
|
||||
import Quartz
|
||||
from Cocoa import NSURL
|
||||
from Foundation import NSDictionary
|
||||
import sys
|
||||
|
||||
# needed to capture system-level stderr
|
||||
from wurlitzer import pipes
|
||||
|
||||
from .platform import is_macos
|
||||
|
||||
if is_macos:
|
||||
import Metal
|
||||
import objc
|
||||
import Quartz
|
||||
from Cocoa import NSURL
|
||||
from Foundation import NSDictionary
|
||||
|
||||
__all__ = ["ImageConversionError", "ImageConverter"]
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,20 @@
|
||||
""" utility functions for validating/sanitizing path components """
|
||||
""" utility functions for validating/sanitizing path components
|
||||
|
||||
This module also performs Unicode normalization. For a quick summary, there are
|
||||
multiple ways to write more complex characters in Unicode. This causes problems
|
||||
when e.g. checking if a file already exists and you have multiple sources for
|
||||
the same string with different encodings. This sadly happens in Photos, but
|
||||
isn't a problem on macOS, since macOS does normalization behind-the-scenes (see
|
||||
https://eclecticlight.co/2021/05/08/explainer-unicode-normalization-and-apfs/).
|
||||
This causes problems on other platforms, so we normalize as part of filename
|
||||
sanitization functions and rely on them being called every time a unique
|
||||
filename is needed.
|
||||
"""
|
||||
|
||||
import pathvalidate
|
||||
|
||||
from osxphotos.unicode import normalize_unicode
|
||||
|
||||
from ._constants import MAX_DIRNAME_LEN, MAX_FILENAME_LEN
|
||||
|
||||
__all__ = [
|
||||
@@ -24,7 +37,7 @@ def is_valid_filepath(filepath):
|
||||
|
||||
|
||||
def sanitize_filename(filename, replacement=":"):
|
||||
"""replace any illegal characters in a filename and truncate filename if needed
|
||||
"""replace any illegal characters in a filename, truncate filename if needed and normalize Unicode to NFC form
|
||||
|
||||
Args:
|
||||
filename: str, filename to sanitze
|
||||
@@ -35,6 +48,7 @@ def sanitize_filename(filename, replacement=":"):
|
||||
"""
|
||||
|
||||
if filename:
|
||||
filename = normalize_unicode(filename)
|
||||
filename = filename.replace("/", replacement)
|
||||
if len(filename) > MAX_FILENAME_LEN:
|
||||
parts = filename.split(".")
|
||||
@@ -54,7 +68,7 @@ def sanitize_filename(filename, replacement=":"):
|
||||
|
||||
|
||||
def sanitize_dirname(dirname, replacement=":"):
|
||||
"""replace any illegal characters in a directory name and truncate directory name if needed
|
||||
"""replace any illegal characters in a directory name, truncate directory name if needed, and normalize Unicode to NFC form
|
||||
|
||||
Args:
|
||||
dirname: str, directory name to sanitize
|
||||
@@ -69,7 +83,7 @@ def sanitize_dirname(dirname, replacement=":"):
|
||||
|
||||
|
||||
def sanitize_pathpart(pathpart, replacement=":"):
|
||||
"""replace any illegal characters in a path part (either directory or filename without extension) and truncate name if needed
|
||||
"""replace any illegal characters in a path part (either directory or filename without extension), truncate name if needed, and normalize Unicode to NFC form
|
||||
|
||||
Args:
|
||||
pathpart: str, path part to sanitize
|
||||
@@ -82,6 +96,7 @@ def sanitize_pathpart(pathpart, replacement=":"):
|
||||
pathpart = (
|
||||
pathpart.replace("/", replacement) if replacement is not None else pathpart
|
||||
)
|
||||
pathpart = normalize_unicode(pathpart)
|
||||
if len(pathpart) > MAX_DIRNAME_LEN:
|
||||
drop = len(pathpart) - MAX_DIRNAME_LEN
|
||||
pathpart = pathpart[:-drop]
|
||||
|
||||
@@ -11,7 +11,7 @@ import photoscript
|
||||
from strpdatetime import strpdatetime
|
||||
from tenacity import retry, stop_after_attempt, wait_exponential
|
||||
|
||||
from ._constants import _DB_TABLE_NAMES
|
||||
from ._constants import _DB_TABLE_NAMES, SQLITE_CHECK_SAME_THREAD
|
||||
from .datetime_utils import (
|
||||
datetime_has_tz,
|
||||
datetime_remove_tz,
|
||||
@@ -219,7 +219,7 @@ def _set_date_added(library_path: str, uuid: str, date_added: datetime.datetime)
|
||||
asset_table = _DB_TABLE_NAMES[photos_version]["ASSET"]
|
||||
|
||||
timestamp = datetime_to_photos_timestamp(date_added)
|
||||
conn = sqlite3.connect(db_path)
|
||||
conn = sqlite3.connect(db_path, check_same_thread=SQLITE_CHECK_SAME_THREAD)
|
||||
c = conn.cursor()
|
||||
c.execute(
|
||||
f"UPDATE {asset_table} SET ZADDEDDATE=? WHERE ZUUID=?",
|
||||
@@ -268,7 +268,7 @@ def get_photo_date_added(
|
||||
photos_version = get_photos_library_version(library_path)
|
||||
db_path = str(pathlib.Path(library_path) / "database/Photos.sqlite")
|
||||
asset_table = _DB_TABLE_NAMES[photos_version]["ASSET"]
|
||||
conn = sqlite3.connect(db_path)
|
||||
conn = sqlite3.connect(db_path, check_same_thread=SQLITE_CHECK_SAME_THREAD)
|
||||
c = conn.cursor()
|
||||
c.execute(
|
||||
f"SELECT ZADDEDDATE FROM {asset_table} WHERE ZUUID=?",
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
""" PhotoExport class to export photos
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import dataclasses
|
||||
import json
|
||||
import logging
|
||||
@@ -8,12 +10,11 @@ import os
|
||||
import pathlib
|
||||
import re
|
||||
import typing as t
|
||||
from collections import namedtuple # pylint: disable=syntax-error
|
||||
from dataclasses import asdict, dataclass
|
||||
from datetime import datetime
|
||||
from enum import Enum
|
||||
from types import SimpleNamespace
|
||||
|
||||
import photoscript
|
||||
from mako.template import Template
|
||||
|
||||
from ._constants import (
|
||||
@@ -31,18 +32,13 @@ from ._constants import (
|
||||
)
|
||||
from ._version import __version__
|
||||
from .datetime_utils import datetime_tz_to_utc
|
||||
from .exiftool import ExifTool, exiftool_can_write
|
||||
from .exiftool import ExifTool, ExifToolCaching, exiftool_can_write, get_exiftool_path
|
||||
from .export_db import ExportDB, ExportDBTemp
|
||||
from .fileutil import FileUtil
|
||||
from .photokit import (
|
||||
PHOTOS_VERSION_CURRENT,
|
||||
PHOTOS_VERSION_ORIGINAL,
|
||||
PHOTOS_VERSION_UNADJUSTED,
|
||||
PhotoKitFetchFailed,
|
||||
PhotoLibrary,
|
||||
)
|
||||
from .phototemplate import RenderOptions
|
||||
from .platform import is_macos
|
||||
from .rich_utils import add_rich_markup_tag
|
||||
from .unicode import normalize_fs_path
|
||||
from .uti import get_preferred_uti_extension
|
||||
from .utils import (
|
||||
hexdigest,
|
||||
@@ -54,6 +50,18 @@ from .utils import (
|
||||
unlock_filename,
|
||||
)
|
||||
|
||||
if is_macos:
|
||||
import photoscript
|
||||
|
||||
from .photokit import (
|
||||
PHOTOS_VERSION_CURRENT,
|
||||
PHOTOS_VERSION_ORIGINAL,
|
||||
PHOTOS_VERSION_UNADJUSTED,
|
||||
PhotoKitFetchFailed,
|
||||
PhotoLibrary,
|
||||
)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"ExportError",
|
||||
"ExportOptions",
|
||||
@@ -68,6 +76,11 @@ if t.TYPE_CHECKING:
|
||||
# retry if download_missing/use_photos_export fails the first time (which sometimes it does)
|
||||
MAX_PHOTOSCRIPT_RETRIES = 3
|
||||
|
||||
# Global to hold the compiled XMP template
|
||||
# This is expensive to compile so we only want to do it once
|
||||
_global_xmp_template: Template | None = None
|
||||
|
||||
|
||||
# return values for _should_update_photo
|
||||
class ShouldUpdate(Enum):
|
||||
NOT_IN_DATABASE = 1
|
||||
@@ -122,6 +135,7 @@ class ExportOptions:
|
||||
render_options (RenderOptions): t.Optional osxphotos.phototemplate.RenderOptions instance to specify options for rendering templates
|
||||
replace_keywords (bool): if True, keyword_template replaces any keywords, otherwise it's additive
|
||||
rich (bool): if True, will use rich markup with verbose output
|
||||
export_aae (bool): if True, also exports adjustments as .AAE file
|
||||
sidecar_drop_ext (bool, default=False): if True, drops the photo's extension from sidecar filename (e.g. 'IMG_1234.json' instead of 'IMG_1234.JPG.json')
|
||||
sidecar: bit field (int): set to one or more of `SIDECAR_XMP`, `SIDECAR_JSON`, `SIDECAR_EXIFTOOL`
|
||||
- SIDECAR_JSON: if set will write a json sidecar with data in format readable by exiftool sidecar filename will be dest/filename.json;
|
||||
@@ -174,6 +188,7 @@ class ExportOptions:
|
||||
render_options: t.Optional[RenderOptions] = None
|
||||
replace_keywords: bool = False
|
||||
rich: bool = False
|
||||
export_aae: bool = False
|
||||
sidecar_drop_ext: bool = False
|
||||
sidecar: int = 0
|
||||
strip: bool = False
|
||||
@@ -235,6 +250,9 @@ class StagedFiles:
|
||||
def __str__(self):
|
||||
return str(self.asdict())
|
||||
|
||||
def __repr__(self):
|
||||
return f"StagedFiles({self.asdict()})"
|
||||
|
||||
def asdict(self):
|
||||
return {
|
||||
"original": self.original,
|
||||
@@ -265,6 +283,7 @@ class ExportResults:
|
||||
"missing",
|
||||
"missing_album",
|
||||
"new",
|
||||
"aae_written",
|
||||
"sidecar_exiftool_skipped",
|
||||
"sidecar_exiftool_written",
|
||||
"sidecar_json_skipped",
|
||||
@@ -295,6 +314,7 @@ class ExportResults:
|
||||
missing=None,
|
||||
missing_album=None,
|
||||
new=None,
|
||||
aae_written=None,
|
||||
sidecar_exiftool_skipped=None,
|
||||
sidecar_exiftool_written=None,
|
||||
sidecar_json_skipped=None,
|
||||
@@ -309,7 +329,6 @@ class ExportResults:
|
||||
xattr_skipped=None,
|
||||
xattr_written=None,
|
||||
):
|
||||
|
||||
local_vars = locals()
|
||||
self._datetime = datetime.now().isoformat()
|
||||
for attr in self.attributes:
|
||||
@@ -335,6 +354,7 @@ class ExportResults:
|
||||
+ self.exif_updated
|
||||
+ self.touched
|
||||
+ self.converted_to_jpeg
|
||||
+ self.aae_written
|
||||
+ self.sidecar_json_written
|
||||
+ self.sidecar_json_skipped
|
||||
+ self.sidecar_exiftool_written
|
||||
@@ -374,7 +394,7 @@ class PhotoExporter:
|
||||
def __init__(self, photo: "PhotoInfo", tmpdir: t.Optional[str] = None):
|
||||
self.photo = photo
|
||||
self._render_options = RenderOptions()
|
||||
self._verbose = self.photo._verbose
|
||||
self._verbose = photo._verbose
|
||||
|
||||
# define functions for adding markup
|
||||
self._filepath = add_rich_markup_tag("filepath", rich=False)
|
||||
@@ -471,6 +491,11 @@ class PhotoExporter:
|
||||
dest, options = self._should_convert_to_jpeg(dest, options)
|
||||
|
||||
# stage files for export by finding path in local library or downloading from iCloud as appropriate
|
||||
# for `--download-missing` and `--update` case, this may cause unnecessary downloads
|
||||
# as it will download the file even if it's not needed (won't be checked until the _should_update_photo() call from _export_photo()
|
||||
# fixing this will require major refactoring of the export code, see #1086
|
||||
# leaving it for now as this should not be a common use case
|
||||
# (if using `--update` it is much better to be using "Download originals to this Mac" in Photos)
|
||||
staged_files = self._stage_photos_for_export(options)
|
||||
src = staged_files.edited if options.edited else staged_files.original
|
||||
|
||||
@@ -585,6 +610,8 @@ class PhotoExporter:
|
||||
f"Skipping missing preview photo for {self._filename(self.photo.original_filename)} ({self._uuid(self.photo.uuid)})"
|
||||
)
|
||||
|
||||
if options.export_aae:
|
||||
all_results += self._write_aae_file(dest=dest, options=options)
|
||||
all_results += self._write_sidecar_files(dest=dest, options=options)
|
||||
|
||||
return all_results
|
||||
@@ -657,8 +684,16 @@ class PhotoExporter:
|
||||
return lock_filename(filename) if lock else filename
|
||||
|
||||
# if overwrite==False and #increment==False, export should fail if file exists
|
||||
if dest.exists() and not any(
|
||||
[options.increment, options.update, options.force_update, options.overwrite]
|
||||
if (
|
||||
not any(
|
||||
[
|
||||
options.increment,
|
||||
options.update,
|
||||
options.force_update,
|
||||
options.overwrite,
|
||||
]
|
||||
)
|
||||
and dest.exists()
|
||||
):
|
||||
raise FileExistsError(
|
||||
f"destination exists ({dest}); overwrite={options.overwrite}, increment={options.increment}"
|
||||
@@ -717,9 +752,18 @@ class PhotoExporter:
|
||||
return dest
|
||||
|
||||
def _should_update_photo(
|
||||
self, src: pathlib.Path, dest: pathlib.Path, options: ExportOptions
|
||||
) -> t.Literal[True, False]:
|
||||
"""Return True if photo should be updated, else False"""
|
||||
self, src: pathlib.Path | None, dest: pathlib.Path, options: ExportOptions
|
||||
) -> bool | ShouldUpdate:
|
||||
"""Return True if photo should be updated, else False
|
||||
|
||||
Args:
|
||||
src (pathlib.Path | None): source path; if None, photo is missing and
|
||||
any checks that require src will return True
|
||||
dest (pathlib.Path): destination path
|
||||
|
||||
Returns:
|
||||
False if photo should not be updated otherwise a truthy ShouldUpdate value
|
||||
"""
|
||||
|
||||
# NOTE: The order of certain checks is important
|
||||
# read the comments below to understand why before changing
|
||||
@@ -733,11 +777,11 @@ class PhotoExporter:
|
||||
# photo doesn't exist in database, should update
|
||||
return ShouldUpdate.NOT_IN_DATABASE
|
||||
|
||||
if options.export_as_hardlink and not dest.samefile(src):
|
||||
if options.export_as_hardlink and (not src or not dest.samefile(src)):
|
||||
# different files, should update
|
||||
return ShouldUpdate.HARDLINK_DIFFERENT_FILES
|
||||
|
||||
if not options.export_as_hardlink and dest.samefile(src):
|
||||
if not options.export_as_hardlink and (not src or dest.samefile(src)):
|
||||
# same file but not exporting as hardlink, should update
|
||||
return ShouldUpdate.NOT_HARDLINK_SAME_FILES
|
||||
|
||||
@@ -769,7 +813,9 @@ class PhotoExporter:
|
||||
# as exiftool will be used to update edited file
|
||||
return ShouldUpdate.EXIFTOOL_DIFFERENT if rv else False
|
||||
|
||||
if options.edited and not fileutil.cmp_file_sig(src, file_record.src_sig):
|
||||
if options.edited and (
|
||||
not src or not fileutil.cmp_file_sig(src, file_record.src_sig)
|
||||
):
|
||||
# edited file in Photos doesn't match what was last exported
|
||||
return ShouldUpdate.EDITED_SIG_DIFFERENT
|
||||
|
||||
@@ -820,22 +866,46 @@ class PhotoExporter:
|
||||
|
||||
# download any missing files
|
||||
if options.download_missing:
|
||||
live_photo = staged.edited_live if options.edited else staged.original_live
|
||||
missing_options = ExportOptions(
|
||||
edited=options.edited,
|
||||
preview=options.preview and not staged.preview,
|
||||
raw_photo=options.raw_photo and not staged.raw,
|
||||
live_photo=options.live_photo and not live_photo,
|
||||
staged |= self._stage_missing_photos_for_export(
|
||||
staged=staged, options=options
|
||||
)
|
||||
if options.use_photokit:
|
||||
missing_staged = self._stage_photo_for_export_with_photokit(
|
||||
options=missing_options
|
||||
)
|
||||
else:
|
||||
missing_staged = self._stage_photo_for_export_with_applescript(
|
||||
options=missing_options
|
||||
)
|
||||
staged |= missing_staged
|
||||
|
||||
return staged
|
||||
|
||||
def _stage_missing_photos_for_export(
|
||||
self, staged: StagedFiles, options: ExportOptions
|
||||
) -> StagedFiles:
|
||||
"""Download and stage any missing files for export"""
|
||||
|
||||
# if live photo and requesting edited version need the edited live photo
|
||||
live_photo = staged.edited_live if options.edited else staged.original_live
|
||||
|
||||
# is there actually a missing file? (#1086)
|
||||
something_to_download = (
|
||||
(self.photo.hasadjustments and options.edited and not staged.edited)
|
||||
or (self.photo.live_photo and options.live_photo and not live_photo)
|
||||
or (self.photo.has_raw and options.raw_photo and not staged.raw)
|
||||
or (options.preview and not staged.preview)
|
||||
or (not options.edited and not staged.original)
|
||||
)
|
||||
if not something_to_download:
|
||||
return staged
|
||||
|
||||
missing_options = ExportOptions(
|
||||
edited=options.edited,
|
||||
preview=options.preview and not staged.preview,
|
||||
raw_photo=self.photo.has_raw and options.raw_photo and not staged.raw,
|
||||
live_photo=self.photo.live_photo and options.live_photo and not live_photo,
|
||||
)
|
||||
if options.use_photokit:
|
||||
missing_staged = self._stage_photo_for_export_with_photokit(
|
||||
options=missing_options
|
||||
)
|
||||
else:
|
||||
missing_staged = self._stage_photo_for_export_with_applescript(
|
||||
options=missing_options
|
||||
)
|
||||
staged |= missing_staged
|
||||
return staged
|
||||
|
||||
def _stage_photo_for_export_with_photokit(
|
||||
@@ -950,7 +1020,8 @@ class PhotoExporter:
|
||||
"""Stage a photo for export with AppleScript to a temporary directory
|
||||
|
||||
Note: If exporting an edited live photo, the associated live video will not be exported.
|
||||
This is a limitation of the Photos AppleScript interface and Photos behaves the same way."""
|
||||
This is a limitation of the Photos AppleScript interface and Photos behaves the same way.
|
||||
"""
|
||||
|
||||
if options.edited and not self.photo.hasadjustments:
|
||||
raise ValueError("Edited version requested but photo has no adjustments")
|
||||
@@ -1179,7 +1250,7 @@ class PhotoExporter:
|
||||
try:
|
||||
fileutil.copy(src, dest_str)
|
||||
verbose(
|
||||
f"Exported {self._filename(self.photo.original_filename)} to {self._filepath(dest_str)}"
|
||||
f"Exported {self._filename(self.photo.original_filename)} to {self._filepath(normalize_fs_path(dest_str))}"
|
||||
)
|
||||
except Exception as e:
|
||||
raise ExportError(
|
||||
@@ -1210,7 +1281,7 @@ class PhotoExporter:
|
||||
|
||||
# set data in the database
|
||||
with export_db.create_or_get_file_record(dest_str, self.photo.uuid) as rec:
|
||||
rec.photoinfo = self.photo.json()
|
||||
rec.photoinfo = self.photo.json(shallow=True)
|
||||
rec.export_options = options.bit_flags
|
||||
# don't set src_sig as that is set above before any modifications by convert_to_jpeg or exiftool
|
||||
if not options.ignore_signature:
|
||||
@@ -1340,6 +1411,53 @@ class PhotoExporter:
|
||||
exported_paths.append(str(dest_new))
|
||||
return exported_paths
|
||||
|
||||
def _write_aae_file(
|
||||
self,
|
||||
dest: pathlib.Path,
|
||||
options: ExportOptions,
|
||||
) -> ExportResults:
|
||||
"""Write AAE file for the photo."""
|
||||
|
||||
# AAE files describe adjustments to originals, so they don't make sense
|
||||
# for edited files
|
||||
if options.edited:
|
||||
return ExportResults()
|
||||
|
||||
verbose = options.verbose or self._verbose
|
||||
|
||||
aae_src = self.photo.adjustments_path
|
||||
if aae_src is None:
|
||||
return ExportResults()
|
||||
aae_dest = dest.with_suffix(".AAE")
|
||||
|
||||
if options.export_as_hardlink:
|
||||
try:
|
||||
if aae_dest.exists() and any(
|
||||
[options.overwrite, options.update, options.force_update]):
|
||||
try:
|
||||
options.fileutil.unlink(aae_dest)
|
||||
except Exception as e:
|
||||
raise ExportError(
|
||||
f"Error removing file {aae_dest}: {e} (({lineno(__file__)})"
|
||||
) from e
|
||||
options.fileutil.hardlink(aae_src, aae_dest)
|
||||
except Exception as e:
|
||||
raise ExportError(
|
||||
f"Error hardlinking {aae_src} to {aae_dest}: {e} ({lineno(__file__)})"
|
||||
) from e
|
||||
else:
|
||||
try:
|
||||
options.fileutil.copy(aae_src, aae_dest)
|
||||
verbose(
|
||||
f"Exported adjustments of {self._filename(self.photo.original_filename)} to {self._filepath(normalize_fs_path(aae_dest))}"
|
||||
)
|
||||
except Exception as e:
|
||||
raise ExportError(
|
||||
f"Error copying file {aae_src} to {aae_dest}: {e} ({lineno(__file__)})"
|
||||
) from e
|
||||
|
||||
return ExportResults(aae_written=[aae_dest])
|
||||
|
||||
def _write_sidecar_files(
|
||||
self,
|
||||
dest: pathlib.Path,
|
||||
@@ -1519,10 +1637,10 @@ class PhotoExporter:
|
||||
if not options.dry_run:
|
||||
warning_, error_ = self._write_exif_data(src, options=options)
|
||||
if warning_:
|
||||
exiftool_results.exiftool_warning.append((dest, warning_))
|
||||
exiftool_results.exiftool_warning.append((str(dest), str(warning_)))
|
||||
if error_:
|
||||
exiftool_results.exiftool_error.append((dest, error_))
|
||||
exiftool_results.error.append((dest, error_))
|
||||
exiftool_results.exiftool_error.append((str(dest), str(error_)))
|
||||
exiftool_results.error.append((str(dest), str(error_)))
|
||||
|
||||
exiftool_results.exif_updated.append(dest)
|
||||
exiftool_results.to_touch.append(dest)
|
||||
@@ -1564,7 +1682,7 @@ class PhotoExporter:
|
||||
with ExifTool(
|
||||
filepath,
|
||||
flags=options.exiftool_flags,
|
||||
exiftool=self.photo._db._exiftool_path,
|
||||
exiftool=self.photo._exiftool_path,
|
||||
) as exiftool:
|
||||
for exiftag, val in exif_info.items():
|
||||
if type(val) == list:
|
||||
@@ -1744,7 +1862,6 @@ class PhotoExporter:
|
||||
elif self.photo.ismovie:
|
||||
exif["Keys:GPSCoordinates"] = f"{lat} {lon}"
|
||||
exif["UserData:GPSCoordinates"] = f"{lat} {lon}"
|
||||
|
||||
# process date/time and timezone offset
|
||||
# Photos exports the following fields and sets modify date to creation date
|
||||
# [EXIF] Modify Date : 2020:10:30 00:00:00
|
||||
@@ -1854,7 +1971,7 @@ class PhotoExporter:
|
||||
def _get_exif_keywords(self):
|
||||
"""returns list of keywords found in the file's exif metadata"""
|
||||
keywords = []
|
||||
exif = self.photo.exiftool
|
||||
exif = exiftool_caching(self.photo)
|
||||
if exif:
|
||||
exifdict = exif.asdict()
|
||||
for field in ["IPTC:Keywords", "XMP:TagsList", "XMP:Subject"]:
|
||||
@@ -1871,7 +1988,7 @@ class PhotoExporter:
|
||||
def _get_exif_persons(self):
|
||||
"""returns list of persons found in the file's exif metadata"""
|
||||
persons = []
|
||||
exif = self.photo.exiftool
|
||||
exif = exiftool_caching(self.photo)
|
||||
if exif:
|
||||
exifdict = exif.asdict()
|
||||
try:
|
||||
@@ -1952,10 +2069,7 @@ class PhotoExporter:
|
||||
|
||||
options = options or ExportOptions()
|
||||
|
||||
xmp_template_file = (
|
||||
_XMP_TEMPLATE_NAME if not self.photo._db._beta else _XMP_TEMPLATE_NAME_BETA
|
||||
)
|
||||
xmp_template = Template(filename=os.path.join(_TEMPLATE_DIR, xmp_template_file))
|
||||
xmp_template = self._xmp_template()
|
||||
|
||||
if extension is None:
|
||||
extension = pathlib.Path(self.photo.original_filename)
|
||||
@@ -2062,6 +2176,20 @@ class PhotoExporter:
|
||||
xmp_str = "\n".join(line for line in xmp_str.split("\n") if line.strip() != "")
|
||||
return xmp_str
|
||||
|
||||
def _xmp_template(self):
|
||||
"""Return the mako template for XMP sidecar, creating it if necessary"""
|
||||
global _global_xmp_template
|
||||
if _global_xmp_template is not None:
|
||||
return _global_xmp_template
|
||||
|
||||
xmp_template_file = (
|
||||
_XMP_TEMPLATE_NAME_BETA if self.photo._db._beta else _XMP_TEMPLATE_NAME
|
||||
)
|
||||
_global_xmp_template = Template(
|
||||
filename=os.path.join(_TEMPLATE_DIR, xmp_template_file)
|
||||
)
|
||||
return _global_xmp_template
|
||||
|
||||
def _write_sidecar(self, filename, sidecar_str):
|
||||
"""write sidecar_str to filename
|
||||
used for exporting sidecar info"""
|
||||
@@ -2142,3 +2270,32 @@ def rename_jpeg_files(files, jpeg_ext, fileutil):
|
||||
else:
|
||||
new_files.append(file)
|
||||
return new_files
|
||||
|
||||
|
||||
def exiftool_caching(photo: SimpleNamespace) -> ExifToolCaching:
|
||||
"""Return ExifToolCaching object for photo
|
||||
|
||||
Args:
|
||||
photo: SimpleNamespace object with photo info
|
||||
|
||||
Returns:
|
||||
ExifToolCaching object
|
||||
"""
|
||||
try:
|
||||
return photo._exiftool_caching
|
||||
except AttributeError:
|
||||
try:
|
||||
exiftool_path = photo._exiftool_path or get_exiftool_path()
|
||||
if photo.path is not None and os.path.isfile(photo.path):
|
||||
exiftool = ExifToolCaching(photo.path, exiftool=exiftool_path)
|
||||
else:
|
||||
exiftool = None
|
||||
except FileNotFoundError:
|
||||
# get_exiftool_path raises FileNotFoundError if exiftool not found
|
||||
exiftool = None
|
||||
logging.warning(
|
||||
"exiftool not in path; download and install from https://exiftool.org/"
|
||||
)
|
||||
|
||||
photo._exiftool_caching = exiftool
|
||||
return photo._exiftool_caching
|
||||
|
||||
@@ -8,17 +8,18 @@ import contextlib
|
||||
import dataclasses
|
||||
import datetime
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import os.path
|
||||
import pathlib
|
||||
import plistlib
|
||||
import re
|
||||
from datetime import timedelta, timezone
|
||||
from functools import cached_property
|
||||
from types import SimpleNamespace
|
||||
from typing import Any, Dict, Optional
|
||||
import logging
|
||||
|
||||
import yaml
|
||||
from osxmetadata import OSXMetaData
|
||||
|
||||
import osxphotos
|
||||
|
||||
@@ -57,16 +58,22 @@ from .exiftool import ExifToolCaching, get_exiftool_path
|
||||
from .momentinfo import MomentInfo
|
||||
from .personinfo import FaceInfo, PersonInfo
|
||||
from .photoexporter import ExportOptions, PhotoExporter
|
||||
from .phototables import PhotoTables
|
||||
from .phototemplate import PhotoTemplate, RenderOptions
|
||||
from .placeinfo import PlaceInfo4, PlaceInfo5
|
||||
from .platform import assert_macos, is_macos
|
||||
from .query_builder import get_query
|
||||
from .scoreinfo import ScoreInfo
|
||||
from .searchinfo import SearchInfo
|
||||
from .text_detection import detect_text
|
||||
from .uti import get_preferred_uti_extension, get_uti_for_extension
|
||||
from .utils import _get_resource_loc, hexdigest, list_directory
|
||||
|
||||
__all__ = ["PhotoInfo", "PhotoInfoNone"]
|
||||
if is_macos:
|
||||
from osxmetadata import OSXMetaData
|
||||
|
||||
from .text_detection import detect_text
|
||||
|
||||
__all__ = ["PhotoInfo", "PhotoInfoNone", "frozen_photoinfo_factory"]
|
||||
|
||||
logger = logging.getLogger("osxphotos")
|
||||
|
||||
@@ -81,6 +88,7 @@ class PhotoInfo:
|
||||
self._uuid: str = uuid
|
||||
self._info: dict[str, Any] = info
|
||||
self._db: "osxphotos.PhotosDB" = db
|
||||
self._exiftool_path = self._db._exiftool_path
|
||||
self._verbose = self._db._verbose
|
||||
|
||||
@property
|
||||
@@ -128,8 +136,7 @@ class PhotoInfo:
|
||||
if not self.hasadjustments and self._db._db_version <= _PHOTOS_4_VERSION:
|
||||
return None
|
||||
|
||||
imagedate = self._info["lastmodifieddate"]
|
||||
if imagedate:
|
||||
if imagedate := self._info["lastmodifieddate"]:
|
||||
seconds = self._info["imageTimeZoneOffsetSeconds"] or 0
|
||||
delta = timedelta(seconds=seconds)
|
||||
tz = timezone(delta)
|
||||
@@ -166,6 +173,9 @@ class PhotoInfo:
|
||||
"""Returns candidate path for original photo on Photos >= version 5"""
|
||||
if self._info["shared"]:
|
||||
return self._path_5_shared()
|
||||
if self.syndicated and not self.saved_to_library:
|
||||
# path for "shared with you" syndicated photos that have not yet been saved to the library
|
||||
return self._path_syndication()
|
||||
return (
|
||||
os.path.join(self._info["directory"], self._info["filename"])
|
||||
if self._info["directory"].startswith("/")
|
||||
@@ -205,6 +215,21 @@ class PhotoInfo:
|
||||
filename,
|
||||
)
|
||||
|
||||
def _path_syndication(self):
|
||||
"""Return path for syndicated photo on Photos >= version 8"""
|
||||
# Photos 8+ stores syndicated photos in a separate directory
|
||||
# in ~/Photos Library.photoslibrary/scopes/syndication/originals/X/UUID.ext
|
||||
# where X is first digit of UUID
|
||||
syndication_path = "scopes/syndication/originals"
|
||||
uuid_dir = self.uuid[0]
|
||||
path = os.path.join(
|
||||
self._db._library_path,
|
||||
syndication_path,
|
||||
uuid_dir,
|
||||
self.filename,
|
||||
)
|
||||
return path if os.path.isfile(path) else None
|
||||
|
||||
def _path_4(self):
|
||||
"""Returns candidate path for original photo on Photos <= version 4"""
|
||||
if self._info["has_raw"]:
|
||||
@@ -388,6 +413,8 @@ class PhotoInfo:
|
||||
"""return path_edited_live_photo for Photos <= 4"""
|
||||
if self._db._db_version > _PHOTOS_4_VERSION:
|
||||
raise RuntimeError("Wrong database format!")
|
||||
if not self.live_photo:
|
||||
return None
|
||||
photopath = self._get_predicted_path_edited_live_photo_4()
|
||||
if photopath is not None and not os.path.isfile(photopath):
|
||||
# the heuristic failed, so try to find the file
|
||||
@@ -401,10 +428,6 @@ class PhotoInfo:
|
||||
),
|
||||
None,
|
||||
)
|
||||
if photopath is None:
|
||||
logger.debug(
|
||||
f"MISSING PATH: edited live photo file for UUID {self._uuid} does not appear to exist"
|
||||
)
|
||||
return photopath
|
||||
|
||||
def _path_edited_5_live_photo(self):
|
||||
@@ -516,39 +539,26 @@ class PhotoInfo:
|
||||
@property
|
||||
def person_info(self):
|
||||
"""list of PersonInfo objects for person in picture"""
|
||||
try:
|
||||
return self._personinfo
|
||||
except AttributeError:
|
||||
self._personinfo = [
|
||||
PersonInfo(db=self._db, pk=pk) for pk in self._info["persons"]
|
||||
]
|
||||
return self._personinfo
|
||||
return [PersonInfo(db=self._db, pk=pk) for pk in self._info["persons"]]
|
||||
|
||||
@property
|
||||
def face_info(self):
|
||||
"""list of FaceInfo objects for faces in picture"""
|
||||
try:
|
||||
return self._faceinfo
|
||||
except AttributeError:
|
||||
try:
|
||||
faces = self._db._db_faceinfo_uuid[self._uuid]
|
||||
self._faceinfo = [FaceInfo(db=self._db, pk=pk) for pk in faces]
|
||||
except KeyError:
|
||||
# no faces
|
||||
self._faceinfo = []
|
||||
return self._faceinfo
|
||||
faces = self._db._db_faceinfo_uuid[self._uuid]
|
||||
self._faceinfo = [FaceInfo(db=self._db, pk=pk) for pk in faces]
|
||||
except KeyError:
|
||||
# no faces
|
||||
self._faceinfo = []
|
||||
return self._faceinfo
|
||||
|
||||
@property
|
||||
def moment_info(self):
|
||||
"""Moment photo belongs to"""
|
||||
try:
|
||||
return self._moment
|
||||
except AttributeError:
|
||||
try:
|
||||
self._moment = MomentInfo(db=self._db, moment_pk=self._info["momentID"])
|
||||
except ValueError:
|
||||
self._moment = None
|
||||
return self._moment
|
||||
return MomentInfo(db=self._db, moment_pk=self._info["momentID"])
|
||||
except ValueError:
|
||||
return None
|
||||
|
||||
@property
|
||||
def albums(self):
|
||||
@@ -565,65 +575,41 @@ class PhotoInfo:
|
||||
@property
|
||||
def burst_albums(self):
|
||||
"""If photo is burst photo, list of albums it is contained in as well as any albums the key photo is contained in, otherwise returns self.albums"""
|
||||
try:
|
||||
return self._burst_albums
|
||||
except AttributeError:
|
||||
burst_albums = list(self.albums)
|
||||
for photo in self.burst_photos:
|
||||
if photo.burst_key:
|
||||
burst_albums.extend(photo.albums)
|
||||
self._burst_albums = list(set(burst_albums))
|
||||
return self._burst_albums
|
||||
burst_albums = list(self.albums)
|
||||
for photo in self.burst_photos:
|
||||
if photo.burst_key:
|
||||
burst_albums.extend(photo.albums)
|
||||
return list(set(burst_albums))
|
||||
|
||||
@property
|
||||
def album_info(self):
|
||||
"""list of AlbumInfo objects representing albums the photo is contained in"""
|
||||
try:
|
||||
return self._album_info
|
||||
except AttributeError:
|
||||
album_uuids = self._get_album_uuids()
|
||||
self._album_info = [
|
||||
AlbumInfo(db=self._db, uuid=album) for album in album_uuids
|
||||
]
|
||||
return self._album_info
|
||||
album_uuids = self._get_album_uuids()
|
||||
return [AlbumInfo(db=self._db, uuid=album) for album in album_uuids]
|
||||
|
||||
@property
|
||||
def burst_album_info(self):
|
||||
"""If photo is a burst photo, returns list of AlbumInfo objects representing albums the photo is contained in as well as albums the burst key photo is contained in, otherwise returns self.album_info."""
|
||||
try:
|
||||
return self._burst_album_info
|
||||
except AttributeError:
|
||||
burst_album_info = list(self.album_info)
|
||||
for photo in self.burst_photos:
|
||||
if photo.burst_key:
|
||||
burst_album_info.extend(photo.album_info)
|
||||
self._burst_album_info = list(set(burst_album_info))
|
||||
return self._burst_album_info
|
||||
burst_album_info = list(self.album_info)
|
||||
for photo in self.burst_photos:
|
||||
if photo.burst_key:
|
||||
burst_album_info.extend(photo.album_info)
|
||||
return list(set(burst_album_info))
|
||||
|
||||
@property
|
||||
def import_info(self):
|
||||
"""ImportInfo object representing import session for the photo or None if no import session"""
|
||||
try:
|
||||
return self._import_info
|
||||
except AttributeError:
|
||||
self._import_info = (
|
||||
ImportInfo(db=self._db, uuid=self._info["import_uuid"])
|
||||
if self._info["import_uuid"] is not None
|
||||
else None
|
||||
)
|
||||
return self._import_info
|
||||
return (
|
||||
ImportInfo(db=self._db, uuid=self._info["import_uuid"])
|
||||
if self._info["import_uuid"] is not None
|
||||
else None
|
||||
)
|
||||
|
||||
@property
|
||||
def project_info(self):
|
||||
"""list of AlbumInfo objects representing projects for the photo or None if no projects"""
|
||||
try:
|
||||
return self._project_info
|
||||
except AttributeError:
|
||||
project_uuids = self._get_album_uuids(project=True)
|
||||
self._project_info = [
|
||||
ProjectInfo(db=self._db, uuid=album) for album in project_uuids
|
||||
]
|
||||
return self._project_info
|
||||
project_uuids = self._get_album_uuids(project=True)
|
||||
return [ProjectInfo(db=self._db, uuid=album) for album in project_uuids]
|
||||
|
||||
@property
|
||||
def keywords(self):
|
||||
@@ -637,8 +623,7 @@ class PhotoInfo:
|
||||
# in this case, return None so result is the same as if title had never been set (which returns NULL)
|
||||
# issue #512
|
||||
title = self._info["name"]
|
||||
title = None if title == "" else title
|
||||
return title
|
||||
return None if title == "" else title
|
||||
|
||||
@property
|
||||
def uuid(self):
|
||||
@@ -665,28 +650,38 @@ class PhotoInfo:
|
||||
return self._info["hasAdjustments"] == 1
|
||||
|
||||
@property
|
||||
def adjustments(self):
|
||||
"""Returns AdjustmentsInfo class for adjustment data or None if no adjustments; Photos 5+ only"""
|
||||
def adjustments_path(self):
|
||||
"""Returns path to adjustments file or none if file doesn't exist"""
|
||||
if self._db._db_version <= _PHOTOS_4_VERSION:
|
||||
return None
|
||||
|
||||
if self.hasadjustments:
|
||||
try:
|
||||
return self._adjustmentinfo
|
||||
except AttributeError:
|
||||
library = self._db._library_path
|
||||
directory = self._uuid[0] # first char of uuid
|
||||
plist_file = (
|
||||
pathlib.Path(library)
|
||||
/ "resources"
|
||||
/ "renders"
|
||||
/ directory
|
||||
/ f"{self._uuid}.plist"
|
||||
)
|
||||
if not plist_file.is_file():
|
||||
return None
|
||||
self._adjustmentinfo = AdjustmentsInfo(plist_file)
|
||||
return self._adjustmentinfo
|
||||
if not self.hasadjustments:
|
||||
return None
|
||||
|
||||
library = self._db._library_path
|
||||
directory = self._uuid[0] # first char of uuid
|
||||
plist_file = (
|
||||
pathlib.Path(library)
|
||||
/ "resources"
|
||||
/ "renders"
|
||||
/ directory
|
||||
/ f"{self._uuid}.plist"
|
||||
)
|
||||
if not plist_file.is_file():
|
||||
return None
|
||||
return plist_file
|
||||
|
||||
@property
|
||||
def adjustments(self):
|
||||
"""Returns AdjustmentsInfo class for adjustment data or None if no adjustments; Photos 5+ only"""
|
||||
try:
|
||||
return self._adjustmentinfo
|
||||
except AttributeError:
|
||||
plist_file = self.adjustments_path
|
||||
if plist_file is None:
|
||||
return None
|
||||
self._adjustmentinfo = AdjustmentsInfo(plist_file)
|
||||
return self._adjustmentinfo
|
||||
|
||||
@property
|
||||
def external_edit(self):
|
||||
@@ -911,33 +906,14 @@ class PhotoInfo:
|
||||
|
||||
photopath = None
|
||||
if self._db._db_version <= _PHOTOS_4_VERSION:
|
||||
if self.live_photo and not self.ismissing:
|
||||
live_model_id = self._info["live_model_id"]
|
||||
if live_model_id is None:
|
||||
logger.debug(f"missing live_model_id: {self._uuid}")
|
||||
photopath = None
|
||||
else:
|
||||
folder_id, file_id, nn_id = _get_resource_loc(live_model_id)
|
||||
library_path = self._db.library_path
|
||||
photopath = os.path.join(
|
||||
library_path,
|
||||
"resources",
|
||||
"media",
|
||||
"master",
|
||||
folder_id,
|
||||
nn_id,
|
||||
f"jpegvideocomplement_{file_id}.mov",
|
||||
)
|
||||
if not os.path.isfile(photopath):
|
||||
# In testing, I've seen occasional missing movie for live photo
|
||||
# These appear to be valid -- e.g. live component hasn't been downloaded from iCloud
|
||||
# photos 4 has "isOnDisk" column we could check
|
||||
# or could do the actual check with "isfile"
|
||||
# TODO: should this be a warning or debug?
|
||||
photopath = None
|
||||
else:
|
||||
photopath = None
|
||||
return self._path_live_photo_4()
|
||||
elif self.live_photo and self.path and not self.ismissing:
|
||||
if self.shared:
|
||||
return self._path_live_photo_shared_5()
|
||||
if self.syndicated and not self.saved_to_library:
|
||||
# syndicated ("Shared with you") photos not yet saved to library
|
||||
return self._path_live_syndicated()
|
||||
|
||||
filename = pathlib.Path(self.path)
|
||||
photopath = filename.parent.joinpath(f"{filename.stem}_3.mov")
|
||||
photopath = str(photopath)
|
||||
@@ -951,8 +927,68 @@ class PhotoInfo:
|
||||
|
||||
return photopath
|
||||
|
||||
def _path_live_photo_shared_5(self):
|
||||
"""Return path for live photo for shared photos"""
|
||||
if not self.shared:
|
||||
raise ValueError(f"photo {self.uuid} is not a shared photo")
|
||||
if not self.live_photo:
|
||||
raise ValueError(f"photo {self.uuid} is not a live photo")
|
||||
|
||||
photopath = self._path_5_shared()
|
||||
if photopath:
|
||||
photopath = pathlib.Path(photopath).with_suffix(".MOV")
|
||||
if not photopath.exists():
|
||||
photopath = None
|
||||
return photopath
|
||||
|
||||
def _path_live_photo_4(self):
|
||||
"""Return path for live edited photo for Photos <= 4"""
|
||||
if self.live_photo and not self.ismissing:
|
||||
live_model_id = self._info["live_model_id"]
|
||||
if live_model_id is None:
|
||||
logger.debug(f"missing live_model_id: {self._uuid}")
|
||||
photopath = None
|
||||
else:
|
||||
folder_id, file_id, nn_id = _get_resource_loc(live_model_id)
|
||||
library_path = self._db.library_path
|
||||
photopath = os.path.join(
|
||||
library_path,
|
||||
"resources",
|
||||
"media",
|
||||
"master",
|
||||
folder_id,
|
||||
nn_id,
|
||||
f"jpegvideocomplement_{file_id}.mov",
|
||||
)
|
||||
if not os.path.isfile(photopath):
|
||||
# In testing, I've seen occasional missing movie for live photo
|
||||
# These appear to be valid -- e.g. live component hasn't been downloaded from iCloud
|
||||
# photos 4 has "isOnDisk" column we could check
|
||||
# or could do the actual check with "isfile"
|
||||
# TODO: should this be a warning or debug?
|
||||
photopath = None
|
||||
else:
|
||||
photopath = None
|
||||
return photopath
|
||||
|
||||
def _path_live_syndicated(self):
|
||||
"""Return path for live syndicated photo on Photos >= version 8"""
|
||||
# Photos 8+ stores live syndicated photos in a separate directory
|
||||
# in ~/Photos Library.photoslibrary/scopes/syndication/originals/X/UUID_3.mov
|
||||
# where X is first digit of UUID
|
||||
syndication_path = "scopes/syndication/originals"
|
||||
uuid_dir = self.uuid[0]
|
||||
filename = f"{pathlib.Path(self.filename).stem}_3.mov"
|
||||
live_photo = os.path.join(
|
||||
self._db._library_path,
|
||||
syndication_path,
|
||||
uuid_dir,
|
||||
filename,
|
||||
)
|
||||
return live_photo if os.path.isfile(live_photo) else None
|
||||
|
||||
@cached_property
|
||||
def path_derivatives(self):
|
||||
def path_derivatives(self) -> list[str]:
|
||||
"""Return any derivative (preview) images associated with the photo as a list of paths, sorted by file size (largest first)"""
|
||||
if self._db._db_version <= _PHOTOS_4_VERSION:
|
||||
return self._path_derivatives_4()
|
||||
@@ -961,24 +997,36 @@ class PhotoInfo:
|
||||
return self._path_derivatives_5_shared()
|
||||
|
||||
directory = self._uuid[0] # first char of uuid
|
||||
derivative_path = (
|
||||
pathlib.Path(self._db._library_path) / f"resources/derivatives/{directory}"
|
||||
)
|
||||
if self.syndicated and not self.saved_to_library:
|
||||
# syndicated ("Shared with you") photos not yet saved to library
|
||||
derivative_path = "scopes/syndication/resources/derivatives"
|
||||
thumb_path = (
|
||||
f"{derivative_path}/masters/{directory}/{self.uuid}_4_5005_c.jpeg"
|
||||
)
|
||||
else:
|
||||
derivative_path = f"resources/derivatives/{directory}"
|
||||
thumb_path = (
|
||||
f"resources/derivatives/masters/{directory}/{self.uuid}_4_5005_c.jpeg"
|
||||
)
|
||||
|
||||
derivative_path = pathlib.Path(self._db._library_path).joinpath(derivative_path)
|
||||
thumb_path = pathlib.Path(self._db._library_path).joinpath(thumb_path)
|
||||
|
||||
# find all files that start with uuid in derivative path
|
||||
files = list(derivative_path.glob(f"{self.uuid}*.*"))
|
||||
|
||||
# previews may be missing from derivatives path
|
||||
# there are what appear to be low res thumbnails in the "masters" subfolder
|
||||
thumb_path = (
|
||||
pathlib.Path(self._db._library_path)
|
||||
/ f"resources/derivatives/masters/{directory}/{self.uuid}_4_5005_c.jpeg"
|
||||
)
|
||||
if thumb_path.exists():
|
||||
files.append(thumb_path)
|
||||
|
||||
# sort by file size, largest first
|
||||
files = sorted(files, reverse=True, key=lambda f: f.stat().st_size)
|
||||
|
||||
# return list of filename but skip .THM files (these are actually low-res thumbnails in JPEG format but with .THM extension)
|
||||
derivatives = [str(filename) for filename in files if filename.suffix != ".THM"]
|
||||
if self.isphoto and len(derivatives) > 1 and derivatives[0].endswith(".mov"):
|
||||
# ensure .mov is first in list as poster image could be larger than the movie preview
|
||||
derivatives[1], derivatives[0] = derivatives[0], derivatives[1]
|
||||
|
||||
return derivatives
|
||||
@@ -1198,7 +1246,6 @@ class PhotoInfo:
|
||||
"""
|
||||
|
||||
if self._db._db_version <= _PHOTOS_4_VERSION:
|
||||
logger.debug(f"score not implemented for this database version")
|
||||
return None
|
||||
|
||||
try:
|
||||
@@ -1298,6 +1345,38 @@ class PhotoInfo:
|
||||
self._search_info_normalized = SearchInfo(self, normalized=True)
|
||||
return self._search_info_normalized
|
||||
|
||||
@cached_property
|
||||
def syndicated(self) -> bool | None:
|
||||
"""Return true if photo was shared via syndication (e.g. via Messages, etc.);
|
||||
these are photos that appear in "Shared with you" album.
|
||||
Photos 8+ only; returns None if not Photos 8+.
|
||||
"""
|
||||
if self._db.photos_version < 8:
|
||||
return None
|
||||
|
||||
try:
|
||||
return (
|
||||
self._db._db_syndication_uuid[self.uuid]["syndication_identifier"]
|
||||
is not None
|
||||
)
|
||||
except KeyError:
|
||||
return False
|
||||
|
||||
@cached_property
|
||||
def saved_to_library(self) -> bool | None:
|
||||
"""Return True if syndicated photo has been saved to library;
|
||||
returns False if photo is not syndicated or has not been saved to the library.
|
||||
Returns None if not Photos 8+.
|
||||
Syndicated photos are photos that appear in "Shared with you" album; Photos 8+ only.
|
||||
"""
|
||||
if self._db.photos_version < 8:
|
||||
return None
|
||||
|
||||
try:
|
||||
return self._db._db_syndication_uuid[self.uuid]["syndication_history"] != 0
|
||||
except KeyError:
|
||||
return False
|
||||
|
||||
@property
|
||||
def labels(self):
|
||||
"""returns list of labels applied to photo by Photos image categorization
|
||||
@@ -1344,7 +1423,6 @@ class PhotoInfo:
|
||||
"""
|
||||
|
||||
if self._db._db_version <= _PHOTOS_4_VERSION:
|
||||
logger.debug(f"exif_info not implemented for this database version")
|
||||
return None
|
||||
|
||||
try:
|
||||
@@ -1427,11 +1505,14 @@ class PhotoInfo:
|
||||
def hexdigest(self):
|
||||
"""Returns a unique digest of the photo's properties and metadata;
|
||||
useful for detecting changes in any property/metadata of the photo"""
|
||||
return hexdigest(self.json())
|
||||
return hexdigest(self._json_hexdigest())
|
||||
|
||||
@cached_property
|
||||
def cloud_metadata(self) -> Dict:
|
||||
"""Returns contents of ZCLOUDMASTERMEDIAMETADATA as dict"""
|
||||
def cloud_metadata(self) -> dict[Any, Any]:
|
||||
"""Returns contents of ZCLOUDMASTERMEDIAMETADATA as dict; Photos 5+ only"""
|
||||
if self._db._db_version <= _PHOTOS_4_VERSION:
|
||||
return {}
|
||||
|
||||
# This is a large blob of data so don't load it unless requested
|
||||
asset_table = _DB_TABLE_NAMES[self._db._photos_ver]["ASSET"]
|
||||
sql_cloud_metadata = f"""
|
||||
@@ -1442,10 +1523,6 @@ class PhotoInfo:
|
||||
WHERE {asset_table}.ZUUID = ?
|
||||
"""
|
||||
|
||||
if self._db._db_version <= _PHOTOS_4_VERSION:
|
||||
logger.debug(f"cloud_metadata not implemented for this database version")
|
||||
return {}
|
||||
|
||||
_, cursor = self._db.get_db_connection()
|
||||
metadata = {}
|
||||
if results := cursor.execute(sql_cloud_metadata, (self.uuid,)).fetchone():
|
||||
@@ -1500,6 +1577,8 @@ class PhotoInfo:
|
||||
|
||||
def _detected_text(self):
|
||||
"""detect text in photo, either from cached extended attribute or by attempting text detection"""
|
||||
assert_macos()
|
||||
|
||||
path = (
|
||||
self.path_edited if self.hasadjustments and self.path_edited else self.path
|
||||
)
|
||||
@@ -1779,96 +1858,188 @@ class PhotoInfo:
|
||||
}
|
||||
return yaml.dump(info, sort_keys=False)
|
||||
|
||||
def asdict(self):
|
||||
"""return dict representation"""
|
||||
def asdict(self, shallow: bool = True) -> dict[str, Any]:
|
||||
"""Return dict representation of PhotoInfo object.
|
||||
|
||||
Args:
|
||||
shallow: if True, return shallow representation (does not contain folder_info, person_info, etc.)
|
||||
|
||||
Returns:
|
||||
dict representation of PhotoInfo object
|
||||
|
||||
Note:
|
||||
The shallow representation is used internally by export as it contains only the subset of data needed for export.
|
||||
"""
|
||||
|
||||
comments = [comment.asdict() for comment in self.comments]
|
||||
exif_info = dataclasses.asdict(self.exif_info) if self.exif_info else {}
|
||||
face_info = [face.asdict() for face in self.face_info]
|
||||
folders = {album.title: album.folder_names for album in self.album_info}
|
||||
exif = dataclasses.asdict(self.exif_info) if self.exif_info else {}
|
||||
likes = [like.asdict() for like in self.likes]
|
||||
place = self.place.asdict() if self.place else {}
|
||||
score = dataclasses.asdict(self.score) if self.score else {}
|
||||
comments = [comment.asdict() for comment in self.comments]
|
||||
likes = [like.asdict() for like in self.likes]
|
||||
faces = [face.asdict() for face in self.face_info]
|
||||
search_info = self.search_info.asdict() if self.search_info else {}
|
||||
|
||||
return {
|
||||
"library": self._db._library_path,
|
||||
"uuid": self.uuid,
|
||||
"filename": self.filename,
|
||||
"original_filename": self.original_filename,
|
||||
"date": self.date,
|
||||
"description": self.description,
|
||||
"title": self.title,
|
||||
"keywords": self.keywords,
|
||||
"labels": self.labels,
|
||||
"keywords": self.keywords,
|
||||
dict_data = {
|
||||
"albums": self.albums,
|
||||
"folders": folders,
|
||||
"persons": self.persons,
|
||||
"faces": faces,
|
||||
"path": self.path,
|
||||
"ismissing": self.ismissing,
|
||||
"hasadjustments": self.hasadjustments,
|
||||
"external_edit": self.external_edit,
|
||||
"favorite": self.favorite,
|
||||
"hidden": self.hidden,
|
||||
"latitude": self._latitude,
|
||||
"longitude": self._longitude,
|
||||
"path_edited": self.path_edited,
|
||||
"shared": self.shared,
|
||||
"isphoto": self.isphoto,
|
||||
"ismovie": self.ismovie,
|
||||
"uti": self.uti,
|
||||
"uti_original": self.uti_original,
|
||||
"burst": self.burst,
|
||||
"live_photo": self.live_photo,
|
||||
"path_live_photo": self.path_live_photo,
|
||||
"iscloudasset": self.iscloudasset,
|
||||
"incloud": self.incloud,
|
||||
"isreference": self.isreference,
|
||||
"date_modified": self.date_modified,
|
||||
"portrait": self.portrait,
|
||||
"screenshot": self.screenshot,
|
||||
"slow_mo": self.slow_mo,
|
||||
"time_lapse": self.time_lapse,
|
||||
"hdr": self.hdr,
|
||||
"selfie": self.selfie,
|
||||
"panorama": self.panorama,
|
||||
"has_raw": self.has_raw,
|
||||
"israw": self.israw,
|
||||
"raw_original": self.raw_original,
|
||||
"uti_raw": self.uti_raw,
|
||||
"path_raw": self.path_raw,
|
||||
"place": place,
|
||||
"exif": exif,
|
||||
"score": score,
|
||||
"intrash": self.intrash,
|
||||
"height": self.height,
|
||||
"width": self.width,
|
||||
"orientation": self.orientation,
|
||||
"original_height": self.original_height,
|
||||
"original_width": self.original_width,
|
||||
"original_orientation": self.original_orientation,
|
||||
"original_filesize": self.original_filesize,
|
||||
"comments": comments,
|
||||
"likes": likes,
|
||||
"search_info": search_info,
|
||||
"fingerprint": self.fingerprint,
|
||||
"cloud_guid": self.cloud_guid,
|
||||
"cloud_owner_hashed_id": self.cloud_owner_hashed_id,
|
||||
"comments": comments,
|
||||
"date_added": self.date_added,
|
||||
"date_modified": self.date_modified,
|
||||
"date_trashed": self.date_trashed,
|
||||
"date": self.date,
|
||||
"description": self.description,
|
||||
"exif_info": exif_info,
|
||||
"external_edit": self.external_edit,
|
||||
"face_info": face_info,
|
||||
"favorite": self.favorite,
|
||||
"filename": self.filename,
|
||||
"fingerprint": self.fingerprint,
|
||||
"folders": folders,
|
||||
"has_raw": self.has_raw,
|
||||
"hasadjustments": self.hasadjustments,
|
||||
"hdr": self.hdr,
|
||||
"height": self.height,
|
||||
"hidden": self.hidden,
|
||||
"incloud": self.incloud,
|
||||
"intrash": self.intrash,
|
||||
"iscloudasset": self.iscloudasset,
|
||||
"ismissing": self.ismissing,
|
||||
"ismovie": self.ismovie,
|
||||
"isphoto": self.isphoto,
|
||||
"israw": self.israw,
|
||||
"isreference": self.isreference,
|
||||
"keywords": self.keywords,
|
||||
"labels": self.labels,
|
||||
"latitude": self._latitude,
|
||||
"library": self._db._library_path,
|
||||
"likes": likes,
|
||||
"live_photo": self.live_photo,
|
||||
"location": self.location,
|
||||
"longitude": self._longitude,
|
||||
"orientation": self.orientation,
|
||||
"original_filename": self.original_filename,
|
||||
"original_filesize": self.original_filesize,
|
||||
"original_height": self.original_height,
|
||||
"original_orientation": self.original_orientation,
|
||||
"original_width": self.original_width,
|
||||
"owner": self.owner,
|
||||
"panorama": self.panorama,
|
||||
"path_edited_live_photo": self.path_edited_live_photo,
|
||||
"path_edited": self.path_edited,
|
||||
"path_live_photo": self.path_live_photo,
|
||||
"path_raw": self.path_raw,
|
||||
"path": self.path,
|
||||
"persons": self.persons,
|
||||
"place": place,
|
||||
"portrait": self.portrait,
|
||||
"raw_original": self.raw_original,
|
||||
"score": score,
|
||||
"screenshot": self.screenshot,
|
||||
"selfie": self.selfie,
|
||||
"shared": self.shared,
|
||||
"slow_mo": self.slow_mo,
|
||||
"time_lapse": self.time_lapse,
|
||||
"title": self.title,
|
||||
"tzoffset": self.tzoffset,
|
||||
"uti_edited": self.uti_edited,
|
||||
"uti_original": self.uti_original,
|
||||
"uti_raw": self.uti_raw,
|
||||
"uti": self.uti,
|
||||
"uuid": self.uuid,
|
||||
"visible": self.visible,
|
||||
"width": self.width,
|
||||
}
|
||||
|
||||
def json(self):
|
||||
"""Return JSON representation"""
|
||||
# non-shallow keys
|
||||
if not shallow:
|
||||
dict_data["album_info"] = [album.asdict() for album in self.album_info]
|
||||
dict_data["path_derivatives"] = self.path_derivatives
|
||||
dict_data["adjustments"] = (
|
||||
self.adjustments.asdict() if self.adjustments else {}
|
||||
)
|
||||
dict_data["burst_album_info"] = [a.asdict() for a in self.burst_album_info]
|
||||
dict_data["burst_albums"] = self.burst_albums
|
||||
dict_data["burst_default_pick"] = self.burst_default_pick
|
||||
dict_data["burst_key"] = self.burst_key
|
||||
dict_data["burst_photos"] = [p.uuid for p in self.burst_photos]
|
||||
dict_data["burst_selected"] = self.burst_selected
|
||||
dict_data["cloud_metadata"] = self.cloud_metadata
|
||||
dict_data["import_info"] = (
|
||||
self.import_info.asdict() if self.import_info else {}
|
||||
)
|
||||
dict_data["labels_normalized"] = self.labels_normalized
|
||||
dict_data["person_info"] = [p.asdict() for p in self.person_info]
|
||||
dict_data["project_info"] = [p.asdict() for p in self.project_info]
|
||||
dict_data["search_info"] = (
|
||||
self.search_info.asdict() if self.search_info else {}
|
||||
)
|
||||
dict_data["search_info_normalized"] = (
|
||||
self.search_info_normalized.asdict()
|
||||
if self.search_info_normalized
|
||||
else {}
|
||||
)
|
||||
|
||||
return dict_data
|
||||
|
||||
def json(self, indent: int | None = None, shallow: bool = True) -> str:
|
||||
"""Return JSON representation
|
||||
|
||||
Args:
|
||||
indent: indent level for JSON, if None, no indent
|
||||
shallow: if True, return shallow JSON representation (does not contain folder_info, person_info, etc.)
|
||||
|
||||
Returns:
|
||||
JSON string
|
||||
|
||||
Note:
|
||||
The shallow representation is used internally by export as it contains only the subset of data needed for export.
|
||||
"""
|
||||
|
||||
def default(o):
|
||||
if isinstance(o, (datetime.date, datetime.datetime)):
|
||||
return o.isoformat()
|
||||
|
||||
dict_data = self.asdict()
|
||||
dict_data = self.asdict(shallow=True) if shallow else self.asdict(shallow=False)
|
||||
|
||||
for k, v in dict_data.items():
|
||||
# sort lists such as keywords so JSON is consistent
|
||||
# but do not sort certain items like location
|
||||
if k in ["location"]:
|
||||
continue
|
||||
if v and isinstance(v, (list, tuple)) and not isinstance(v[0], dict):
|
||||
dict_data[k] = sorted(v)
|
||||
dict_data[k] = sorted(v, key=lambda v: v if v is not None else "")
|
||||
return json.dumps(dict_data, sort_keys=True, default=default, indent=indent)
|
||||
|
||||
def tables(self) -> PhotoTables:
|
||||
"""Return PhotoTables object to provide access database tables associated with this photo (Photos 5+)"""
|
||||
return None if self._db._photos_ver < 5 else PhotoTables(self)
|
||||
|
||||
def _json_hexdigest(self):
|
||||
"""JSON for use by hexdigest()"""
|
||||
|
||||
# This differs from json() because hexdigest must not change if metadata changed
|
||||
# With json(), sort order of lists of dicts is not consistent but these aren't needed
|
||||
# for computing hexdigest so we can ignore them
|
||||
# also don't use visible because it changes based on Photos UI state
|
||||
|
||||
def default(o):
|
||||
if isinstance(o, (datetime.date, datetime.datetime)):
|
||||
return o.isoformat()
|
||||
|
||||
dict_data = self.asdict(shallow=True)
|
||||
|
||||
for k in ["face_info", "visible"]:
|
||||
del dict_data[k]
|
||||
|
||||
for k, v in dict_data.items():
|
||||
# sort lists such as keywords so JSON is consistent
|
||||
# but do not sort certain items like location
|
||||
if k in ["location"]:
|
||||
continue
|
||||
if v and isinstance(v, (list, tuple)) and not isinstance(v[0], dict):
|
||||
dict_data[k] = sorted(v, key=lambda v: v if v is not None else "")
|
||||
return json.dumps(dict_data, sort_keys=True, default=default)
|
||||
|
||||
def __eq__(self, other):
|
||||
@@ -1893,10 +2064,111 @@ class PhotoInfo:
|
||||
|
||||
|
||||
class PhotoInfoNone:
|
||||
"""mock class that returns None for all attributes"""
|
||||
"""Mock class that returns None for all attributes"""
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def __getattribute__(self, name):
|
||||
return None
|
||||
|
||||
|
||||
def frozen_photoinfo_factory(photo: PhotoInfo) -> SimpleNamespace:
|
||||
"""Return a frozen SimpleNamespace object for a PhotoInfo object"""
|
||||
photo_json = photo.json()
|
||||
|
||||
def _object_hook(d: dict[Any, Any]):
|
||||
if not d:
|
||||
return d
|
||||
|
||||
# if d key matches a ISO 8601 datetime ('2023-03-24T06:46:57.690786', '2019-07-04T16:24:01-07:00', '2019-07-04T16:24:01+07:00'), convert to datetime
|
||||
# fromisoformat will also handle dates with timezone offset in form +0700, etc.
|
||||
for k, v in d.items():
|
||||
if isinstance(v, str) and re.match(
|
||||
r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[.]?\d*[+-]?\d{2}[:]?\d{2}?", v
|
||||
):
|
||||
d[k] = datetime.datetime.fromisoformat(v)
|
||||
return SimpleNamespace(**d)
|
||||
|
||||
frozen = json.loads(photo_json, object_hook=lambda d: _object_hook(d))
|
||||
|
||||
# add on json() method to frozen object
|
||||
def _json(*args):
|
||||
return photo_json
|
||||
|
||||
frozen.json = _json
|
||||
|
||||
# add hexdigest property to frozen object
|
||||
frozen.hexdigest = photo.hexdigest
|
||||
|
||||
def detected_text(confidence_threshold=TEXT_DETECTION_CONFIDENCE_THRESHOLD):
|
||||
"""Detects text in photo and returns lists of results as (detected text, confidence)
|
||||
|
||||
confidence_threshold: float between 0.0 and 1.0. If text detection confidence is below this threshold,
|
||||
text will not be returned. Default is TEXT_DETECTION_CONFIDENCE_THRESHOLD
|
||||
|
||||
If photo is edited, uses the edited photo, otherwise the original; falls back to the preview image if neither edited or original is available
|
||||
|
||||
Returns: list of (detected text, confidence) tuples
|
||||
"""
|
||||
|
||||
try:
|
||||
return frozen._detected_text_cache[confidence_threshold]
|
||||
except (AttributeError, KeyError) as e:
|
||||
if isinstance(e, AttributeError):
|
||||
frozen._detected_text_cache = {}
|
||||
|
||||
try:
|
||||
detected_text = frozen._detected_text()
|
||||
except Exception as e:
|
||||
logging.warning(f"Error detecting text in photo {frozen.uuid}: {e}")
|
||||
detected_text = []
|
||||
|
||||
frozen._detected_text_cache[confidence_threshold] = [
|
||||
(text, confidence)
|
||||
for text, confidence in detected_text
|
||||
if confidence >= confidence_threshold
|
||||
]
|
||||
return frozen._detected_text_cache[confidence_threshold]
|
||||
|
||||
def _detected_text():
|
||||
"""detect text in photo, either from cached extended attribute or by attempting text detection"""
|
||||
path = (
|
||||
frozen.path_edited
|
||||
if frozen.hasadjustments and frozen.path_edited
|
||||
else frozen.path
|
||||
)
|
||||
path = path or frozen.path_derivatives[0] if frozen.path_derivatives else None
|
||||
if not path:
|
||||
return []
|
||||
|
||||
md = OSXMetaData(path)
|
||||
try:
|
||||
|
||||
def decoder(val):
|
||||
"""Decode value from JSON"""
|
||||
return json.loads(val.decode("utf-8"))
|
||||
|
||||
detected_text = md.get_xattr(
|
||||
"osxphotos.metadata:detected_text", decode=decoder
|
||||
)
|
||||
except KeyError:
|
||||
detected_text = None
|
||||
if detected_text is None:
|
||||
orientation = frozen.orientation or None
|
||||
detected_text = detect_text(path, orientation)
|
||||
|
||||
def encoder(obj):
|
||||
"""Encode value as JSON"""
|
||||
val = json.dumps(obj)
|
||||
return val.encode("utf-8")
|
||||
|
||||
md.set_xattr(
|
||||
"osxphotos.metadata:detected_text", detected_text, encode=encoder
|
||||
)
|
||||
return detected_text
|
||||
|
||||
frozen.detected_text = detected_text
|
||||
frozen._detected_text = _detected_text
|
||||
|
||||
return frozen
|
||||
|
||||
@@ -19,9 +19,14 @@
|
||||
|
||||
import copy
|
||||
import pathlib
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
|
||||
from .platform import get_macos_version
|
||||
|
||||
assert sys.platform == "darwin"
|
||||
|
||||
import AVFoundation
|
||||
import CoreServices
|
||||
import Foundation
|
||||
@@ -34,7 +39,7 @@ from wurlitzer import pipes
|
||||
|
||||
from .fileutil import FileUtil
|
||||
from .uti import get_preferred_uti_extension
|
||||
from .utils import get_macos_version, increment_filename
|
||||
from .utils import increment_filename
|
||||
|
||||
__all__ = [
|
||||
"NSURL_to_path",
|
||||
@@ -84,6 +89,7 @@ PHOTOKIT_NOTIFICATION_FINISHED_REQUEST = "PyPhotoKitNotificationFinishedRequest"
|
||||
# minimum amount to sleep while waiting for export
|
||||
MIN_SLEEP = 0.015
|
||||
|
||||
|
||||
### utility functions
|
||||
def NSURL_to_path(url):
|
||||
"""Convert URL string as represented by NSURL to a path string"""
|
||||
@@ -626,7 +632,8 @@ class PhotoAsset:
|
||||
|
||||
def handler(imageData, dataUTI, orientation, info):
|
||||
"""result handler for requestImageDataAndOrientationForAsset_options_resultHandler_
|
||||
all returned by the request is set as properties of nonlocal data (Fetchdata object)"""
|
||||
all returned by the request is set as properties of nonlocal data (Fetchdata object)
|
||||
"""
|
||||
|
||||
nonlocal requestdata
|
||||
|
||||
@@ -673,7 +680,8 @@ class PhotoAsset:
|
||||
|
||||
def handler(data):
|
||||
"""result handler for requestImageDataAndOrientationForAsset_options_resultHandler_
|
||||
all returned by the request is set as properties of nonlocal data (Fetchdata object)"""
|
||||
all returned by the request is set as properties of nonlocal data (Fetchdata object)
|
||||
"""
|
||||
|
||||
nonlocal requestdata
|
||||
|
||||
@@ -710,7 +718,8 @@ class PhotoAsset:
|
||||
|
||||
def handler(imageData, dataUTI, orientation, info):
|
||||
"""result handler for requestImageDataAndOrientationForAsset_options_resultHandler_
|
||||
all returned by the request is set as properties of nonlocal data (Fetchdata object)"""
|
||||
all returned by the request is set as properties of nonlocal data (Fetchdata object)
|
||||
"""
|
||||
|
||||
nonlocal data
|
||||
|
||||
|
||||
@@ -1,30 +1,54 @@
|
||||
""" PhotosAlbum class to create an album in default Photos library and add photos to it """
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import unicodedata
|
||||
from typing import List, Optional
|
||||
|
||||
import photoscript
|
||||
from more_itertools import chunked
|
||||
from photoscript import Album, Folder, Photo, PhotosLibrary
|
||||
|
||||
from .photoinfo import PhotoInfo
|
||||
from .platform import assert_macos
|
||||
from .utils import noop, pluralize
|
||||
|
||||
assert_macos()
|
||||
|
||||
import photoscript
|
||||
from photoscript import Album, Folder, Photo, PhotosLibrary
|
||||
|
||||
__all__ = ["PhotosAlbum", "PhotosAlbumPhotoScript"]
|
||||
|
||||
|
||||
def get_unicode_variants(s: str) -> list[str]:
|
||||
"""Get all unicode variants of string"""
|
||||
variants = []
|
||||
for form in ["NFC", "NFD", "NFKC", "NFKD"]:
|
||||
normalized = unicodedata.normalize(form, s)
|
||||
variants.append(normalized)
|
||||
return variants
|
||||
|
||||
|
||||
def folder_by_path(folders: List[str], verbose: Optional[callable] = None) -> Folder:
|
||||
"""Get (and create if necessary) a Photos Folder by path (passed as list of folder names)"""
|
||||
library = PhotosLibrary()
|
||||
verbose = verbose or noop
|
||||
top_folder_name = folders.pop(0)
|
||||
top_folder = library.folder(top_folder_name, top_level=True)
|
||||
if not top_folder:
|
||||
|
||||
for folder_variant in get_unicode_variants(top_folder_name):
|
||||
top_folder = library.folder(folder_variant, top_level=True)
|
||||
if top_folder is not None:
|
||||
break
|
||||
else:
|
||||
verbose(f"Creating folder '{top_folder_name}'")
|
||||
top_folder = library.create_folder(top_folder_name)
|
||||
|
||||
current_folder = top_folder
|
||||
for folder_name in folders:
|
||||
folder = current_folder.folder(folder_name)
|
||||
if not folder:
|
||||
for folder_variant in get_unicode_variants(folder_name):
|
||||
folder = current_folder.folder(folder_variant)
|
||||
if folder is not None:
|
||||
break
|
||||
else:
|
||||
verbose(f"Creating folder '{folder_name}'")
|
||||
folder = current_folder.create_folder(folder_name)
|
||||
current_folder = folder
|
||||
@@ -41,15 +65,24 @@ def album_by_path(
|
||||
# have folders
|
||||
album_name = folders_album.pop()
|
||||
folder = folder_by_path(folders_album, verbose)
|
||||
album = folder.album(album_name)
|
||||
if album is None:
|
||||
for album_variant in get_unicode_variants(album_name):
|
||||
# Get album if it exists
|
||||
# need to check every unicode variant to avoid creating duplicate albums with same visual representation (#1085)
|
||||
album = folder.album(album_variant)
|
||||
if album is not None:
|
||||
break
|
||||
else:
|
||||
verbose(f"Creating album '{album_name}'")
|
||||
album = folder.create_album(album_name)
|
||||
else:
|
||||
# only have album name
|
||||
album_name = folders_album[0]
|
||||
album = library.album(album_name, top_level=True)
|
||||
if album is None:
|
||||
for album_variant in get_unicode_variants(album_name):
|
||||
album = library.album(album_variant, top_level=True)
|
||||
if album is not None:
|
||||
break
|
||||
else:
|
||||
# album doesn't exist, create it
|
||||
verbose(f"Creating album '{album_name}'")
|
||||
album = library.create_album(album_name)
|
||||
|
||||
|
||||
@@ -4,6 +4,10 @@ from __future__ import annotations
|
||||
|
||||
import sqlite3
|
||||
|
||||
from .platform import assert_macos
|
||||
|
||||
assert_macos()
|
||||
|
||||
import photoscript
|
||||
|
||||
from ._constants import _DB_TABLE_NAMES, _PHOTOS_5_ALBUM_KIND, _PHOTOS_5_FOLDER_KIND
|
||||
|
||||
@@ -4,4 +4,4 @@ Processes a Photos.app library database to extract information about photos
|
||||
"""
|
||||
|
||||
from .photosdb import PhotosDB
|
||||
from .photosdb_utils import get_db_version, get_db_model_version, get_model_version
|
||||
from .photosdb_utils import get_db_model_version, get_db_version, get_model_version
|
||||
|
||||
@@ -6,8 +6,8 @@ import datetime
|
||||
from dataclasses import dataclass
|
||||
|
||||
from .._constants import _DB_TABLE_NAMES, _PHOTOS_4_VERSION, TIME_DELTA
|
||||
from ..utils import normalize_unicode
|
||||
from ..sqlite_utils import sqlite_open_ro
|
||||
from ..unicode import normalize_unicode
|
||||
|
||||
|
||||
def _process_comments(self):
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user