Moved util scripts to utils
This commit is contained in:
39
utils/check_uuid.py
Normal file
39
utils/check_uuid.py
Normal file
@@ -0,0 +1,39 @@
|
||||
""" Use with output file created by dump_photo_info.scpt to check ouput
|
||||
of osxphotos vs what Photos reports """
|
||||
|
||||
import csv
|
||||
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB()
|
||||
photos = photosdb.photos(movies=True)
|
||||
photos_uuid = {p.uuid: p for p in photos}
|
||||
got_uuid = {}
|
||||
|
||||
inputfile = "photoslib1.txt"
|
||||
|
||||
# check that each uuid in the library is in photos
|
||||
with open(inputfile) as csv_file:
|
||||
csv_reader = csv.reader(csv_file, delimiter=",")
|
||||
for row in csv_reader:
|
||||
uuid, *_ = row[0].split("/")
|
||||
fname = row[1]
|
||||
if uuid in got_uuid:
|
||||
print(f"WARNING: uuid already in got_dict: {uuid} {fname}")
|
||||
got_uuid[uuid] = fname
|
||||
|
||||
if uuid not in photos_uuid:
|
||||
print(f"missing uuid not in photos_uuid: {uuid}, {fname}")
|
||||
|
||||
# check for uuids in photos not in the library
|
||||
shared = 0
|
||||
not_shared = 0
|
||||
for uuid in photos_uuid:
|
||||
if uuid not in got_uuid:
|
||||
if photos_uuid[uuid].shared:
|
||||
shared += 1
|
||||
else:
|
||||
not_shared += 1
|
||||
print(f"missing uuid not in library:\n{photos_uuid[uuid].json()}")
|
||||
|
||||
print(f"shared: {shared}, not_shared: {not_shared}")
|
||||
41
utils/dump_photo_info.applescript
Normal file
41
utils/dump_photo_info.applescript
Normal file
@@ -0,0 +1,41 @@
|
||||
-- Dumps UUID and other info about every photo in Photos.app to a tet file (see theFile below)
|
||||
-- Use output of this script with check_uuid.py to help with debugging differences in Photos and osxphoto
|
||||
|
||||
tell application "Photos"
|
||||
activate
|
||||
|
||||
set theDelimiter to ";"
|
||||
set theBackup to AppleScript's text item delimiters
|
||||
|
||||
-- Set the new delimiter
|
||||
set AppleScript's text item delimiters to theDelimiter
|
||||
|
||||
set theFile to (((path to desktop folder) as string) & "photoslib1.txt")
|
||||
set theOpenedFile to open for access file theFile with write permission
|
||||
|
||||
set results to selection
|
||||
repeat with _item in results
|
||||
|
||||
|
||||
set _keywords to keywords of _item
|
||||
if _keywords is not {} then
|
||||
_keywords = (_keywords as text)
|
||||
else
|
||||
_keywords = "none"
|
||||
end if
|
||||
|
||||
set _str to (((((id of _item) as text) & ", " & (filename of _item) as text) & ", " & _keywords & ", " & (name of _item) as text) & ", " & (description of _item) as text) & "
|
||||
"
|
||||
-- display dialog _str
|
||||
write _str to theOpenedFile starting at eof
|
||||
|
||||
-- writeTextToFile(_str, theFile, false)
|
||||
end repeat
|
||||
|
||||
-- Restore the original delimiter
|
||||
set AppleScript's text item delimiters to theBackup
|
||||
close access theOpenedFile
|
||||
|
||||
end tell
|
||||
|
||||
|
||||
BIN
utils/dump_photo_info.scpt
Normal file
BIN
utils/dump_photo_info.scpt
Normal file
Binary file not shown.
34
utils/get_photo_info.applescript
Normal file
34
utils/get_photo_info.applescript
Normal file
@@ -0,0 +1,34 @@
|
||||
-- Displays UUID and other info about selected photos
|
||||
-- Useful for debugging with osxphotos
|
||||
|
||||
tell application "Photos"
|
||||
activate
|
||||
|
||||
set theDelimiter to ";"
|
||||
set theBackup to AppleScript's text item delimiters
|
||||
|
||||
-- Set the new delimiter
|
||||
set AppleScript's text item delimiters to theDelimiter
|
||||
|
||||
set theResults to selection
|
||||
repeat with theItem in theResults
|
||||
|
||||
|
||||
set theKeywords to keywords of theItem
|
||||
if theKeywords is not {} then
|
||||
theKeywords = (theKeywords as text)
|
||||
else
|
||||
theKeywords = "none"
|
||||
end if
|
||||
|
||||
set theStr to (((((id of theItem) as text) & ", " & (filename of theItem) as text) & ", " & theKeywords & ", " & (name of theItem) as text) & ", " & (description of theItem) as text) & "
|
||||
"
|
||||
display dialog theStr
|
||||
|
||||
end repeat
|
||||
|
||||
set AppleScript's text item delimiters to theBackup
|
||||
|
||||
end tell
|
||||
|
||||
|
||||
BIN
utils/get_photo_info.scpt
Normal file
BIN
utils/get_photo_info.scpt
Normal file
Binary file not shown.
Reference in New Issue
Block a user