From b66d74ecb3855c3aa4eeba023c3357b8c8bc6f00 Mon Sep 17 00:00:00 2001 From: Puqns67 Date: Thu, 17 Oct 2024 22:20:26 +0800 Subject: [PATCH] fix: NCM metadata parse --- ncmlyrics/lrc.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ncmlyrics/lrc.py b/ncmlyrics/lrc.py index 29c0ce0..76585a8 100644 --- a/ncmlyrics/lrc.py +++ b/ncmlyrics/lrc.py @@ -87,12 +87,18 @@ class Lrc: return try: - key: str = data["c"][0]["tx"] - value: str = data["c"][1]["tx"] - except KeyError: + match len(data["c"]): + case 1: + key, value = data["c"][0]["tx"].replace(":", ":").split(":") + case 2: + key = data["c"][0]["tx"] + value = data["c"][1]["tx"] + case _: + return + except (KeyError, ValueError): return - key = key.strip(" :") + key = key.strip(" ::") value = value.strip() self.specials["metadata"].append((LrcMetaType.Author, f"{key}/{value}"))