time is available on photos down to the second using the SDK - I would think that can be taken advantage of somehow, no?
I read the documentation carefully and that's what it says:
- value: (type must match field type) The value against which to match. For date values, use the string format "YYYY-MM-DD".
Using inLast is better as hours might be used. There might be a way to further specify the date but it's not documented for sure. I tried querying with cocoa timestamp but the results had nothing in common with the expected (some random photos with dates not even close to the provided value).
1 person found this helpful
I think your gonna have to put in some extra code to refine granularity:
Use the inLast to get it to the nearest hour (or not), then go through those photos using the raw-metadata timestamp and compare to current-time...
Will that work?
Sure, that's how I do it now. But this is just a work around. I think the API should be updated (after all database search is much more powerful and faster than doing it in dedicated code).
Anyway, thanks for your sole replies,
Sorry I misunderstood - I see now this was a feature request, not a question or request for help.
My guess is that the present state is because it is essentially emulating the capability in Lightroom proper. Regardless, I agree that extending the SDK in this regard would be worthwhile.
Actually I didn't formulate it right. I wanted to highlight the date issue, however I started talking about the feature I'm missing most - callbacks on certain actions (or events). Finally I combined them in a meaningless thread.
To make it more clear, if anyone knows a way to register callbacks on certain actions, please give your suggestions (or any other way to understand state changes (and what are the changes) without polling).
What I've tried (and failed) so far:
- Adding observer - I want to observe table changes rather than a specific key-value pair
- Modifying/Adding metatable - __newindex and __index didn't do the trick (obviously Lightoom doesn't use intrinsically the objects I'm trying to observe (e.g. all photos))
- Custom publishing service that exports to predefined location - not applicable
- Smart collections - didn't find a way to use them for my needs (e.g. report change; the UI makes it somehow, maybe add a shadow binding?)
- Intercepting functions (override the function that it calls a callback first then the real function) - seems that Lightroom just exposes the API rather than using it internally (would be so powerful and elegant if interception was possible (reminds me of postscript))
I also opened the catalog db, but this is not an option.
For now I'm using polling mechanisms which are far from best (the API still restricts me from doing it right; for example doing a post search myself is neither fast, nor flexible, nor elegant)
PS: Actually the only usable event (if you can call it event at all) is the custom metadata startup trick, thanks Rob!
Registering callback functions for various events is a feature not much supported by the SDK, and it would be nice if it could be.
Just out of curiosity, I'm wondering about a klugy event handling subsystem: An application that does access the database directly (read-only), and a background thread in a plugin that monitors a file written by the application that contains a reference to the changed object and what changed. Plugin main could then register handlers with plugin background for events of interest.
I haven't thought this through - I'm just shooting from the hip...
That's what I don't want to do. Database might change with releases (or even with fixes) though not likely. Another issue is that Lightroom locks the database while running (I'm trying to overcome this but have no success yet). Anyway, I'm researching it as a fallback.
M. Marinov wrote:
Database might change with releases (or even with fixes) though not likely.
This could be managed, since you have access to the version numbers.
M. Marinov wrote:
Another issue is that Lightroom locks the database while running (I'm trying to overcome this but have no success yet).
Sounds like a deal breaker if not overcome...
Let me know what you end up with. I'll let you know if I have any better ideas - OK?