Skip to content

Commit

Permalink
Merge pull request #38 from harlanx:fix/remove-reference-of-show-when…
Browse files Browse the repository at this point in the history
…-adding-to-task

fix: Remove reference of show when added to task
  • Loading branch information
harlanx authored Oct 22, 2024
2 parents b4d05e6 + 7016d63 commit b643398
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 31 deletions.
4 changes: 2 additions & 2 deletions default_modifiers.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"\\bHDCam\\b",
"\\bDolby\\b",
"\\bAtmos\\b",
"\\bDual\\b,",
"\\bESub\\b,",
"\\bDual\\b",
"\\bESub\\b",
"\\bHEVC\\b",
"\\bDTS\\b",
"\\bAAC\\b",
Expand Down
32 changes: 13 additions & 19 deletions lib/data/show_notifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,26 +71,13 @@ class ShowNotifier extends InputBasic with ChangeNotifier {

void _assignDefaultAudio(List<TrackProperties> tracks) {
List<TrackProperties> matches = [];
for (final flagOrder in profile.defaultFlagOrder) {
if (flagOrder == 'default') {
matches = tracks.where((track) {
final isDefaultLanguage =
track.language.iso6393 == profile.defaultAudioLanguage;
final orderableFlags = track.flags.values.where((flag) {
return !['enabled', 'default'].contains(flag.definedKey);
}).toList();
for (final flagName in profile.defaultFlagOrder) {
matches = tracks.where((track) {
final isDefaultLanguage =
track.language.iso6393 == profile.defaultAudioLanguage;
return track.flags[flagName]!.value && isDefaultLanguage;
}).toList();

return orderableFlags.every((flag) => flag.value == false) &&
isDefaultLanguage;
}).toList();
} else {
matches = tracks.where((track) {
final isDefaultLanguage =
track.language.iso6393 == profile.defaultAudioLanguage;

return track.flags[flagOrder]!.value && isDefaultLanguage;
}).toList();
}
if (matches.isEmpty) {
continue;
} else {
Expand Down Expand Up @@ -223,6 +210,13 @@ class ShowNotifier extends InputBasic with ChangeNotifier {
return 0;
}

ShowNotifier copyWith({Show? show, UserProfile? profile}) {
return ShowNotifier(
show ?? this.show,
profile ?? this.profile,
);
}

void updateProfile(UserProfile profile) {
this.profile = profile;
_previewProfile();
Expand Down
22 changes: 17 additions & 5 deletions lib/models/show.dart
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class EmbeddedTrack extends TrackProperties {
@override
Future<void> loadInfo() async {
return await _memoizer.runOnce(() async {
flags['default']!.value = false;
flags['default']!.value = await _isDefault;
flags['original_language']!.value = await _isOriginalLanguage;
flags['forced']!.value = await _isForced;
flags['commentary']!.value = await _isCommentary;
Expand All @@ -300,6 +300,18 @@ class EmbeddedTrack extends TrackProperties {
});
}

Future<bool> get _isDefault async {
final identifiers = ['Default'];
bool result = flags['default']!.value;
// If false, reconfirm by using track title;
if (!result) {
result = identifiers.any((identifier) =>
(title ?? '').contains(RegExp(identifier, caseSensitive: true)));
}

return result;
}

Future<bool> get _isOriginalLanguage async {
final identifiers = ['Original Language'];
bool result = flags['original_language']!.value;
Expand Down Expand Up @@ -417,10 +429,10 @@ class AddedTrack extends TrackProperties {
result = identifiers.any((identifier) =>
file.title.contains(RegExp(identifier, caseSensitive: true)));

if (AppData.subtitleFormats.contains(file.extension)) {
// Usually Forced Subtitles are less than 20KB
result = await file.length() < 20000;
}
// if (AppData.subtitleFormats.contains(file.extension)) {
// // Usually Forced Subtitles are less than 10KB
// result = await file.length() < 10000;
// }
return result;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/models/user_profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ class UserProfile extends ChangeNotifier with EquatableMixin {
r'\bHDCam\b',
r'\bDolby\b',
r'\bAtmos\b',
r'\bDual\b,',
r'\bESub\b,',
r'\bDual\b',
r'\bESub\b',
r'\bHEVC\b',
r'\bDTS\b',
r'\bAAC\b',
Expand Down
3 changes: 2 additions & 1 deletion lib/screens/home/home_screen_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class HomeScreenMenuBar extends StatelessWidget {
icon: const Icon(FluentIcons.build_queue_new),
label: Text(l10n.addToQueue),
onPressed: selectedID.value != null
? () => tasks.add(shows.items[selectedID.value]!)
? () => tasks
.add(shows.items[selectedID.value]!.copyWith())
: null,
),
],
Expand Down
2 changes: 1 addition & 1 deletion lib/utilities/utilities.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Utilities {
}
}
final currentModifiers = jsonEncode(AppData.profiles.items[1]!.modifiers);
print(latestModifiers == currentModifiers);
//print(latestModifiers == currentModifiers);
if (latestModifiers.isNotEmpty && (latestModifiers != currentModifiers)) {
return MapEntry(true, latestModifiers);
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: Automatically manage and mux series or movie files to the common co
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

version: 0.6.8+27
version: 0.6.9+28

environment:
sdk: ^3.5.0
Expand Down

0 comments on commit b643398

Please sign in to comment.