-
-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Google Photos Takeout now adds a suffix to json file (and not properly either) #353
Comments
Added this to json_extractor.dart and it works now (FYI AI generated) Future<File?> _jsonForFile(File file, {required bool tryhard}) async {
final dir = Directory(p.dirname(file.path));
var name = p.basename(file.path);
// Use methods to generate potential JSON file names
for (final method in [
(String s) => s,
_shortenName,
_bracketSwap,
_removeExtra,
if (tryhard) ...[
_removeExtraRegex,
_removeDigit,
]
]) {
final baseJsonFile = File(p.join(dir.path, '${method(name)}.json'));
if (await baseJsonFile.exists()) return baseJsonFile;
// Check for JSON file with suffix and truncated suffix variations
final supplementalJsonFile =
await _matchSupplementalSuffix(dir, method(name));
if (supplementalJsonFile != null) return supplementalJsonFile;
}
return null;
}
/// Attempts to find a JSON file with `.supplemental-metadata.json` suffix or a truncated version
Future<File?> _matchSupplementalSuffix(Directory dir, String baseName) async {
const suffix = '.supplemental-metadata.json';
const maxLength = 51;
// Try with full suffix
final fullFile = File(p.join(dir.path, '$baseName$suffix'));
if (await fullFile.exists()) return fullFile;
// Try truncated suffixes if file length exceeds max length
for (int i = suffix.length; i > 0; i--) {
final truncatedSuffix = suffix.substring(0, i);
final truncatedFile =
File(p.join(dir.path, '$baseName$truncatedSuffix.json'));
if (await truncatedFile.exists()) return truncatedFile;
}
return null;
} |
ooo jaaapierdole... okay, will look into this... soon ™️ |
Where did you add this into json_extractor.dart file? Thank you |
Running this python script on the files before running the .exe seems to have done the trick for someone out there. import os
[os.rename(f, f.replace('.supplemental-metadata.', '.')) for f in os.listdir('.') if not f.startswith('.')]
[os.rename(f, f.replace('.supplemental-metad.', '.')) for f in os.listdir('.') if not f.startswith('.')]
[os.rename(f, f.replace('.supplementa.', '.')) for f in os.listdir('.') if not f.startswith('.')]
[os.rename(f, f.replace('.supplemental-metadat.', '.')) for f in os.listdir('.') if not f.startswith('.')]
[os.rename(f, f.replace('.suppleme.', '.')) for f in os.listdir('.') if not f.startswith('.')]
[os.rename(f, f.replace('.supplemental-meta.', '.')) for f in os.listdir('.') if not f.startswith('.')] might be useful to people until the owner adds the proper code in dart. |
To follow, same issue, file are move in Nodate Folder while there is a supplemental-metadata files with date. |
Running this command in PowerShell did the trick for me (in Takeout folder, before running gpth): I also created a pull request with a fix adapted from that command: #375 Additionally, I released an alternate version that includes this fix along with other pull requests I submitted with fixes and new functions if you want to try it in the meantime: |
Hello, Thanks a lot for this tool but unfortunately it is not working correctly for me. I noticed either other people's json file was just the filename with
.json
at the end.But I noticed mine have a suffix at the end of each json file. Most of my files have this extension
.supplemental-metadata.json
after the file name. but with some of the longer files, the extensions are cut off at the end such asPXL_20240817_202602411.mp4
has the json file namedPXL_20240817_202602411.mp4.supplemental-metada.json
. and there are many others like that with.supplemental-me
,.supplementa
, etcGuessing works with some but fails terribly with others. I have some that are dated to 1868 and 2068 😂
The text was updated successfully, but these errors were encountered: