Handle !soundcloud returning no results (soundcloud.py)

This commit is contained in:
jesopo 2019-01-08 10:14:03 +00:00
parent 38b7a1dadf
commit 93336efd38

View file

@ -48,15 +48,18 @@ class Module(ModuleManager.BaseModule):
get_params=get_params, json=True)
if page:
page = page.data[0] if has_query else page
title = page["title"]
user = page["user"]["username"]
duration = time.strftime("%H:%M:%S", time.gmtime(page[
"duration"]/1000))
if duration.startswith("00:"):
duration = duration[3:]
link = page["permalink_url"]
event["stdout"].write("%s [%s] (posted by %s) %s" % (title,
duration, user, link))
if len(page.data):
page = page.data[0] if has_query else page
title = page["title"]
user = page["user"]["username"]
duration = time.strftime("%H:%M:%S", time.gmtime(page[
"duration"]/1000))
if duration.startswith("00:"):
duration = duration[3:]
link = page["permalink_url"]
event["stdout"].write("%s [%s] (posted by %s) %s" % (title,
duration, user, link))
else:
event["stderr"].write("No results found")
else:
raise utils.EventsResultsError()