mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
[Streams] Smashcast removal. (#5040)
* Remove smashcast * style * remove smash from cog guides
This commit is contained in:
parent
737e4cc399
commit
54e5307307
@ -72,7 +72,7 @@ from installing and updating, every part of the bot can be controlled from withi
|
|||||||
- Moderation features (kick/ban/softban/hackban, mod-log, filter, chat cleanup)
|
- Moderation features (kick/ban/softban/hackban, mod-log, filter, chat cleanup)
|
||||||
- Trivia (lists are included and can be easily added)
|
- Trivia (lists are included and can be easily added)
|
||||||
- Music features (YouTube, SoundCloud, local files, playlists, queues)
|
- Music features (YouTube, SoundCloud, local files, playlists, queues)
|
||||||
- Stream alerts (Twitch, Youtube, Hitbox, Picarto)
|
- Stream alerts (Twitch, Youtube, Picarto)
|
||||||
- Bank (slot machine, user credits)
|
- Bank (slot machine, user credits)
|
||||||
- Custom commands
|
- Custom commands
|
||||||
- Imgur/gif search
|
- Imgur/gif search
|
||||||
|
|||||||
@ -27,7 +27,6 @@ Supported streaming services are:
|
|||||||
|
|
||||||
- Twitch
|
- Twitch
|
||||||
- Youtube
|
- Youtube
|
||||||
- Smashcast
|
|
||||||
- Picarto
|
- Picarto
|
||||||
|
|
||||||
Youtube and Twitch both require setting authentication
|
Youtube and Twitch both require setting authentication
|
||||||
@ -353,26 +352,6 @@ Check if a Picarto channel is live.
|
|||||||
|
|
||||||
* ``<channel_name>``: The Picarto channel to check.
|
* ``<channel_name>``: The Picarto channel to check.
|
||||||
|
|
||||||
.. _streams-command-smashcast:
|
|
||||||
|
|
||||||
^^^^^^^^^
|
|
||||||
smashcast
|
|
||||||
^^^^^^^^^
|
|
||||||
|
|
||||||
**Syntax**
|
|
||||||
|
|
||||||
.. code-block:: none
|
|
||||||
|
|
||||||
[p]smashcast <channel_name>
|
|
||||||
|
|
||||||
**Description**
|
|
||||||
|
|
||||||
Check if a Smashcast channel is live.
|
|
||||||
|
|
||||||
**Arguments**
|
|
||||||
|
|
||||||
* ``<channel_name>``: The Smashcast channel to check.
|
|
||||||
|
|
||||||
.. _streams-command-twitchstream:
|
.. _streams-command-twitchstream:
|
||||||
|
|
||||||
^^^^^^^^^^^^
|
^^^^^^^^^^^^
|
||||||
@ -466,27 +445,6 @@ specified Picarto channel.
|
|||||||
|
|
||||||
* ``<channel_name>``: The Picarto channel to toggle the alert for.
|
* ``<channel_name>``: The Picarto channel to toggle the alert for.
|
||||||
|
|
||||||
.. _streams-command-streamalert-smashcast:
|
|
||||||
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
streamalert smashcast
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
**Syntax**
|
|
||||||
|
|
||||||
.. code-block:: none
|
|
||||||
|
|
||||||
[p]streamalert smashcast <channel_name>
|
|
||||||
|
|
||||||
**Description**
|
|
||||||
|
|
||||||
Toggle alerts in the current channel for the
|
|
||||||
specified Smashcast channel.
|
|
||||||
|
|
||||||
**Arguments**
|
|
||||||
|
|
||||||
* ``<channel_name>``: The Smashcast channel to toggle the alert for.
|
|
||||||
|
|
||||||
.. _streams-command-streamalert-twitch-channel:
|
.. _streams-command-streamalert-twitch-channel:
|
||||||
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|||||||
@ -6,7 +6,6 @@ from redbot.core.utils._internal_utils import send_to_owners_with_prefix_replace
|
|||||||
from redbot.core.utils.chat_formatting import escape, pagify
|
from redbot.core.utils.chat_formatting import escape, pagify
|
||||||
|
|
||||||
from .streamtypes import (
|
from .streamtypes import (
|
||||||
HitboxStream,
|
|
||||||
PicartoStream,
|
PicartoStream,
|
||||||
Stream,
|
Stream,
|
||||||
TwitchStream,
|
TwitchStream,
|
||||||
@ -234,12 +233,6 @@ class Streams(commands.Cog):
|
|||||||
)
|
)
|
||||||
await self.check_online(ctx, stream)
|
await self.check_online(ctx, stream)
|
||||||
|
|
||||||
@commands.command()
|
|
||||||
async def smashcast(self, ctx: commands.Context, channel_name: str):
|
|
||||||
"""Check if a smashcast channel is live."""
|
|
||||||
stream = HitboxStream(_bot=self.bot, name=channel_name)
|
|
||||||
await self.check_online(ctx, stream)
|
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def picarto(self, ctx: commands.Context, channel_name: str):
|
async def picarto(self, ctx: commands.Context, channel_name: str):
|
||||||
"""Check if a Picarto channel is live."""
|
"""Check if a Picarto channel is live."""
|
||||||
@ -249,7 +242,7 @@ class Streams(commands.Cog):
|
|||||||
async def check_online(
|
async def check_online(
|
||||||
self,
|
self,
|
||||||
ctx: commands.Context,
|
ctx: commands.Context,
|
||||||
stream: Union[PicartoStream, HitboxStream, YoutubeStream, TwitchStream],
|
stream: Union[PicartoStream, YoutubeStream, TwitchStream],
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
info = await stream.is_online()
|
info = await stream.is_online()
|
||||||
@ -323,11 +316,6 @@ class Streams(commands.Cog):
|
|||||||
"""Toggle alerts in this channel for a YouTube stream."""
|
"""Toggle alerts in this channel for a YouTube stream."""
|
||||||
await self.stream_alert(ctx, YoutubeStream, channel_name_or_id)
|
await self.stream_alert(ctx, YoutubeStream, channel_name_or_id)
|
||||||
|
|
||||||
@streamalert.command(name="smashcast")
|
|
||||||
async def smashcast_alert(self, ctx: commands.Context, channel_name: str):
|
|
||||||
"""Toggle alerts in this channel for a Smashcast stream."""
|
|
||||||
await self.stream_alert(ctx, HitboxStream, channel_name)
|
|
||||||
|
|
||||||
@streamalert.command(name="picarto")
|
@streamalert.command(name="picarto")
|
||||||
async def picarto_alert(self, ctx: commands.Context, channel_name: str):
|
async def picarto_alert(self, ctx: commands.Context, channel_name: str):
|
||||||
"""Toggle alerts in this channel for a Picarto stream."""
|
"""Toggle alerts in this channel for a Picarto stream."""
|
||||||
|
|||||||
@ -435,45 +435,6 @@ class TwitchStream(Stream):
|
|||||||
return "<{0.__class__.__name__}: {0.name} (ID: {0.id})>".format(self)
|
return "<{0.__class__.__name__}: {0.name} (ID: {0.id})>".format(self)
|
||||||
|
|
||||||
|
|
||||||
class HitboxStream(Stream):
|
|
||||||
|
|
||||||
token_name = None # This streaming services don't currently require an API key
|
|
||||||
|
|
||||||
async def is_online(self):
|
|
||||||
url = "https://api.smashcast.tv/media/live/" + self.name
|
|
||||||
|
|
||||||
async with aiohttp.ClientSession() as session:
|
|
||||||
async with session.get(url) as r:
|
|
||||||
# data = await r.json(encoding='utf-8')
|
|
||||||
data = await r.text()
|
|
||||||
data = json.loads(data, strict=False)
|
|
||||||
if "livestream" not in data:
|
|
||||||
raise StreamNotFound()
|
|
||||||
elif data["livestream"][0]["media_is_live"] == "0":
|
|
||||||
# self.already_online = False
|
|
||||||
raise OfflineStream()
|
|
||||||
elif data["livestream"][0]["media_is_live"] == "1":
|
|
||||||
# self.already_online = True
|
|
||||||
return self.make_embed(data)
|
|
||||||
|
|
||||||
raise APIError(data)
|
|
||||||
|
|
||||||
def make_embed(self, data):
|
|
||||||
base_url = "https://edge.sf.hitbox.tv"
|
|
||||||
livestream = data["livestream"][0]
|
|
||||||
channel = livestream["channel"]
|
|
||||||
url = channel["channel_link"]
|
|
||||||
embed = discord.Embed(title=livestream["media_status"], url=url, color=0x98CB00)
|
|
||||||
embed.set_author(name=livestream["media_name"])
|
|
||||||
embed.add_field(name=_("Followers"), value=humanize_number(channel["followers"]))
|
|
||||||
embed.set_thumbnail(url=base_url + channel["user_logo"])
|
|
||||||
if livestream["media_thumbnail"]:
|
|
||||||
embed.set_image(url=rnd(base_url + livestream["media_thumbnail"]))
|
|
||||||
embed.set_footer(text=_("Playing: ") + livestream["category_name"])
|
|
||||||
|
|
||||||
return embed
|
|
||||||
|
|
||||||
|
|
||||||
class PicartoStream(Stream):
|
class PicartoStream(Stream):
|
||||||
|
|
||||||
token_name = None # This streaming services don't currently require an API key
|
token_name = None # This streaming services don't currently require an API key
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user