Merge pull request #191 from Demizo/feature_duration_matching

[Feature] Add Duration Match Algorithm (Needs Testing)
This commit is contained in:
Kingkor Roy Tirtho 2022-09-19 12:25:09 +06:00 committed by GitHub
commit 9ba46e3060
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -351,7 +351,7 @@ class Settings extends HookConsumerWidget {
value: SpotubeTrackMatchAlgorithm.popular,
),
DropdownMenuItem(
child: Text("YouTube's choice is my choice"),
child: Text("YouTube's Top choice"),
value: SpotubeTrackMatchAlgorithm.youtube,
),
],

View File

@ -429,6 +429,10 @@ class Playback extends PersistedChangeNotifier {
final bool hasNoLiveInTitle =
!PrimitiveUtils.containsTextInBracket(ytTitle, "live");
final bool hasCloseDuration =
(track.duration!.inSeconds - video.duration!.inSeconds)
.abs() <=
10; //Duration matching threshold
int rate = 0;
for (final el in [
@ -438,12 +442,14 @@ class Playback extends PersistedChangeNotifier {
SpotubeTrackMatchAlgorithm.authenticPopular)
authorIsArtist,
hasNoLiveInTitle,
hasCloseDuration,
!video.isLive,
]) {
if (el) rate++;
}
// can't let pass any non title matching track
if (!hasTitle) rate = rate - 2;
return {
"video": video,
"points": rate,