Compare commits

..

2 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

View File

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