Compare commits

..

1 Commits

Author SHA1 Message Date
Guanciottaman
188e52329a
Merge ff252d6b14 into 8a7f5c4008 2025-03-29 12:16:36 +06:00

View File

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