From 5598af5cee5c80189c930185f9269cebb0389866 Mon Sep 17 00:00:00 2001 From: Lars Noack Date: Tue, 29 Nov 2022 16:55:13 +0100 Subject: [PATCH] addet compatibility if length of a song is not known --- src/music_kraken/utils/phonetic_compares.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/music_kraken/utils/phonetic_compares.py b/src/music_kraken/utils/phonetic_compares.py index 159363d..65f5deb 100644 --- a/src/music_kraken/utils/phonetic_compares.py +++ b/src/music_kraken/utils/phonetic_compares.py @@ -49,5 +49,9 @@ def match_artists(artist_1, artist_2: str): return True, min(distances) return match_titles(artist_1, artist_2) -def match_length(length_1: int, length_2: int) -> bool: +def match_length(length_1: int | None, length_2: int | None) -> bool: + # returning true if either one is Null, because if one value is not known, + # then it shouldn't be an attribute which could reject an audio source + if length_1 is None or length_2 is None: + return True return abs(length_1 - length_2) <= ALLOWED_LENGTH_DISTANCE