mirror of
https://github.com/oddluck/limnoria-plugins.git
synced 2025-04-29 15:01:11 -05:00
AzuraCast: add video player link
This commit is contained in:
parent
2e6f9141da
commit
3b46eda5fd
@ -41,9 +41,7 @@ conf.registerGlobalValue(
|
|||||||
)
|
)
|
||||||
|
|
||||||
conf.registerGlobalValue(
|
conf.registerGlobalValue(
|
||||||
AzuraCast,
|
AzuraCast, "VideoURL", registry.String("", _("""Video URL for your radio"""))
|
||||||
"VideoURL",
|
|
||||||
registry.String("", _("""Video URL. Should end in /stats.json.php""")),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
||||||
|
@ -29,7 +29,7 @@ class AzuraCast(callbacks.Plugin):
|
|||||||
self.__parent.__init__(irc)
|
self.__parent.__init__(irc)
|
||||||
self.BASE_API = self.registryValue("AzuraAPI")
|
self.BASE_API = self.registryValue("AzuraAPI")
|
||||||
self.PUB_URL = self.registryValue("PublicURL") + "#{name}"
|
self.PUB_URL = self.registryValue("PublicURL") + "#{name}"
|
||||||
self.VID_URL = self.registryValue("VideoURL")
|
self.VID_URL = self.registryValue("VideoURL").rstrip("stats.json.php")
|
||||||
|
|
||||||
def _fetchURL(self, url, headers=None):
|
def _fetchURL(self, url, headers=None):
|
||||||
return requests.get(url, headers=headers).json()
|
return requests.get(url, headers=headers).json()
|
||||||
@ -83,13 +83,22 @@ class AzuraCast(callbacks.Plugin):
|
|||||||
url = " | {}".format(d["public_url"]) if d["public_url"] else ""
|
url = " | {}".format(d["public_url"]) if d["public_url"] else ""
|
||||||
np = "{}".format(d["nowplaying"]["song"]["text"])
|
np = "{}".format(d["nowplaying"]["song"]["text"])
|
||||||
listeners = " | Listeners: {}".format(d["listeners"]["current"])
|
listeners = " | Listeners: {}".format(d["listeners"]["current"])
|
||||||
listen = " | Audio player link: {}/public/{}/playlist/pls".format(
|
listen = " | Audio Player: {}/public/{}/playlist/pls".format(
|
||||||
self.BASE_API.replace("/api/", ""), d["id"]
|
self.BASE_API.replace("/api/", ""), d["id"]
|
||||||
)
|
)
|
||||||
string = "{} {}{}{}{}{}".format(prefix, np, album, listeners, url, listen)
|
string = "{} {}{}{}{}{}".format(prefix, np, album, listeners, url, listen)
|
||||||
|
if self.VID_URL:
|
||||||
|
url = self.VID_URL + "stats.json.php"
|
||||||
|
data = self._fetchURL(url)
|
||||||
|
d = data.get("applications")[0]
|
||||||
|
if d:
|
||||||
|
c = d.get("channelName")
|
||||||
|
if c:
|
||||||
|
string += " | Video Player: {}?c={}".format(self.VID_URL, c)
|
||||||
output.append(string)
|
output.append(string)
|
||||||
else:
|
else:
|
||||||
# all stations?
|
# all stations?
|
||||||
|
i = 0
|
||||||
for s, d in data.items():
|
for s, d in data.items():
|
||||||
prefix = ircutils.bold("Now Playing on {}:".format(d["name"]))
|
prefix = ircutils.bold("Now Playing on {}:".format(d["name"]))
|
||||||
album = (
|
album = (
|
||||||
@ -100,12 +109,21 @@ class AzuraCast(callbacks.Plugin):
|
|||||||
url = " | {}".format(d["public_url"]) if d["public_url"] else ""
|
url = " | {}".format(d["public_url"]) if d["public_url"] else ""
|
||||||
np = "{}".format(d["nowplaying"]["song"]["text"])
|
np = "{}".format(d["nowplaying"]["song"]["text"])
|
||||||
listeners = " | Listeners: {}".format(d["listeners"]["current"])
|
listeners = " | Listeners: {}".format(d["listeners"]["current"])
|
||||||
listen = " | Audio player link: {}/public/{}/playlist/pls".format(
|
listen = " | Audio Player: {}/public/{}/playlist/pls".format(
|
||||||
self.BASE_API.replace("/api/", ""), d["id"]
|
self.BASE_API.replace("/api/", ""), d["id"]
|
||||||
)
|
)
|
||||||
string = "{} {}{}{}{}{}".format(
|
string = "{} {}{}{}{}{}".format(
|
||||||
prefix, np, album, listeners, url, listen
|
prefix, np, album, listeners, url, listen
|
||||||
)
|
)
|
||||||
|
if self.VID_URL:
|
||||||
|
url = self.VID_URL + "stats.json.php"
|
||||||
|
data = self._fetchURL(url)
|
||||||
|
d = data.get("applications")[i]
|
||||||
|
if d:
|
||||||
|
c = d.get("channelName")
|
||||||
|
if c:
|
||||||
|
string += " | Video Player: {}?c={}".format(self.VID_URL, c)
|
||||||
|
i += 1
|
||||||
output.append(string)
|
output.append(string)
|
||||||
for string in output:
|
for string in output:
|
||||||
irc.reply(string)
|
irc.reply(string)
|
||||||
@ -139,9 +157,22 @@ class AzuraCast(callbacks.Plugin):
|
|||||||
cur = "are no listeners"
|
cur = "are no listeners"
|
||||||
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:
|
||||||
|
url = self.VID_URL + "stats.json.php"
|
||||||
|
data = self._fetchURL(url)
|
||||||
|
d = data.get("applications")
|
||||||
|
if d:
|
||||||
|
d = d[0].get("users")
|
||||||
|
if d:
|
||||||
|
views = d.get("online")
|
||||||
|
if views:
|
||||||
|
string += " and there are \x02{}\x02 viewers on the video stream.".format(
|
||||||
|
views
|
||||||
|
)
|
||||||
output.append(string)
|
output.append(string)
|
||||||
else:
|
else:
|
||||||
# all stations?
|
# all stations?
|
||||||
|
i = 0
|
||||||
for s, d in data.items():
|
for s, d in data.items():
|
||||||
count = d["listeners"]["current"]
|
count = d["listeners"]["current"]
|
||||||
if count > 1 and count != 0:
|
if count > 1 and count != 0:
|
||||||
@ -154,16 +185,19 @@ class AzuraCast(callbacks.Plugin):
|
|||||||
cur = "are no listeners"
|
cur = "are no listeners"
|
||||||
plr = " "
|
plr = " "
|
||||||
string = "There {}{}on {}".format(cur, plr, ircutils.bold(d["name"]))
|
string = "There {}{}on {}".format(cur, plr, ircutils.bold(d["name"]))
|
||||||
output.append(string)
|
if self.VID_URL:
|
||||||
if self.VID_URL:
|
url = self.VID_URL + "stats.json.php"
|
||||||
data = self._fetchURL(self.VID_URL)
|
data = self._fetchURL(url)
|
||||||
d = data.get("applications")
|
d = data.get("applications")
|
||||||
if d:
|
if d:
|
||||||
d = d[0].get("users")
|
d = d[i].get("users")
|
||||||
if d:
|
if d:
|
||||||
views = d.get("online")
|
views = d.get("online")
|
||||||
if views:
|
if views:
|
||||||
string = "There are {} viewers on the video stream".format(views)
|
string += " and there are \x02{}\x02 viewers on the video stream.".format(
|
||||||
|
views
|
||||||
|
)
|
||||||
|
i += 1
|
||||||
output.append(string)
|
output.append(string)
|
||||||
for string in output:
|
for string in output:
|
||||||
irc.reply(string)
|
irc.reply(string)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user