Replies: 5 comments 3 replies
-
@garz75 The >>> album = "Los Angeles 2020"
>>> "2020" in album
True This would be easier to implement. If you wanted to take a stab at implementing this, here are the basic steps. All modifications would be to
Lines 205 to 214 in 3c36b0f
Lines 1030 to 1035 in 3c36b0f So you'd add
Lines 1980 to 1985 in 3c36b0f You'd add a new block in this method that goes something like this: if folder_matching:
# code that matches folder names here....see the section that starts "if folder:"
photos = new_list_of_photos In
Lines 5703 to 5721 in 3c36b0f |
Beta Was this translation helpful? Give feedback.
-
If you want to try to add this I also recommend you look at the changes in this commit where I recently added |
Beta Was this translation helpful? Give feedback.
-
Thank you for showing the path for implementing this ! I actually have
started implementing —folder-matching, my diff looks a lot like what you
propose. I won’t have time to work on this before next weekend, I hope I
will be able to push a pull request bien then...
À bientôt et merci!
On Mon 5 Apr 2021 at 16:40 Rhet Turnbull ***@***.***> wrote:
@garz75 <https://github.com/garz75> The --album and --folder options
currently match against the entire album or folder name, respectively. Do
you need full regex matching or would it be sufficient to use python's str
in? For example:
>>> album = "Los Angeles 2020"
>>> "2020" in album
True
This would be easier to implement.
If you wanted to take a stab at implementing this, here are the basic
steps. All modifications would be to osxphotos/cli.py.
1. Add the option to query_options which gets used by both osxphotos
query and osxphotos export. While the option name has a "-" in it,
these get converted to underscore "_" for the associated variable name.
https://github.com/RhetTbull/osxphotos/blob/3c36b0fb333a47c996b687c704d45b25a1edd95d/osxphotos/cli.py#L205-L214
1. Add the new argument, e.g. folder_matching to both query() and
export() function defs. In export, you'll also need to add it to the
config code that saves and restores config from file for --save-config
and --load-config. Reference this bit of code:
https://github.com/RhetTbull/osxphotos/blob/3c36b0fb333a47c996b687c704d45b25a1edd95d/osxphotos/cli.py#L1030-L1035
So you'd add folder_matching = cfg.folder_matching etc
1. Modify _query() which does the actual matching for all query
options:
https://github.com/RhetTbull/osxphotos/blob/3c36b0fb333a47c996b687c704d45b25a1edd95d/osxphotos/cli.py#L1980-L1985
You'd add a new block in this method that goes something like this:
if folder_matching:
# code that matches folder names here....see the section that starts "if folder:"
photos = new_list_of_photos
In _query, all blocks are progressive --- e.g. they build on the previous
block to build up a list of photos to query/export. It's a long but simple
function so should be easy to follow.
1.
Find all the places _query is called in the cli.py and update the call
to include the new options.
2.
Write a test! See test_cli.py. Copy one of the test libraries to your
Pictures folder to examine it if needed then write a test that tests your
new option. Do NOT open the test library from inside the source code folder
as if you do that, Photos will constantly be trying to update it (e.g. to
do background processing to find faces, etc) and there's no way to turn
this off once Photos "finds" the library. See this test as a an example:
https://github.com/RhetTbull/osxphotos/blob/3c36b0fb333a47c996b687c704d45b25a1edd95d/tests/test_cli.py#L5703-L5721
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#413 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABSWNEYFVPB5ZKJJL7JH73TTHHDW7ANCNFSM42MOT64Q>
.
--
—
Frederic Garzon
+33 6 72 87 41 67
|
Beta Was this translation helpful? Give feedback.
-
@garz75 while not as elegant as a custom option, with v0.42.6, I fixed the Albums: Folders: The eval string for folders is a bit more complex because it needs to ask each album for a list of folder names but those are returned as a list of lists in the list comprehension which then needs to be flattened Of course, you can use this method to use a regex for any search, not just albums or folders. |
Beta Was this translation helpful? Give feedback.
-
Rhet this is a brilliant idea. This one is worth adding a new option IMHO ;-) |
Beta Was this translation helpful? Give feedback.
-
Hi Rhet and other osxphotos gurus,
Has anyone ever requested such a feature ? I organise my library with folders and albums with dates and places or events in their names, so I would like to be able to export photos with a command like this
I am new at python so my code should be scrutinised ;-), but I would be happy to propose something if you are interested to include it in the project....
Beta Was this translation helpful? Give feedback.
All reactions