File tree 1 file changed +6
-7
lines changed
lib/services/sourced_track/sources
1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -251,19 +251,18 @@ class YoutubeSourcedTrack extends SourcedTrack {
251
251
.map ((YoutubeVideoInfo videoInfo) {
252
252
final ytWords = videoInfo.title
253
253
.toLowerCase ()
254
- .replaceAll (RegExp (r'[^a-zA-Z0-9\s]+' ), '' )
254
+ .replaceAll (RegExp (r'(?:\p{L}\p{Mn}*|\p{N}|\s)+' , unicode : true ), '' )
255
255
.split (RegExp (r'\s+' ))
256
256
.where ((item) => item.isNotEmpty);
257
257
final spWords = track.name!
258
258
.toLowerCase ()
259
- .replaceAll (RegExp (r'\((.*)\)' ), '' )
260
- .replaceAll (RegExp (r'[^a-zA-Z0-9\s]+' ), '' )
259
+ .replaceAll (RegExp (r'(?:\p{L}\p{Mn}*|\p{N}|\s)+' , unicode: true ), '' )
261
260
.split (RegExp (r'\s+' ))
262
261
.where ((item) => item.isNotEmpty);
263
- // Word match to filter out unrelated results
264
- final matchCount =
265
- ytWords. where ((word) => spWords. contains (word)).length;
266
- if (matchCount > spWords.length ~ / 2 ) {
262
+ // Single word and duration match with 3 second tolerance
263
+ if (ytWords. any ((word) => spWords. contains (word)) &&
264
+ (videoInfo.duration - track.duration ! )
265
+ . abs ().inMilliseconds <= 3000 ) {
267
266
return videoInfo;
268
267
}
269
268
return null ;
You can’t perform that action at this time.
0 commit comments