Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related Issues
Summary
Now it doesn't prioritize specific fields, it instead prioritizes the oldest date found in the candidate fields. This should provide much more accurate dates and also fix the problem where if we prioritize tags commonly used for iPhone videos then Android videos have the wrong sort order and vice versa. If the oldest datetime is shared between fields it chooses the most precise one between no seconds, seconds, and subseconds.
PERFORMANCE IMPACT: Very minimal and necessary for proper sort order.
Uses two calls to exiftool per media item. One with -n for GPS coordinates and one without -n for anything else. I found using -n causes issues with how exiftool reports date strings with subseconds and timezones. This change allows us to support subseconds and makes it so most dates come out of exiftool with a proper timezone already attached. The only time the parser manually handles timezones now is when the oldest candidate date found lacks timezone info.
PERFORMANCE IMPACT: Very minimal. If we really want to we could reduce this to one call again if we manually parse the GPS info from the first exiftool call. Not sure which is faster.
Now handles more datetime EXIF fields and formats.
PERFORMANCE IMPACT: Basically none.
Now uses a fallback method to get timezone information from GPS coordinates if it can't be gathered from the planet database. It uses Python timezonefinder so Python 3.9+ must be installed on the server and most of the time it is by default on modern distros. This allows us to still get timezone information for Android videos (important for sorting) on SQLite instances or if the planet dataset isn't installed. The timezonefinder library and dataset is in the python directory and can be updated with pip install --upgrade timezonefinder --target /var/www/html/nextcloud/apps/memories/python. This is where the scary number of "files changed" comes from.
PERFORMANCE IMPACT: Large, but this code pretty much only runs on single-user instances, since large instances will likely be using PostgreSQL, MySQL, or MariaDB and the planet dataset. And on single-user instances without the planet dataset this code still only runs when it needs to for proper timezone gathering.
Now media is categorized into days based on the day they were taken in the media item timezone so they don't show on the wrong day when they are past midnight UTC.
PERFORMANCE IMPACT: Basically none.
Changed some UI elements to show dates based on the media item timezone.
PERFORMANCE IMPACT: Basically none.
IMPORTANT NOTE: Will need to clear/force reindex files and clear browser cache to have photos show correctly with these changes.
If you have media that had dates previously converted to UTC from another timezone and saved back into the file EXIF dates, and didn't have its old timezone offset removed from the dedicated EXIF offset fields in the process, then reindexing it will move it off from where it should be by your timezone offset. I don't have time to look into it but somebody should double check that Memories doesn't do this when editing metadata, because that would be bad whether or not my PR is merged.
The way Date/Time metadata is edited in Memories should also eventually get some work done to bring it in line with my changes. I suggest showing the Date/Time in the media item timezone instead of UTC and adding an edit box for the timezone offset.
The way the Android app sorts local photos should also get brought in line with these changes at some point.
First contribution to a repo that isn't my own ever so go easy on me please 🙏.