diff --git a/lib/date_extractors/json_extractor.dart b/lib/date_extractors/json_extractor.dart index 8f6427a2f..4268404ce 100644 --- a/lib/date_extractors/json_extractor.dart +++ b/lib/date_extractors/json_extractor.dart @@ -5,6 +5,7 @@ import 'package:collection/collection.dart'; import 'package:gpth/extras.dart' as extras; import 'package:gpth/utils.dart'; import 'package:path/path.dart' as p; +import 'package:unorm_dart/unorm_dart.dart' as unorm; /// Finds corresponding json file with info and gets 'photoTakenTime' from it Future jsonExtractor(File file, {bool tryhard = false}) async { @@ -59,6 +60,9 @@ String _removeDigit(String filename) => /// This removes only strings defined in [extraFormats] list from `extras.dart`, /// so it's pretty safe String _removeExtra(String filename) { + // MacOS uses NFD that doesn't work with our accents πŸ™ƒπŸ™ƒ + // https://github.com/TheLastGimbus/GooglePhotosTakeoutHelper/pull/247 + filename = unorm.nfc(filename); for (final extra in extras.extraFormats) { if (filename.contains(extra)) { return filename.replaceLast(extra, ''); @@ -77,6 +81,9 @@ String _removeExtra(String filename) { /// ``` /// so it's *kinda* safe String _removeExtraRegex(String filename) { + // MacOS uses NFD that doesn't work with our accents πŸ™ƒπŸ™ƒ + // https://github.com/TheLastGimbus/GooglePhotosTakeoutHelper/pull/247 + filename = unorm.nfc(filename); // include all characters, also with accents final matches = RegExp(r'(?-[A-Za-zΓ€-Γ–Γ˜-ΓΆΓΈ-ΓΏ]+(\(\d\))?)\.\w+$') .allMatches(filename); diff --git a/lib/extras.dart b/lib/extras.dart index fa7c8fba2..7c3d4b4cd 100644 --- a/lib/extras.dart +++ b/lib/extras.dart @@ -1,4 +1,5 @@ import 'package:path/path.dart' as p; +import 'package:unorm_dart/unorm_dart.dart' as unorm; import 'media.dart'; @@ -34,7 +35,9 @@ int removeExtras(List media) { for (final m in copy) { final name = p.withoutExtension(p.basename(m.firstFile.path)).toLowerCase(); for (final extra in extraFormats) { - if (name.endsWith(extra)) { + // MacOS uses NFD that doesn't work with our accents πŸ™ƒπŸ™ƒ + // https://github.com/TheLastGimbus/GooglePhotosTakeoutHelper/pull/247 + if (unorm.nfc(name).endsWith(extra)) { media.remove(m); count++; break; diff --git a/pubspec.lock b/pubspec.lock index a7cd51fcc..4194c2671 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -417,6 +417,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.2" + unorm_dart: + dependency: "direct main" + description: + name: unorm_dart + sha256: "5b35bff83fce4d76467641438f9e867dc9bcfdb8c1694854f230579d68cd8f4b" + url: "https://pub.dev" + source: hosted + version: "0.2.0" vm_service: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 5cd4cc052..7e1ce24ac 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -23,6 +23,7 @@ dependencies: # url: https://github.com/TheLastGimbus/archive.git # ref: fix-windoza-extract-errors proper_filesize: ^0.0.2 + unorm_dart: ^0.2.0 dev_dependencies: lints: ^2.1.1