Skip to content

Commit

Permalink
skip int and float conversion on bad tag values
Browse files Browse the repository at this point in the history
  • Loading branch information
geo-martino authored Sep 20, 2024
1 parent e6b2da0 commit a156a48
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions musify/libraries/local/track/_tags/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down Expand Up @@ -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"""
Expand Down

0 comments on commit a156a48

Please sign in to comment.