Added hidden/favorite/missing to cmd_line
This commit is contained in:
12
README.md
12
README.md
@@ -63,6 +63,12 @@ Options:
|
|||||||
--person TEXT search for person(s)
|
--person TEXT search for person(s)
|
||||||
--album TEXT search for album(s)
|
--album TEXT search for album(s)
|
||||||
--uuid TEXT search for UUID(s)
|
--uuid TEXT search for UUID(s)
|
||||||
|
--favorite search for photos marked favorite
|
||||||
|
--notfavorite search for photos not marked favorite
|
||||||
|
--hidden search for photos marked hidden
|
||||||
|
--nothidden search for photos not marked hidden
|
||||||
|
--missing search for photos missing from disk
|
||||||
|
--notmissing search for photos present on disk (e.g. not missing)
|
||||||
--json Print output in JSON format
|
--json Print output in JSON format
|
||||||
-h, --help Show this message and exit.
|
-h, --help Show this message and exit.
|
||||||
```
|
```
|
||||||
@@ -319,6 +325,12 @@ Returns `True` if the original image file is missing on disk, otherwise `False`.
|
|||||||
#### `hasadjustments()`
|
#### `hasadjustments()`
|
||||||
Returns `True` if the file has been edited in Photos, otherwise `False`
|
Returns `True` if the file has been edited in Photos, otherwise `False`
|
||||||
|
|
||||||
|
#### `favorite()`
|
||||||
|
Returns `True` if the picture has been marked as a favorite, otherwise `False`
|
||||||
|
|
||||||
|
#### `hidden()`
|
||||||
|
Returns `True` if the picture has been marked as hidden, otherwise `False`
|
||||||
|
|
||||||
#### `to_json()`
|
#### `to_json()`
|
||||||
Returns a JSON representation of all photo info
|
Returns a JSON representation of all photo info
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,9 @@ from Foundation import *
|
|||||||
from . import _applescript
|
from . import _applescript
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: Add hidden, favorite, missing to photos and command line query?
|
||||||
|
# TODO: Update README for favorite, missing
|
||||||
# TODO: Add test for __str__ and to_json
|
# TODO: Add test for __str__ and to_json
|
||||||
# TODO: Add favorites, hidden
|
|
||||||
# TODO: Add location
|
# TODO: Add location
|
||||||
# TODO: standardize _ and __ as leading char for private variables
|
# TODO: standardize _ and __ as leading char for private variables
|
||||||
# TODO: fix docstrings
|
# TODO: fix docstrings
|
||||||
|
|||||||
@@ -126,6 +126,14 @@ def dump(cli_obj):
|
|||||||
@click.option("--person", default=None, multiple=True, help="search for person(s)")
|
@click.option("--person", default=None, multiple=True, help="search for person(s)")
|
||||||
@click.option("--album", default=None, multiple=True, help="search for album(s)")
|
@click.option("--album", default=None, multiple=True, help="search for album(s)")
|
||||||
@click.option("--uuid", default=None, multiple=True, help="search for UUID(s)")
|
@click.option("--uuid", default=None, multiple=True, help="search for UUID(s)")
|
||||||
|
@click.option("--favorite", is_flag=True, help="search for photos marked favorite")
|
||||||
|
@click.option(
|
||||||
|
"--notfavorite", is_flag=True, help="search for photos not marked favorite"
|
||||||
|
)
|
||||||
|
@click.option("--hidden", is_flag=True, help="search for photos marked hidden")
|
||||||
|
@click.option("--nothidden", is_flag=True, help="search for photos not marked hidden")
|
||||||
|
@click.option("--missing", is_flag=True, help="search for photos missing from disk")
|
||||||
|
@click.option("--notmissing", is_flag=True, help="search for photos present on disk (e.g. not missing)")
|
||||||
@click.option(
|
@click.option(
|
||||||
"--json",
|
"--json",
|
||||||
required=False,
|
required=False,
|
||||||
@@ -135,17 +143,69 @@ def dump(cli_obj):
|
|||||||
)
|
)
|
||||||
@click.pass_obj
|
@click.pass_obj
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def query(ctx, cli_obj, keyword, person, album, uuid, json):
|
def query(
|
||||||
|
ctx,
|
||||||
|
cli_obj,
|
||||||
|
keyword,
|
||||||
|
person,
|
||||||
|
album,
|
||||||
|
uuid,
|
||||||
|
json,
|
||||||
|
favorite,
|
||||||
|
notfavorite,
|
||||||
|
hidden,
|
||||||
|
nothidden,
|
||||||
|
missing,
|
||||||
|
notmissing,
|
||||||
|
):
|
||||||
""" query the Photos database using 1 or more search options """
|
""" query the Photos database using 1 or more search options """
|
||||||
|
|
||||||
# if no query terms, show help and return
|
# if no query terms, show help and return
|
||||||
if not keyword and not person and not album and not uuid:
|
if (
|
||||||
|
not keyword
|
||||||
|
and not person
|
||||||
|
and not album
|
||||||
|
and not uuid
|
||||||
|
and not favorite
|
||||||
|
and not notfavorite
|
||||||
|
and not hidden
|
||||||
|
and not nothidden
|
||||||
|
and not missing
|
||||||
|
and not notmissing
|
||||||
|
):
|
||||||
|
print(cli.commands["query"].get_help(ctx))
|
||||||
|
return
|
||||||
|
elif favorite and notfavorite:
|
||||||
|
# can't search for both favorite and notfavorite
|
||||||
|
print(cli.commands["query"].get_help(ctx))
|
||||||
|
return
|
||||||
|
elif hidden and nothidden:
|
||||||
|
# can't search for both hidden and nothidden
|
||||||
|
print(cli.commands["query"].get_help(ctx))
|
||||||
|
return
|
||||||
|
elif missing and notmissing:
|
||||||
|
# can't search for both missing and notmissing
|
||||||
print(cli.commands["query"].get_help(ctx))
|
print(cli.commands["query"].get_help(ctx))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
photos = cli_obj.photosdb.photos(
|
photos = cli_obj.photosdb.photos(
|
||||||
keywords=keyword, persons=person, albums=album, uuid=uuid
|
keywords=keyword, persons=person, albums=album, uuid=uuid
|
||||||
)
|
)
|
||||||
|
if favorite:
|
||||||
|
photos = [p for p in photos if p.favorite()]
|
||||||
|
elif notfavorite:
|
||||||
|
photos = [p for p in photos if not p.favorite()]
|
||||||
|
|
||||||
|
if hidden:
|
||||||
|
photos = [p for p in photos if p.hidden()]
|
||||||
|
elif nothidden:
|
||||||
|
photos = [p for p in photos if not p.hidden()]
|
||||||
|
|
||||||
|
if missing:
|
||||||
|
photos = [p for p in photos if p.ismissing()]
|
||||||
|
elif notmissing:
|
||||||
|
photos = [p for p in photos if not p.ismissing()]
|
||||||
|
|
||||||
print_photo_info(photos, cli_obj.json or json)
|
print_photo_info(photos, cli_obj.json or json)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user