mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-24 03:54:20 +00:00
Add funkwhale command
This commit is contained in:
parent
e90221d1b6
commit
5ed03118c0
4 changed files with 27 additions and 2 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "royalpack"
|
name = "royalpack"
|
||||||
version = "5.1.9"
|
version = "5.1.10"
|
||||||
description = "A Royalnet command pack for the Royal Games community"
|
description = "A Royalnet command pack for the Royal Games community"
|
||||||
authors = ["Stefano Pigozzi <ste.pigozzi@gmail.com>"]
|
authors = ["Stefano Pigozzi <ste.pigozzi@gmail.com>"]
|
||||||
license = "AGPL-3.0+"
|
license = "AGPL-3.0+"
|
||||||
|
|
|
@ -27,6 +27,7 @@ from .ahnonlosoio import AhnonlosoioCommand
|
||||||
from .eat import EatCommand
|
from .eat import EatCommand
|
||||||
from .pmots import PmotsCommand
|
from .pmots import PmotsCommand
|
||||||
from .peertube import PeertubeCommand
|
from .peertube import PeertubeCommand
|
||||||
|
from .funkwhale import FunkwhaleCommand
|
||||||
from .eval import EvalCommand
|
from .eval import EvalCommand
|
||||||
from .exec import ExecCommand
|
from .exec import ExecCommand
|
||||||
|
|
||||||
|
|
24
royalpack/commands/funkwhale.py
Normal file
24
royalpack/commands/funkwhale.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
from .play import PlayCommand
|
||||||
|
from royalnet.commands import *
|
||||||
|
import aiohttp
|
||||||
|
import urllib.parse
|
||||||
|
|
||||||
|
|
||||||
|
class FunkwhaleCommand(PlayCommand):
|
||||||
|
name: str = "funkwhale"
|
||||||
|
|
||||||
|
aliases = ["fw", "royalwhale", "rw"]
|
||||||
|
|
||||||
|
description: str = "Cerca un video su RoyalWhale e lo aggiunge alla coda della chat vocale."
|
||||||
|
|
||||||
|
syntax = "{ricerca}"
|
||||||
|
|
||||||
|
async def get_url(self, args):
|
||||||
|
search = urllib.parse.quote(args.joined(require_at_least=1))
|
||||||
|
async with aiohttp.ClientSession() as session:
|
||||||
|
async with session.get(self.config["Funkwhale"]["instance_url"] +
|
||||||
|
f"/api/v1/search?query={search}") as response:
|
||||||
|
j = await response.json()
|
||||||
|
if len(j["tracks"]) < 1:
|
||||||
|
raise InvalidInputError("Nessun video trovato.")
|
||||||
|
return f'{self.config["Funkwhale"]["instance_url"]}{j["tracks"][0]["listen_url"]}'
|
|
@ -1 +1 @@
|
||||||
semantic = "5.1.9"
|
semantic = "5.1.10"
|
||||||
|
|
Loading…
Reference in a new issue