1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Add funkwhale command

This commit is contained in:
Steffo 2020-01-06 00:44:02 +01:00
parent e90221d1b6
commit 5ed03118c0
4 changed files with 27 additions and 2 deletions

View file

@ -2,7 +2,7 @@
[tool.poetry]
name = "royalpack"
version = "5.1.9"
version = "5.1.10"
description = "A Royalnet command pack for the Royal Games community"
authors = ["Stefano Pigozzi <ste.pigozzi@gmail.com>"]
license = "AGPL-3.0+"

View file

@ -27,6 +27,7 @@ from .ahnonlosoio import AhnonlosoioCommand
from .eat import EatCommand
from .pmots import PmotsCommand
from .peertube import PeertubeCommand
from .funkwhale import FunkwhaleCommand
from .eval import EvalCommand
from .exec import ExecCommand

View 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"]}'

View file

@ -1 +1 @@
semantic = "5.1.9"
semantic = "5.1.10"