Recherche avancée

Médias (10)

Mot : - Tags -/wav

Autres articles (67)

  • Les tâches Cron régulières de la ferme

    1er décembre 2010, par

    La gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
    Le super Cron (gestion_mutu_super_cron)
    Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

  • Contribute to documentation

    13 avril 2011

    Documentation is vital to the development of improved technical capabilities.
    MediaSPIP welcomes documentation by users as well as developers - including : critique of existing features and functions articles contributed by developers, administrators, content producers and editors screenshots to illustrate the above translations of existing documentation into other languages
    To contribute, register to the project users’ mailing (...)

Sur d’autres sites (7123)

  • How do I add a queue to my music bot using Discrod.py FFmpeg and youtube_dl ?

    28 septembre 2022, par Виктор Лисичкин

    I'm writing my bot for discord, I can't figure out how to track the end of a song to lose the next one. I sort of figured out the piece of music, but I don't fully understand what to do next. Here is my code for main.py

    


    from discord.ext import commands, tasks
from config import settings
from music_cog import music_cog
bot = commands.Bot(command_prefix='!',intents = discord.Intents.all())

@bot.event
async def on_ready():
    print(f'We have logged in as {bot.user}')
    await bot.add_cog(music_cog(bot))

bot.run(settings['token'])


    


    and And this is for cog with music

    


    from discord.ext import commands
from youtube_dl import YoutubeDL
YDL_OPTIONS = {'format': 'worstaudio/best', 'noplaylist': 'False', 'simulate': 'True',
               'preferredquality': '192', 'preferredcodec': 'mp3', 'key': 'FFmpegExtractAudio'}
FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
queue = []
class music_cog(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
    @commands.command(pass_context=True)
    async def play(self,ctx, *, arg):
        global queue
        queue.append(arg)
        def playing():
            for song in queue:
                with YoutubeDL(YDL_OPTIONS) as ydl:
                    if 'https://' in song:
                        info = ydl.extract_info(song, download=False)
                    else:
                        info = ydl.extract_info(f"ytsearch:{song}", download=False)['entries'][0]

                    url = info['formats'][0]['url']
                    queue.pop(0)
                    vc.play(discord.FFmpegPCMAudio(executable="ffmpeg", source=url, **FFMPEG_OPTIONS))
        voice_client = discord.utils.get(self.bot.voice_clients, guild=ctx.guild)
        if not ctx.message.author.voice:
            await ctx.send("You are not connected to voice chanel")
        elif voice_client:
            queue.append(arg)
        else:
            vc = await ctx.message.author.voice.channel.connect()
            playing()
    @commands.command(pass_context = True)
    async def disconect(self, ctx):
        server = ctx.message.guild.voice_client
        if ctx.message.guild.voice_client:
            await server.disconnect()
        else:
            await ctx.send("I am not connected")

    @commands.command(pass_context=True)
    async def stop(self, ctx):
        server = ctx.message.guild
        voice_channel = server.voice_client
        voice_channel.pause()

    @commands.command(pass_context=True)
    async def resumue(self, ctx):
        server = ctx.message.guild
        voice_channel = server.voice_client
        voice_channel.resume()


    


  • heroku-22 stack discord.py bot doesn't play music

    30 août 2022, par bon ho

    I'm making music bot with discord.py and using heroku. bot is playing music my localhost but heroku host is not playing music.

    


    I found what cause a bug.
It working nicely in heroku-20, but not working in heroku-22 stack.

    


    How can I use heroku-22 stack without error ?
What can I do ?

    


    I'm sorry my english is bad.

    


    my code :

    


    import youtube_dl
import discord
from discord import app_commands,Interaction
import asyncio
import os

class MyClient(discord.Client):
  async def on_ready(self):
    await self.wait_until_ready()
    await tree.sync()
    print(f"login at {self.user}")
        
intents= discord.Intents.all()
client = MyClient(intents=intents)
tree = app_commands.CommandTree(client)

youtube_dl.utils.bug_reports_message = lambda: ''
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=True):
        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)
queue={}
@tree.command(name="play", description="play music")
async def playmusic(interaction:Interaction,url_title:str,playfirst:bool=False):
  await interaction.response.send_message("I'm looking for music!!")
  guild=str(interaction.guild.id)
  try:
    queue[guild]
  except KeyError:
    queue[guild]=[]
  if interaction.user.voice is None:
    await interaction.edit_original_response(content="you must join any voice channel")
  else:
    voice_client: discord.VoiceClient = discord.utils.get(client.voice_clients, guild=interaction.guild)
    if voice_client == None:
      await interaction.user.voice.channel.connect()
      voice_client: discord.VoiceClient = discord.utils.get(client.voice_clients, guild=interaction.guild)
    player = await YTDLSource.from_url(url_title, loop=None)
    if playfirst and len(queue[guild])>1:
      queue[guild].insert(1,player)
    else:
      queue[guild].append(player)
    if not voice_client.is_playing():
      voice_client.play(player,after=None)
      await interaction.edit_original_response(content=f"{player.title} playing!!")
    else:
      await interaction.edit_original_response(content=f"{player.title} enqueued!")
    await asyncio.sleep(7)
    await interaction.delete_original_response()

client.run(token)


    


  • heroku discord.py bot doesn't play music

    30 août 2022, par bon ho

    I'm making music bot with discord.py and using heroku. bot is playing music my localhost but heroku host is not playing music.

    


    I found what cause a bug.
It working nicely in heroku-20, but not working in heroku-22 stack.

    


    How can I use heroku-22 stack without error ?
What can I do ?

    


    I'm sorry my english is bad.

    


    my code :

    


    import youtube_dl
import discord
from discord import app_commands,Interaction
import asyncio
import os

class MyClient(discord.Client):
  async def on_ready(self):
    await self.wait_until_ready()
    await tree.sync()
    print(f"login at {self.user}")
        
intents= discord.Intents.all()
client = MyClient(intents=intents)
tree = app_commands.CommandTree(client)

youtube_dl.utils.bug_reports_message = lambda: ''
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=True):
        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)
queue={}
@tree.command(name="play", description="play music")
async def playmusic(interaction:Interaction,url_title:str,playfirst:bool=False):
  await interaction.response.send_message("I'm looking for music!!")
  guild=str(interaction.guild.id)
  try:
    queue[guild]
  except KeyError:
    queue[guild]=[]
  if interaction.user.voice is None:
    await interaction.edit_original_response(content="you must join any voice channel")
  else:
    voice_client: discord.VoiceClient = discord.utils.get(client.voice_clients, guild=interaction.guild)
    if voice_client == None:
      await interaction.user.voice.channel.connect()
      voice_client: discord.VoiceClient = discord.utils.get(client.voice_clients, guild=interaction.guild)
    player = await YTDLSource.from_url(url_title, loop=None)
    if playfirst and len(queue[guild])>1:
      queue[guild].insert(1,player)
    else:
      queue[guild].append(player)
    if not voice_client.is_playing():
      voice_client.play(player,after=None)
      await interaction.edit_original_response(content=f"{player.title} playing!!")
    else:
      await interaction.edit_original_response(content=f"{player.title} enqueued!")
    await asyncio.sleep(7)
    await interaction.delete_original_response()

client.run(token)