Compare commits

...

6 Commits

Author SHA1 Message Date
Richard Hajek
53da163a36
Merge 42e954428b into e986baa0aa 2025-04-07 14:20:35 +06:00
Seungmin Kim
e986baa0aa
chore: revise filter for ISRC search (#2614) 2025-04-07 13:12:45 +06:00
Richard Hajek
42e954428b feat: added filtering duplicates in recent 2025-01-18 18:01:26 +01:00
Kingkor Roy Tirtho
8c1337d1fc
Merge pull request #2118 from KRTirtho/dev
chore: release 3.9.0
2024-12-09 00:04:29 +06:00
Kingkor Roy Tirtho
94e704087f Merge branch 'dev' 2024-10-09 16:38:23 +06:00
Kingkor Roy Tirtho
8e287ab1e5
Merge pull request #1981 from KRTirtho/dev
Release 3.8.3
2024-10-09 15:39:31 +06:00
2 changed files with 19 additions and 17 deletions

View File

@ -9,7 +9,7 @@ import 'package:spotube/provider/history/recent.dart';
class HomeRecentlyPlayedSection extends HookConsumerWidget {
const HomeRecentlyPlayedSection({super.key});
@override
Widget build(BuildContext context, ref) {
final history = ref.watch(recentlyPlayedItems);
@ -20,17 +20,20 @@ class HomeRecentlyPlayedSection extends HookConsumerWidget {
return const SizedBox();
}
final uniqueItems = <dynamic>{};
final filteredItems = [
for (final item in historyData)
if (item.playlist != null && item.playlist?.id != null && uniqueItems.add(item.playlist!.id!))
item.playlist
else if (item.album != null && item.album?.id != null && uniqueItems.add(item.album?.id))
item.album
];
return Skeletonizer(
enabled: history.isLoading,
child: HorizontalPlaybuttonCardView(
title: Text(context.l10n.recently_played),
items: [
for (final item in historyData)
if (item.playlist != null)
item.playlist
else if (item.album != null)
item.album
],
items: filteredItems,
hasNextPage: false,
isLoadingNextPage: false,
onFetchMore: () {},

View File

@ -251,19 +251,18 @@ class YoutubeSourcedTrack extends SourcedTrack {
.map((YoutubeVideoInfo videoInfo) {
final ytWords = videoInfo.title
.toLowerCase()
.replaceAll(RegExp(r'[^a-zA-Z0-9\s]+'), '')
.split(RegExp(r'\s+'))
.replaceAll(RegExp(r'[^\p{L}\p{N}\p{Z}]+', unicode: true), '')
.split(RegExp(r'\p{Z}+', unicode: true))
.where((item) => item.isNotEmpty);
final spWords = track.name!
.toLowerCase()
.replaceAll(RegExp(r'\((.*)\)'), '')
.replaceAll(RegExp(r'[^a-zA-Z0-9\s]+'), '')
.split(RegExp(r'\s+'))
.replaceAll(RegExp(r'[^\p{L}\p{N}\p{Z}]+', unicode: true), '')
.split(RegExp(r'\p{Z}+', unicode: true))
.where((item) => item.isNotEmpty);
// Word match to filter out unrelated results
final matchCount =
ytWords.where((word) => spWords.contains(word)).length;
if (matchCount > spWords.length ~/ 2) {
// Single word and duration match with 3 second tolerance
if (ytWords.any((word) => spWords.contains(word)) &&
(videoInfo.duration - track.duration!)
.abs().inMilliseconds <= 3000) {
return videoInfo;
}
return null;