Skip to content

Commit

Permalink
Little fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
HarcicYang committed Aug 6, 2024
1 parent 29558bb commit 60d603a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Hyper/Segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ def init(self, *args, **kwargs):
def to_json(self) -> dict:
base = {"type": sg_type, "data": {}}
for i in anns:
base["data"][i] = getattr(self, i)
try:
base["data"][i] = anns[i](getattr(self, i))
except TypeError:
base["data"][i] = getattr(self, i)
return base

cls.to_json = to_json
Expand All @@ -67,6 +70,7 @@ def to_str(self) -> str:
text = text.replace(f"<{i}>", str(v))

return text

cls.__str__ = to_str if cls().__str__() == "__not_set__" else cls.__str__

message_types[sg_type] = {
Expand Down Expand Up @@ -291,4 +295,3 @@ class Music(Base):
url: str = None
audio: str = None
title: str = None

2 changes: 2 additions & 0 deletions modules/Musics.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def search(name: str, num: int = 15) -> list:
async def download(song_id: int) -> tuple[bool, str, str]:
res = apis.track.GetTrackAudioV1([song_id])
url = res["data"][0]["url"]
if url is None:
return False, "无法获取歌曲URL,这可能是一个付费歌曲或该歌曲不存在", ""
md5 = res["data"][0]["md5"]
suffix = res["data"][0]["type"]
did = 0
Expand Down

0 comments on commit 60d603a

Please sign in to comment.