From b8ad7be46f101e9d487ddc5ebc354738a3ed4694 Mon Sep 17 00:00:00 2001 From: office-pc nix root Date: Thu, 21 Nov 2024 20:00:11 +0800 Subject: [PATCH 1/3] fix issues with thumbnails fix #636 --- lib/player/views/components/audio_player.dart | 5 ++++- lib/utils/models/image_object.dart | 11 +++++++++-- lib/videos/models/video.dart | 9 --------- lib/videos/views/components/inner_view.dart | 4 +++- lib/videos/views/components/inner_view_tablet.dart | 4 +++- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/lib/player/views/components/audio_player.dart b/lib/player/views/components/audio_player.dart index ad40e02e..c4453419 100644 --- a/lib/player/views/components/audio_player.dart +++ b/lib/player/views/components/audio_player.dart @@ -1,3 +1,4 @@ +import 'package:clipious/utils/models/image_object.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:clipious/player/views/components/player_controls.dart'; @@ -49,7 +50,9 @@ class AudioPlayer extends StatelessWidget { decoration: const BoxDecoration(), videoId: playerState.video!.videoId, thumbnailUrl: playerState.video?.deArrowThumbnailUrl ?? - playerState.video?.getBestThumbnail()?.url ?? + ImageObject.getBestThumbnail( + playerState.video?.videoThumbnails ?? []) + ?.url ?? '', ) : playerState.offlineVideo != null diff --git a/lib/utils/models/image_object.dart b/lib/utils/models/image_object.dart index c602207e..b442d007 100644 --- a/lib/utils/models/image_object.dart +++ b/lib/utils/models/image_object.dart @@ -20,10 +20,17 @@ class ImageObject { if (images != null && images.isNotEmpty) { List imgs = List.from(images); imgs.sort((a, b) { - return (b.width * b.height).compareTo(a.width * a.height); + final aHasDefault = a.quality?.contains("default") ?? false; + final bHasDefault = b.quality?.contains("default") ?? false; + + if (bHasDefault == aHasDefault) { + return (b.width * b.height).compareTo(a.width * a.height); + } else { + return (aHasDefault ? 0 : 1).compareTo(bHasDefault ? 0 : 1); + } }); - return imgs[0]; + return imgs.firstOrNull; } else { return null; } diff --git a/lib/videos/models/video.dart b/lib/videos/models/video.dart index 2aba9999..eee8cf89 100644 --- a/lib/videos/models/video.dart +++ b/lib/videos/models/video.dart @@ -102,15 +102,6 @@ class Video with _$Video implements ShareLinks, IdedVideo { return link; } - - ImageObject? getBestThumbnail() { - if (videoThumbnails.isNotEmpty) { - return videoThumbnails - .firstWhere((element) => element.quality == 'maxres'); - } else { - return null; - } - } } /* diff --git a/lib/videos/views/components/inner_view.dart b/lib/videos/views/components/inner_view.dart index eb7fd5f4..f4720a03 100644 --- a/lib/videos/views/components/inner_view.dart +++ b/lib/videos/views/components/inner_view.dart @@ -1,3 +1,4 @@ +import 'package:clipious/utils/models/image_object.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; @@ -54,7 +55,8 @@ class VideoInnerView extends StatelessWidget { child: VideoThumbnailView( videoId: video.videoId, thumbnailUrl: video.deArrowThumbnailUrl ?? - video.getBestThumbnail()?.url ?? + ImageObject.getBestThumbnail(video.videoThumbnails) + ?.url ?? '', child: phoneLandscape ? const SizedBox.shrink() diff --git a/lib/videos/views/components/inner_view_tablet.dart b/lib/videos/views/components/inner_view_tablet.dart index 69fe0c47..08803773 100644 --- a/lib/videos/views/components/inner_view_tablet.dart +++ b/lib/videos/views/components/inner_view_tablet.dart @@ -8,6 +8,7 @@ import 'package:clipious/videos/views/components/play_button.dart'; import '../../../player/states/player.dart'; import '../../../settings/states/settings.dart'; import '../../../utils.dart'; +import '../../../utils/models/image_object.dart'; import '../../states/video.dart'; import 'add_to_queue_button.dart'; import 'info.dart'; @@ -56,7 +57,8 @@ class VideoTabletInnerView extends StatelessWidget { child: VideoThumbnailView( videoId: video.videoId, thumbnailUrl: video.deArrowThumbnailUrl ?? - video.getBestThumbnail()?.url ?? + ImageObject.getBestThumbnail(video.videoThumbnails) + ?.url ?? '', child: Stack( alignment: Alignment.center, From d69b16b6e4004a108cb03448705c9e808a94f1e2 Mon Sep 17 00:00:00 2001 From: office-pc nix root Date: Thu, 21 Nov 2024 20:01:18 +0800 Subject: [PATCH 2/3] update version --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index c44ff826..9a289403 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: clipious -version: 1.22.2+4065 +version: 1.22.3+4066 publish_to: none description: Client for invidious. environment: From bc39537178f487778adbdade7b8b163a2db43815 Mon Sep 17 00:00:00 2001 From: office-pc nix root Date: Thu, 21 Nov 2024 20:04:25 +0800 Subject: [PATCH 3/3] fix translations --- lib/l10n/app_fr.arb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/l10n/app_fr.arb b/lib/l10n/app_fr.arb index 65e6f548..99ef581c 100644 --- a/lib/l10n/app_fr.arb +++ b/lib/l10n/app_fr.arb @@ -100,7 +100,7 @@ "@shareInvidiousLink": { "description": "asking user to share invidious link" }, - "ok": "D'accord", + "ok": "D''accord", "@ok": { "description": "Ok" }, @@ -443,11 +443,11 @@ "@sponsorBlockCategoryMusicOffTopicDescription": { "description": "Only for use in music videos. This only should be used for sections of music videos that aren't already covered by another category." }, - "appLogsDescription": "Obtenir les registres de ce qui se passe dans l'application, peut être utile pour signaler les problèmes", + "appLogsDescription": "Obtenir les registres de ce qui se passe dans l''application, peut être utile pour signaler les problèmes", "@appLogsDescription": { "description": "Description of the app log settings" }, - "appLogs": "Journaux d'application", + "appLogs": "Journaux d''application", "@appLogs": { "description": "Title for settings that leads to application logs" }, @@ -459,7 +459,7 @@ "@logsCopied": { "description": "Message to tell user that logs have been copied to the clipboard" }, - "clearSearchHistory": "Effacer l'historique de recherche", + "clearSearchHistory": "Effacer l''historique de recherche", "@clearSearchHistory": { "description": "Settings label for clearing search history" }, @@ -825,7 +825,7 @@ "@videoAddedToQueue": { "description": "Pop up message when a video was added at the end of the video queue" }, - "shareLinkWithTimestamp": "Ajouter l'horodatage", + "shareLinkWithTimestamp": "Ajouter l''horodatage", "@shareLinkWithTimestamp": { "description": "asking user to share link along with timestamp" }, @@ -1403,7 +1403,7 @@ "@cancelSleepTimer": {}, "premieresIn": "Première dans {formattedDuration}", "@premieresIn": {}, - "screenControls": "Contrôles de l'écran", + "screenControls": "Contrôles de l''écran", "@screenControls": {}, "screenControlsExplanation": "En regardant une vidéo en plein écran, glisser verticalement de la gauche ou de la droite ajustera la luminosité ou le volume respectivement", "@screenControlsExplanation": {}