add providers
This commit is contained in:
parent
6bb90fd02e
commit
9e164ff0f5
36
bot.py
36
bot.py
@ -2,8 +2,10 @@
|
||||
|
||||
import os
|
||||
from urllib.parse import urlparse, parse_qs
|
||||
import aiohttp
|
||||
import discord
|
||||
|
||||
|
||||
DISCORD_TOKEN = os.getenv("DISCORD_TOKEN")
|
||||
DISCORD_CHANNEL = int(os.getenv("DISCORD_CHANNEL"))
|
||||
DISCORD_GUILD = int(os.getenv("DISCORD_GUILD"))
|
||||
@ -45,6 +47,40 @@ class CustomClient(discord.Client):
|
||||
content=f"https://stream.purser.it/{video_id}?provider=youtube&direct=true"
|
||||
)
|
||||
|
||||
elif "seafile" in url.hostname:
|
||||
stripped = url.path.strip("/")
|
||||
async with aiohttp.ClientSession(
|
||||
timeout=aiohttp.ClientTimeout(total=5)
|
||||
) as session:
|
||||
resp = await session.head(
|
||||
"https://stream.purser.it/{stripped}/?provider=seafile&raw=true"
|
||||
)
|
||||
raw = (
|
||||
ctype := resp.headers.get("content-type")
|
||||
) and "image" in ctype
|
||||
|
||||
await message.reply(
|
||||
content=f"https://stream.purser.it/{stripped}/?provider=seafile&raw={raw}"
|
||||
)
|
||||
|
||||
elif "twitch" in url.hostname:
|
||||
stripped = url.path.strip("/")
|
||||
await message.reply(
|
||||
content=f"https://stream.purser.it/{stripped}?provider=twitch"
|
||||
)
|
||||
|
||||
elif "twitter" in url.hostname:
|
||||
stripped = url.path.strip("/")
|
||||
await message.reply(
|
||||
content=f"https://stream.purser.it/{stripped}?provider=twitter"
|
||||
)
|
||||
|
||||
elif "x.com" in url.hostname:
|
||||
stripped = url.path.strip("/")
|
||||
await message.reply(
|
||||
content=f"https://stream.purser.it/{stripped}?provider=twitter"
|
||||
)
|
||||
|
||||
|
||||
intents = discord.Intents.default()
|
||||
intents.message_content = True
|
||||
|
Loading…
Reference in New Issue
Block a user