[Streams] Mixer removal (#4072)

* [streams] Mixer is dead soon

* remove Mixer from readme
This commit is contained in:
Jamie 2020-07-29 00:38:03 +01:00 committed by GitHub
parent e0616c37a9
commit 57247c5d87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 58 deletions

View File

@ -69,7 +69,7 @@ from installation and updating, every part of the bot can be controlled from wit
- 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, Mixer, Hitbox, Picarto) - Stream alerts (Twitch, Youtube, Hitbox, Picarto)
- Bank (slot machine, user credits) - Bank (slot machine, user credits)
- Custom commands - Custom commands
- Imgur/gif search - Imgur/gif search

View File

@ -7,7 +7,6 @@ from redbot.core.utils.chat_formatting import escape, pagify
from .streamtypes import ( from .streamtypes import (
HitboxStream, HitboxStream,
MixerStream,
PicartoStream, PicartoStream,
Stream, Stream,
TwitchStream, TwitchStream,
@ -40,7 +39,7 @@ log = logging.getLogger("red.core.cogs.Streams")
class Streams(commands.Cog): class Streams(commands.Cog):
"""Various commands relating to streaming platforms. """Various commands relating to streaming platforms.
You can check if a Twitch, YouTube, Picarto or Mixer stream is You can check if a Twitch, YouTube or Picarto stream is
currently live. currently live.
""" """
@ -228,12 +227,6 @@ class Streams(commands.Cog):
stream = HitboxStream(name=channel_name) stream = HitboxStream(name=channel_name)
await self.check_online(ctx, stream) await self.check_online(ctx, stream)
@commands.command()
async def mixer(self, ctx: commands.Context, channel_name: str):
"""Check if a Mixer channel is live."""
stream = MixerStream(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."""
@ -243,7 +236,7 @@ class Streams(commands.Cog):
async def check_online( async def check_online(
self, self,
ctx: commands.Context, ctx: commands.Context,
stream: Union[PicartoStream, MixerStream, HitboxStream, YoutubeStream, TwitchStream], stream: Union[PicartoStream, HitboxStream, YoutubeStream, TwitchStream],
): ):
try: try:
info = await stream.is_online() info = await stream.is_online()
@ -313,11 +306,6 @@ class Streams(commands.Cog):
"""Toggle alerts in this channel for a Hitbox stream.""" """Toggle alerts in this channel for a Hitbox stream."""
await self.stream_alert(ctx, HitboxStream, channel_name) await self.stream_alert(ctx, HitboxStream, channel_name)
@streamalert.command(name="mixer")
async def mixer_alert(self, ctx: commands.Context, channel_name: str):
"""Toggle alerts in this channel for a Mixer stream."""
await self.stream_alert(ctx, MixerStream, 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."""

View File

@ -359,49 +359,6 @@ class HitboxStream(Stream):
return embed return embed
class MixerStream(Stream):
token_name = None # This streaming services don't currently require an API key
async def is_online(self):
url = "https://mixer.com/api/v1/channels/" + self.name
async with aiohttp.ClientSession() as session:
async with session.get(url) as r:
data = await r.text(encoding="utf-8")
if r.status == 200:
data = json.loads(data, strict=False)
if data["online"] is True:
# self.already_online = True
return self.make_embed(data)
else:
# self.already_online = False
raise OfflineStream()
elif r.status == 404:
raise StreamNotFound()
else:
raise APIError()
def make_embed(self, data):
default_avatar = "https://mixer.com/_latest/assets/images/main/avatars/default.jpg"
user = data["user"]
url = "https://mixer.com/" + data["token"]
embed = discord.Embed(title=data["name"], url=url)
embed.set_author(name=user["username"])
embed.add_field(name=_("Followers"), value=humanize_number(data["numFollowers"]))
embed.add_field(name=_("Total views"), value=humanize_number(data["viewersTotal"]))
if user["avatarUrl"]:
embed.set_thumbnail(url=user["avatarUrl"])
else:
embed.set_thumbnail(url=default_avatar)
if data["thumbnail"]:
embed.set_image(url=rnd(data["thumbnail"]["url"]))
embed.color = 0x4C90F3 # pylint: disable=assigning-non-slot
if data["type"] is not None:
embed.set_footer(text=_("Playing: ") + data["type"]["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