mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-12 23:45:18 +00:00
Merge pull request #191 from Demizo/feature_duration_matching
[Feature] Add Duration Match Algorithm (Needs Testing)
This commit is contained in:
commit
9ba46e3060
@ -351,7 +351,7 @@ class Settings extends HookConsumerWidget {
|
|||||||
value: SpotubeTrackMatchAlgorithm.popular,
|
value: SpotubeTrackMatchAlgorithm.popular,
|
||||||
),
|
),
|
||||||
DropdownMenuItem(
|
DropdownMenuItem(
|
||||||
child: Text("YouTube's choice is my choice"),
|
child: Text("YouTube's Top choice"),
|
||||||
value: SpotubeTrackMatchAlgorithm.youtube,
|
value: SpotubeTrackMatchAlgorithm.youtube,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -429,6 +429,10 @@ class Playback extends PersistedChangeNotifier {
|
|||||||
|
|
||||||
final bool hasNoLiveInTitle =
|
final bool hasNoLiveInTitle =
|
||||||
!PrimitiveUtils.containsTextInBracket(ytTitle, "live");
|
!PrimitiveUtils.containsTextInBracket(ytTitle, "live");
|
||||||
|
final bool hasCloseDuration =
|
||||||
|
(track.duration!.inSeconds - video.duration!.inSeconds)
|
||||||
|
.abs() <=
|
||||||
|
10; //Duration matching threshold
|
||||||
|
|
||||||
int rate = 0;
|
int rate = 0;
|
||||||
for (final el in [
|
for (final el in [
|
||||||
@ -438,12 +442,14 @@ class Playback extends PersistedChangeNotifier {
|
|||||||
SpotubeTrackMatchAlgorithm.authenticPopular)
|
SpotubeTrackMatchAlgorithm.authenticPopular)
|
||||||
authorIsArtist,
|
authorIsArtist,
|
||||||
hasNoLiveInTitle,
|
hasNoLiveInTitle,
|
||||||
|
hasCloseDuration,
|
||||||
!video.isLive,
|
!video.isLive,
|
||||||
]) {
|
]) {
|
||||||
if (el) rate++;
|
if (el) rate++;
|
||||||
}
|
}
|
||||||
// can't let pass any non title matching track
|
// can't let pass any non title matching track
|
||||||
if (!hasTitle) rate = rate - 2;
|
if (!hasTitle) rate = rate - 2;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"video": video,
|
"video": video,
|
||||||
"points": rate,
|
"points": rate,
|
||||||
|
Loading…
Reference in New Issue
Block a user