From 31e8dacbd19411f2ddf1a65ac47a9383dfd27fb3 Mon Sep 17 00:00:00 2001 From: thekoc Date: Tue, 3 May 2016 14:33:17 +0800 Subject: [PATCH] fixed a bug where data might be empty string. --- main.py | 2 +- python3_main.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 3a48c42..881543e 100644 --- a/main.py +++ b/main.py @@ -40,7 +40,7 @@ r = requests.get(url, params=payload) contents = r.text d = json.loads(contents, encoding="utf-8") - if('data' not in d): + if d is not None and 'data' not in d or d['data'] == '': continue songlink = d["data"]["songList"][0]["songLink"] print "find songlink: " diff --git a/python3_main.py b/python3_main.py index e5dd065..0ce8d0b 100644 --- a/python3_main.py +++ b/python3_main.py @@ -31,7 +31,7 @@ r = requests.get(url, params=payload) contents = r.text d = json.loads(contents, encoding="utf-8") - if d is not None and 'data' not in d: + if d is not None and 'data' not in d or d['data'] == '': continue songid = d["data"]["song"][0]["songid"] print("find songid: %s" % songid)