Skip to content

Commit

Permalink
improved time match
Browse files Browse the repository at this point in the history
  • Loading branch information
xnetcat committed Feb 25, 2024
1 parent 7cb2afc commit 789d056
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions spotdl/utils/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import logging
from itertools import product, zip_longest
from math import exp
from typing import Dict, List, Optional, Tuple

from spotdl.types.result import Result
Expand Down Expand Up @@ -606,10 +607,9 @@ def calc_time_match(song: Song, result: Result) -> float:
- time difference between song and result
"""

if result.duration > song.duration:
return 100 - (result.duration - song.duration)

return 100 - (song.duration - result.duration)
time_diff = abs(song.duration - result.duration)
score = exp(-0.1 * time_diff)
return score * 100


def calc_album_match(song: Song, result: Result) -> float:
Expand Down

0 comments on commit 789d056

Please sign in to comment.