From a156a48a6b068928d0b63dcf6c1686b32366d8e6 Mon Sep 17 00:00:00 2001 From: George <41969151+geo-martino@users.noreply.github.com> Date: Fri, 20 Sep 2024 16:47:55 -0400 Subject: [PATCH 1/2] skip int and float conversion on bad tag values --- musify/libraries/local/track/_tags/reader.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/musify/libraries/local/track/_tags/reader.py b/musify/libraries/local/track/_tags/reader.py index b069b547..5db48076 100644 --- a/musify/libraries/local/track/_tags/reader.py +++ b/musify/libraries/local/track/_tags/reader.py @@ -131,7 +131,10 @@ def read_date(self) -> tuple[int | None, int | None, int | None] | None: def read_bpm(self) -> float | None: """Extract BPM tags from file""" values = self.read_tag(self.tag_map.bpm) - return float(values[0]) if values is not None else None + try: + return float(values[0]) if values is not None else None + except ValueError: + return None def read_key(self) -> str | None: """Extract key tags from file""" @@ -159,7 +162,10 @@ def read_disc_total(self) -> int | None: def read_compilation(self) -> bool | None: """Extract compilation tags from file""" values = self.read_tag(self.tag_map.compilation) - return bool(int(values[0])) if values is not None else None + try: + return bool(int(values[0])) if values is not None else None + except ValueError: + return None def read_comments(self) -> list[str] | None: """Extract comment tags from file""" From 2f4f6f3bc0e759bb52324abe5916ed2091c3a3da Mon Sep 17 00:00:00 2001 From: George <41969151+geo-martino@users.noreply.github.com> Date: Fri, 20 Sep 2024 16:50:52 -0400 Subject: [PATCH 2/2] Update release history --- docs/info/release-history.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/info/release-history.rst b/docs/info/release-history.rst index 0cfe9613..18fed4a5 100644 --- a/docs/info/release-history.rst +++ b/docs/info/release-history.rst @@ -32,6 +32,13 @@ The format is based on `Keep a Changelog `_, and this project adheres to `Semantic Versioning `_ +1.1.7 +===== + +Fixed +----- +* Handle bad values for bpm and compilation in :py:class:`.TagReader` by returning ``None``. + 1.1.6 =====