Fix crashing due to Discord RPC error and fix metadata handling crashing if there are no id3 headers

This commit is contained in:
csd4ni3l
2025-07-21 17:33:56 +02:00
parent e5a6fa4a2e
commit 1325f9546f
2 changed files with 6 additions and 6 deletions

View File

@@ -621,7 +621,7 @@ class Main(arcade.gui.UIView):
else: else:
state = "Paused" state = "Paused"
else: else:
details = "" details = "No songs playing"
state = "No songs playing" state = "No songs playing"
self.pypresence_client.update(state=state, details=details, start=self.pypresence_client.start_time) self.pypresence_client.update(state=state, details=details, start=self.pypresence_client.start_time)

View File

@@ -55,13 +55,13 @@ def extract_metadata_and_thumbnail(file_path: str, thumb_resolution: tuple):
last_played = float(frame.text[0]) last_played = float(frame.text[0])
elif desc == "play_count": elif desc == "play_count":
play_count = int(frame.text[0]) play_count = int(frame.text[0])
except ID3NoHeaderError:
pass
if hasattr(easyid3, "info"): if hasattr(easyid3, "info"):
sound_length = round(easyid3.info.length, 2) sound_length = round(easyid3.info.length, 2)
bitrate = int((easyid3.info.bitrate or 0) / 1000) bitrate = int((easyid3.info.bitrate or 0) / 1000)
sample_rate = int(easyid3.info.sample_rate / 1000) sample_rate = int(easyid3.info.sample_rate / 1000)
except ID3NoHeaderError:
pass
apic = id3.getall("APIC") apic = id3.getall("APIC")
thumb_image_data = apic[0].data if apic else None thumb_image_data = apic[0].data if apic else None