From c2c0831d8a256e5beea8e51ac2761fa7ca8c12c2 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Sun, 27 Jun 2021 18:33:53 +0800 Subject: [PATCH] neteasedown fix bug --- list.json | 2 +- neteasedown.py | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/list.json b/list.json index e70044c..c81d2d3 100644 --- a/list.json +++ b/list.json @@ -292,7 +292,7 @@ }, { "name": "neteasedown", - "version": "1.11", + "version": "1.12", "section": "daily", "maintainer": "xtaodada", "size": "15.6 kb", diff --git a/neteasedown.py b/neteasedown.py index 5d339cb..16f5854 100644 --- a/neteasedown.py +++ b/neteasedown.py @@ -209,18 +209,21 @@ def netease_single(id): data=data, ).get("data", []) if len(res_data_detail) > 0 and len(res_data) > 0: - item = res_data_detail[0] - singers = [s.get("name", "") for s in item.get("ar", {})] - song = {"id": item.get("id", ""), - "title": item.get("name", ""), - "singers": singers, - "singer": "、".join(singers), - "album": item.get("al", {}).get("name", ""), - "duration": int(item.get("dt", 0) / 1000), - "cover_url": item.get("al", {}).get("picUrl", ""), - "song_url": res_data[0].get("url", ""), - "rate": int(res_data[0].get("br", 0) / 1000)} - return song + try: + item = res_data_detail[0] + singers = [s.get("name", "") for s in item.get("ar", {})] + song = {"id": item.get("id", ""), + "title": item.get("name", ""), + "singers": singers, + "singer": "、".join(singers), + "album": item.get("al", {}).get("name", ""), + "duration": int(item.get("dt", 0) / 1000), + "cover_url": item.get("al", {}).get("picUrl", ""), + "song_url": res_data[0].get("url", ""), + "rate": int(res_data[0].get("br", 0) / 1000)} + return song + except TypeError: + raise DataError("Get song detail failed.") else: raise DataError("Get song detail failed.")