Skip to content

Commit 9650125

Browse files
committed
done :>
1 parent d57c746 commit 9650125

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

lib/date_extractors/json_extractor.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import 'package:collection/collection.dart';
55
import 'package:gpth/extras.dart' as extras;
66
import 'package:gpth/utils.dart';
77
import 'package:path/path.dart' as p;
8+
import 'package:unorm_dart/unorm_dart.dart' as unorm;
89

910
/// Finds corresponding json file with info and gets 'photoTakenTime' from it
1011
Future<DateTime?> jsonExtractor(File file, {bool tryhard = false}) async {
@@ -59,6 +60,9 @@ String _removeDigit(String filename) =>
5960
/// This removes only strings defined in [extraFormats] list from `extras.dart`,
6061
/// so it's pretty safe
6162
String _removeExtra(String filename) {
63+
// MacOS uses NFD that doesn't work with our accents 🙃🙃
64+
// https://github.com/TheLastGimbus/GooglePhotosTakeoutHelper/pull/247
65+
filename = unorm.nfc(filename);
6266
for (final extra in extras.extraFormats) {
6367
if (filename.contains(extra)) {
6468
return filename.replaceLast(extra, '');
@@ -77,6 +81,9 @@ String _removeExtra(String filename) {
7781
/// ```
7882
/// so it's *kinda* safe
7983
String _removeExtraRegex(String filename) {
84+
// MacOS uses NFD that doesn't work with our accents 🙃🙃
85+
// https://github.com/TheLastGimbus/GooglePhotosTakeoutHelper/pull/247
86+
filename = unorm.nfc(filename);
8087
// include all characters, also with accents
8188
final matches = RegExp(r'(?<extra>-[A-Za-zÀ-ÖØ-öø-ÿ]+(\(\d\))?)\.\w+$')
8289
.allMatches(filename);

lib/extras.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:path/path.dart' as p;
2+
import 'package:unorm_dart/unorm_dart.dart' as unorm;
23

34
import 'media.dart';
45

@@ -34,7 +35,9 @@ int removeExtras(List<Media> media) {
3435
for (final m in copy) {
3536
final name = p.withoutExtension(p.basename(m.firstFile.path)).toLowerCase();
3637
for (final extra in extraFormats) {
37-
if (name.endsWith(extra)) {
38+
// MacOS uses NFD that doesn't work with our accents 🙃🙃
39+
// https://github.com/TheLastGimbus/GooglePhotosTakeoutHelper/pull/247
40+
if (unorm.nfc(name).endsWith(extra)) {
3841
media.remove(m);
3942
count++;
4043
break;

pubspec.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,14 @@ packages:
417417
url: "https://pub.dev"
418418
source: hosted
419419
version: "1.3.2"
420+
unorm_dart:
421+
dependency: "direct main"
422+
description:
423+
name: unorm_dart
424+
sha256: "5b35bff83fce4d76467641438f9e867dc9bcfdb8c1694854f230579d68cd8f4b"
425+
url: "https://pub.dev"
426+
source: hosted
427+
version: "0.2.0"
420428
vm_service:
421429
dependency: transitive
422430
description:

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ dependencies:
2323
# url: https://github.com/TheLastGimbus/archive.git
2424
# ref: fix-windoza-extract-errors
2525
proper_filesize: ^0.0.2
26+
unorm_dart: ^0.2.0
2627

2728
dev_dependencies:
2829
lints: ^2.1.1

0 commit comments

Comments
 (0)