Skip to content

Commit

Permalink
fixed a bug where data might be empty string.
Browse files Browse the repository at this point in the history
  • Loading branch information
thekoc authored and thekoc committed May 3, 2016
1 parent f9698ed commit 31e8dac
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: "
Expand Down
2 changes: 1 addition & 1 deletion python3_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 31e8dac

Please sign in to comment.