added examples
This commit is contained in:
parent
3023f568b7
commit
ec01bf9706
43
examples/examples.py
Normal file
43
examples/examples.py
Normal file
@ -0,0 +1,43 @@
|
||||
import osxphotos
|
||||
|
||||
|
||||
def main():
|
||||
photosdb = osxphotos.PhotosDB()
|
||||
print(photosdb.keywords())
|
||||
print(photosdb.persons())
|
||||
print(photosdb.albums())
|
||||
|
||||
print(photosdb.keywords_as_dict())
|
||||
print(photosdb.persons_as_dict())
|
||||
print(photosdb.albums_as_dict())
|
||||
|
||||
# find all photos with Keyword = Kids and containing person Katie
|
||||
photos = photosdb.photos(keywords=["Kids"], persons=["Katie"])
|
||||
print(f"found {len(photos)} photos")
|
||||
|
||||
# find all photos that include Katie but do not contain the keyword wedding
|
||||
photos = [
|
||||
p
|
||||
for p in photosdb.photos(persons=["Katie"])
|
||||
if p not in photosdb.photos(keywords=["wedding"])
|
||||
]
|
||||
|
||||
# get all photos in the database
|
||||
photos = photosdb.photos()
|
||||
for p in photos:
|
||||
print(
|
||||
p.uuid(),
|
||||
p.filename(),
|
||||
p.date(),
|
||||
p.description(),
|
||||
p.name(),
|
||||
p.keywords(),
|
||||
p.albums(),
|
||||
p.persons(),
|
||||
p.path(),
|
||||
p.ismissing(),
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
x
Reference in New Issue
Block a user