RhetTbull / osxphotos

Python app to work with pictures and associated metadata from Apple Photos on macOS. Also includes a package to provide programmatic access to the Photos library, pictures, and metadata.
MIT License
2.17k stars 100 forks source link

Add software or app property to SearchInfo #937

Closed RhetTbull closed 1 year ago

RhetTbull commented 1 year ago
  On iOS and in the Photos app I can search for the app that created the photo. Is there any way to query this after the export?

This software is amazing, by the way. I have 53,186 assets in my library and this is giving me a way to liberate them 👏

image

Originally posted by @djbeadle in https://github.com/RhetTbull/osxphotos/discussions/936

RhetTbull commented 1 year ago

On Ventura I believe this is key=2200 in the psi.db categories table, accessible through:

PhotosDB()._db_searchinfo_categories[2200]

RhetTbull commented 1 year ago

These are the categories that I've been able to decipher from the psi.sqlite which contains search metadata for each. photo. These values are valid on Ventura only:

1: PLACE_NAME
2: STREET
3: NEIGHBORHOOD
4: LOCALITY_4
6: SUB_LOCALITY_6
5: CITY
7: REGION_NAMES
8: LOCALITY_8
9: NAMED_AREA
10: STATE
11: STATE_ABBREVIATION
12: COUNTRY
14: BODY_OF_WATER
1000: HOME
1001: WORK
1700: VENUE
1701: VENUE_TYPE
PHOTO_TYPE_VIDEO = 1901
PHOTO_TYPE_SELFIES = 1915
PHOTO_TYPE_LIVE = 1906
PHOTO_TYPE_PORTRAIT = 1914
PHOTO_TYPE_FAVORITES = 2000
PHOTO_TYPE_PANORAMA = 1908
PHOTO_TYPE_TIMELAPSE = 1909
PHOTO_TYPE_SLOMO = 1905
PHOTO_TYPE_BURSTS = 1913
PHOTO_TYPE_SCREENSHOT = 1907
PHOTO_TYPE_ANIMATED = 1912
PHOTO_TYPE_RAW = 1902
1500: LABEL
1100: MONTH
1101: YEAR
1103: HOLIDAY
1104: SEASON
1200: KEYWORDS
1201: TITLE
1202: DESCRIPTION
1203: DETECTED_TEXT
1300: PERSON
1600: ACTIVITY
2100: PHOTO_NAME
2300: CAMERA

New categories I've discovered working on this issue:

2200: PHOTO_SOUCE (app that produced the photo), e.g. Messages, Twitter, Instagram, etc. value is a list, e.g. ["Messages"]
1900: is always "Photos" or null, not sure about this one
RhetTbull commented 1 year ago

@all-contributors please add @djbeadle for ideas

allcontributors[bot] commented 1 year ago

@RhetTbull

I've put up a pull request to add @djbeadle! :tada:

RhetTbull commented 1 year ago

This is now include in v0.56.4 as PhotoInfo.SearchInfo.source. You can filter photos by source with a --query-eval:

osxphotos query --query-eval "photo.search_info.source == 'Safari'"