Recherche avancée

Médias (0)

Mot : - Tags -/api

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (45)

  • Personnaliser les catégories

    21 juin 2013, par

    Formulaire de création d’une catégorie
    Pour ceux qui connaissent bien SPIP, une catégorie peut être assimilée à une rubrique.
    Dans le cas d’un document de type catégorie, les champs proposés par défaut sont : Texte
    On peut modifier ce formulaire dans la partie :
    Administration > Configuration des masques de formulaire.
    Dans le cas d’un document de type média, les champs non affichés par défaut sont : Descriptif rapide
    Par ailleurs, c’est dans cette partie configuration qu’on peut indiquer le (...)

  • Librairies et logiciels spécifiques aux médias

    10 décembre 2010, par

    Pour un fonctionnement correct et optimal, plusieurs choses sont à prendre en considération.
    Il est important, après avoir installé apache2, mysql et php5, d’installer d’autres logiciels nécessaires dont les installations sont décrites dans les liens afférants. Un ensemble de librairies multimedias (x264, libtheora, libvpx) utilisées pour l’encodage et le décodage des vidéos et sons afin de supporter le plus grand nombre de fichiers possibles. Cf. : ce tutoriel ; FFMpeg avec le maximum de décodeurs et (...)

  • Activation de l’inscription des visiteurs

    12 avril 2011, par

    Il est également possible d’activer l’inscription des visiteurs ce qui permettra à tout un chacun d’ouvrir soit même un compte sur le canal en question dans le cadre de projets ouverts par exemple.
    Pour ce faire, il suffit d’aller dans l’espace de configuration du site en choisissant le sous menus "Gestion des utilisateurs". Le premier formulaire visible correspond à cette fonctionnalité.
    Par défaut, MediaSPIP a créé lors de son initialisation un élément de menu dans le menu du haut de la page menant (...)

Sur d’autres sites (8267)

  • How do I loop audio files in discord.py ?

    25 septembre 2021, par Jonah Alexander

    I cannot for the life of me find or figure out a solution that works anymore. here is both the bit of code that is actually important, and the whole file if you would like to see that too

    


        async def play(self, ctx: commands.Context, url, lp):
        channel = ctx.author.voice.channel

        if lp == 'loop':
            await channel.connect()

            async with ctx.typing():
                player = await YTDLSource.from_url(url, loop=self.bot.loop)
                ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
            await ctx.send('Now playing: {}'.format(player.title))
            while True:
                if not ctx.voice_client.is_playing():
                    async with ctx.typing():
                        ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
                time.sleep(0.5)
        else:
            async with ctx.typing():
                await channel.connect()
                player = await YTDLSource.from_url(url, loop=self.bot.loop)
                ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
            await ctx.send('Now playing: {}'.format(player.title))


    


    from discord.ext import commands
import ffmpeg
import youtube_dl.YoutubeDL
import asyncio
import time


ytdl_format_options = {
    'format': 'bestaudio/best',
    'outtmpl': '%(extractor)s-%(id)s-%(title)s.%(ext)s',
    'restrictfilenames': True,
    'noplaylist': True,
    'nocheckcertificate': True,
    'ignoreerrors': False,
    'logtostderr': False,
    'quiet': True,
    'no_warnings': True,
    'default_search': 'auto',
    'source_address': '0.0.0.0'  # bind to ipv4 since ipv6 addresses cause issues sometimes
}

ffmpeg_options = {
    'options': '-vn'
}


ytdl = youtube_dl.YoutubeDL(ytdl_format_options)


class YTDLSource(discord.PCMVolumeTransformer):
    def __init__(self, source, *, data, volume=0.5):
        super().__init__(source, volume)

        self.data = data

        self.title = data.get('title')
        self.url = data.get('url')

    @classmethod
    async def from_url(cls, url, *, loop=None, stream=False):
        loop = loop or asyncio.get_event_loop()
        data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=not stream))

        if 'entries' in data:
            # take first item from a playlist
            data = data['entries'][0]

        filename = data['url'] if stream else ytdl.prepare_filename(data)
        return cls(discord.FFmpegPCMAudio(filename, **ffmpeg_options), data=data)


class MyBoi(commands.Cog):
    def __init__(self, bot: commands.Bot):
        self.bot = bot
        self.voice_states = {}

    @commands.command(name='leave')
    async def leave(self, ctx: commands.Context):
        await ctx.voice_client.disconnect()

    @commands.command(name='play')
    async def play(self, ctx: commands.Context, url, lp):
        channel = ctx.author.voice.channel

        if lp == 'loop':
            await channel.connect()

            async with ctx.typing():
                player = await YTDLSource.from_url(url, loop=self.bot.loop)
                ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
            await ctx.send('Now playing: {}'.format(player.title))
            while True:
                if not ctx.voice_client.is_playing():
                    async with ctx.typing():
                        ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
                time.sleep(0.5)
        else:
            async with ctx.typing():
                await channel.connect()
                player = await YTDLSource.from_url(url, loop=self.bot.loop)
                ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
            await ctx.send('Now playing: {}'.format(player.title))


intents = discord.Intents.all()

clnt = commands.Bot(command_prefix='#', intents=intents)
clnt.add_cog(MyBoi(clnt))

lop = {0: False}
plr = {}


@clnt.event
async def on_ready():
    print("ready")


clnt.run("the actual key normally")


    


    is the code poorly made and/or badly organized ? probably. but this is a personal project and did not expect to be sharing this with anyone. If you need clarification on anything lmk.

    


    with the code here, the issue im getting is when I do the looped version, the bot disconnects for a frame and reconnects, then I get this error

    


    


    discord.ext.commands.errors.CommandInvokeError : Command raised an exception : ClientException : Not connected to voice.

    


    


    the bot does not disconnect immediately when not using the looped version, and trying to manually reconnect it at the start of the loop gives me an error saying it's already connected.

    


    also sidenote I did not write the YTDLSource class or the ytdl_format_options.

    


  • avformat/scd : add demuxer

    1er décembre 2021, par Zane van Iperen
    avformat/scd : add demuxer
    

    Adds demuxer for Square Enux SCD files.

    Based off [1] and personal investigation.

    This has only been tested against Drakengard 3 (PS3) *_SCD.XXX files
    (big-endian). As it is highly likely that FFXIV (PC) files are little-endian,
    this demuxer is marked as experimental until this can be confirmed.

    [1] : http://ffxivexplorer.fragmenterworks.com/research/scd%20files.txt

    Reviewed-by : Peter Ross <pross@xvid.org>
    Reviewed-by : Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
    Signed-off-by : Zane van Iperen <zane@zanevaniperen.com>

    • [DH] libavformat/Makefile
    • [DH] libavformat/allformats.c
    • [DH] libavformat/scd.c
  • ytdl python "KeyError : formats"

    7 juillet 2022, par Mondumkreisung

    Im trying to make a discord music bot for personal use, since groovy and rythm got shut down.&#xA;It's working okay-ish I guess, but im having a problem with ytdl.&#xA;typing "-play" and an url is working just like intended, but i cant type "-play 'song name'".&#xA;Typing "-play example" gives me this :

    &#xA;

    [download] Downloading playlist: example&#xA;[youtube:search] query "example": Downloading page 1&#xA;[youtube:search] playlist example: Downloading 1 videos&#xA;[download] Downloading video 1 of 1&#xA;[youtube] CLXt3yh2g0s: Downloading webpage&#xA;Ignoring exception in command play:&#xA;[download] Finished downloading playlist: example&#xA;Traceback (most recent call last):&#xA;  File "C:\Users\Dennis\PycharmProjects\groovy&#x27;s true successor\venv\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped&#xA;    ret = await coro(*args, **kwargs)&#xA;  File "C:\Users\Dennis\PycharmProjects\groovy&#x27;s true successor\voice.py", line 53, in play&#xA;    url2 = info[&#x27;formats&#x27;][0][&#x27;url&#x27;]&#xA;KeyError: &#x27;formats&#x27;&#xA;&#xA;The above exception was the direct cause of the following exception:&#xA;&#xA;Traceback (most recent call last):&#xA;  File "C:\Users\Dennis\PycharmProjects\groovy&#x27;s true successor\venv\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke&#xA;    await ctx.command.invoke(ctx)&#xA;  File "C:\Users\Dennis\PycharmProjects\groovy&#x27;s true successor\venv\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke&#xA;    await injected(*ctx.args, **ctx.kwargs)&#xA;  File "C:\Users\Dennis\PycharmProjects\groovy&#x27;s true successor\venv\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped&#xA;    raise CommandInvokeError(exc) from exc&#xA;discord.ext.commands.errors.CommandInvokeError: Command raised an exception: KeyError: &#x27;formats&#x27;&#xA;

    &#xA;

    im fairly new to coding, so im sorry if somethings weird to understand.

    &#xA;

    okay, so : typing -play with an url works fine, but typing -play with the song name doesnt. its only searching for the first word, downloads the first searchresult and then "crashes".

    &#xA;

    so "-play Rick Astley - Never Gonna Give You Up" for example only searches for "Rick" and then it says something about KeyError : 'formats'&#xA;Here is my code :

    &#xA;

    @client.command()&#xA;async def play(ctx, url):&#xA;    channel = ctx.author.voice.channel&#xA;    voice = discord.utils.get(client.voice_clients, guild=ctx.guild)&#xA;    if voice and voice.is_connected():&#xA;        pass&#xA;    else:&#xA;        await channel.connect()&#xA;&#xA;    ffmpeg_opts = {&#x27;before_options&#x27;: &#x27;-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5&#x27;, &#x27;options&#x27;: &#x27;-vn&#x27;}&#xA;    ydl_opts = {&#x27;format&#x27;: "bestaudio/best", &#x27;default_search&#x27;: &#x27;auto&#x27;}&#xA;    vc = ctx.voice_client&#xA;&#xA;    with youtube_dl.YoutubeDL(ydl_opts) as ydl:&#xA;        info = ydl.extract_info(url, download=False)&#xA;        url2 = info[&#x27;formats&#x27;][0][&#x27;url&#x27;]&#xA;        source = await discord.FFmpegOpusAudio.from_probe(url2, **ffmpeg_opts)&#xA;        vc.play(source)&#xA;

    &#xA;