mirror of
https://github.com/oddluck/limnoria-plugins.git
synced 2025-04-29 06:51:12 -05:00
AzuraCast: fix error when no video
This commit is contained in:
parent
3e33f0eae8
commit
e6d5e29e14
@ -89,6 +89,7 @@ class AzuraCast(callbacks.Plugin):
|
|||||||
self.BASE_API.replace("/api/", ""), d["id"]
|
self.BASE_API.replace("/api/", ""), d["id"]
|
||||||
)
|
)
|
||||||
if self.VID_URL:
|
if self.VID_URL:
|
||||||
|
try:
|
||||||
data_url = self.VID_URL + "stats.json.php"
|
data_url = self.VID_URL + "stats.json.php"
|
||||||
data = self._fetchURL(data_url)
|
data = self._fetchURL(data_url)
|
||||||
d = data.get("applications")[0]
|
d = data.get("applications")[0]
|
||||||
@ -97,6 +98,8 @@ class AzuraCast(callbacks.Plugin):
|
|||||||
users = d.get("users")
|
users = d.get("users")
|
||||||
if users:
|
if users:
|
||||||
views = users.get("online")
|
views = users.get("online")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
if c and views:
|
if c and views:
|
||||||
viewers = " | Viewers: {}".format(views)
|
viewers = " | Viewers: {}".format(views)
|
||||||
watch = " | Video Player: {}?c={}".format(self.VID_URL, c)
|
watch = " | Video Player: {}?c={}".format(self.VID_URL, c)
|
||||||
@ -125,6 +128,7 @@ class AzuraCast(callbacks.Plugin):
|
|||||||
self.BASE_API.replace("/api/", ""), d["id"]
|
self.BASE_API.replace("/api/", ""), d["id"]
|
||||||
)
|
)
|
||||||
if self.VID_URL:
|
if self.VID_URL:
|
||||||
|
try:
|
||||||
data_url = self.VID_URL + "stats.json.php"
|
data_url = self.VID_URL + "stats.json.php"
|
||||||
data = self._fetchURL(data_url)
|
data = self._fetchURL(data_url)
|
||||||
d = data.get("applications")[i]
|
d = data.get("applications")[i]
|
||||||
@ -133,6 +137,8 @@ class AzuraCast(callbacks.Plugin):
|
|||||||
users = d.get("users")
|
users = d.get("users")
|
||||||
if users:
|
if users:
|
||||||
views = users.get("online")
|
views = users.get("online")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
if c and views:
|
if c and views:
|
||||||
viewers = " | Viewers: {}".format(views)
|
viewers = " | Viewers: {}".format(views)
|
||||||
watch = " | Video Player: {}?c={}".format(self.VID_URL, c)
|
watch = " | Video Player: {}?c={}".format(self.VID_URL, c)
|
||||||
@ -178,6 +184,7 @@ class AzuraCast(callbacks.Plugin):
|
|||||||
plr = " "
|
plr = " "
|
||||||
string = "There {}{}on {}".format(cur, plr, ircutils.bold(d["name"]))
|
string = "There {}{}on {}".format(cur, plr, ircutils.bold(d["name"]))
|
||||||
if self.VID_URL:
|
if self.VID_URL:
|
||||||
|
try:
|
||||||
url = self.VID_URL + "stats.json.php"
|
url = self.VID_URL + "stats.json.php"
|
||||||
data = self._fetchURL(url)
|
data = self._fetchURL(url)
|
||||||
d = data.get("applications")
|
d = data.get("applications")
|
||||||
@ -189,6 +196,8 @@ class AzuraCast(callbacks.Plugin):
|
|||||||
string += " and there are \x02{}\x02 viewers on the video stream.".format(
|
string += " and there are \x02{}\x02 viewers on the video stream.".format(
|
||||||
views
|
views
|
||||||
)
|
)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
output.append(string)
|
output.append(string)
|
||||||
else:
|
else:
|
||||||
# all stations?
|
# all stations?
|
||||||
@ -206,6 +215,7 @@ class AzuraCast(callbacks.Plugin):
|
|||||||
plr = " "
|
plr = " "
|
||||||
string = "There {}{}on {}".format(cur, plr, ircutils.bold(d["name"]))
|
string = "There {}{}on {}".format(cur, plr, ircutils.bold(d["name"]))
|
||||||
if self.VID_URL:
|
if self.VID_URL:
|
||||||
|
try:
|
||||||
url = self.VID_URL + "stats.json.php"
|
url = self.VID_URL + "stats.json.php"
|
||||||
data = self._fetchURL(url)
|
data = self._fetchURL(url)
|
||||||
d = data.get("applications")
|
d = data.get("applications")
|
||||||
@ -214,9 +224,12 @@ class AzuraCast(callbacks.Plugin):
|
|||||||
if d:
|
if d:
|
||||||
views = d.get("online")
|
views = d.get("online")
|
||||||
if views:
|
if views:
|
||||||
string += " and there are \x02{}\x02 viewers on the video stream.".format(
|
string += (
|
||||||
views
|
" and there are \x02{}\x02 viewers on the video stream."
|
||||||
|
.format(views)
|
||||||
)
|
)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
i += 1
|
i += 1
|
||||||
output.append(string)
|
output.append(string)
|
||||||
for string in output:
|
for string in output:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user