
Recherche avancée
Médias (1)
-
Rennes Emotion Map 2010-11
19 octobre 2011, par
Mis à jour : Juillet 2013
Langue : français
Type : Texte
Autres articles (46)
-
Personnaliser les catégories
21 juin 2013, parFormulaire 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 binaires spécifiques au traitement vidéo et sonore
31 janvier 2010, parLes logiciels et librairies suivantes sont utilisées par SPIPmotion d’une manière ou d’une autre.
Binaires obligatoires FFMpeg : encodeur principal, permet de transcoder presque tous les types de fichiers vidéo et sonores dans les formats lisibles sur Internet. CF ce tutoriel pour son installation ; Oggz-tools : outils d’inspection de fichiers ogg ; Mediainfo : récupération d’informations depuis la plupart des formats vidéos et sonores ;
Binaires complémentaires et facultatifs flvtool2 : (...) -
Support audio et vidéo HTML5
10 avril 2011MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)
Sur d’autres sites (7860)
-
heroku-22 stack discord.py bot doesn't play music
30 août 2022, par bon hoI'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)



-
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()



-
My discord music bot works locally, but not on a server [closed]
8 décembre 2022, par AsmondyaI have an issue with my discord music bot that I made with discord.js v14.


When I run it locally, it works fine and plays music as it should. But when I put in on a server (here I use Vultr), it doesn't work.


I am not sure but it might come from FFmpeg. I am kinda desperate and cant really figure where the issue is from. I think it is FFmpeg because it is what converts the music.


What happens :


Me: !play a music
Bot: Now playing a music
*and right after, without playing the music*
Bot: Music finished



What should normally happen is that same thing but the "music finished" should be sent when the queue is finished.


The thing is that the bot works perfectly locally, but does this when it is hosted on a server. Also I don't have any error messages or else. It just doesn't play the music like if the music was 0 seconds length.


I tried making sure everything is installed on the server, same as making sure ffmpeg was installed globally and I have the good version of it. Here is the answer I have to the "ffmpeg -version" command :enter image description here.


Does anyone know what could be the issue or what could cause it ? I can show some code if needed, even tho it works perfectly fine locally.


Here's my code :


const { DisTube } = require('distube')
const Discord = require('discord.js')
const { EmbedBuilder } = require('discord.js')
const client = new Discord.Client({
 intents: [
 Discord.GatewayIntentBits.Guilds,
 Discord.GatewayIntentBits.GuildMessages,
 Discord.GatewayIntentBits.GuildVoiceStates,
 Discord.GatewayIntentBits.MessageContent,
 ]
})
const { ActivityType } = require('discord.js')
const fs = require('fs')
const dotenv = require("dotenv")
dotenv.config()
const { SpotifyPlugin } = require('@distube/spotify')
const { SoundCloudPlugin } = require('@distube/soundcloud')
const { YtDlpPlugin } = require('@distube/yt-dlp')

client.distube = new DisTube(client, {
 leaveOnStop: false,
 emitNewSongOnly: true,
 emitAddSongWhenCreatingQueue: false,
 emitAddListWhenCreatingQueue: false,
 plugins: [
 new SpotifyPlugin({
 emitEventsAfterFetching: true
 }),
 new SoundCloudPlugin(),
 new YtDlpPlugin()
 ]
})
client.commands = new Discord.Collection()
client.aliases = new Discord.Collection()

fs.readdir('./commands/', (err, files) => {
 if (err) return console.log('Could not find any commands!')
 const jsFiles = files.filter(f => f.split('.').pop() === 'js')
 if (jsFiles.length <= 0) return console.log('Could not find any commands!')
 jsFiles.forEach(file => {
 const cmd = require(`./commands/${file}`)
 console.log(`Loaded ${file}`)
 client.commands.set(cmd.name, cmd)
 if (cmd.aliases) cmd.aliases.forEach(alias => client.aliases.set(alias, cmd.name))
 })
})

client.on('ready', () => {
 console.log(`${client.user.tag} is ready to play music.`)
})

client.on('messageCreate', async message => {
 if (message.author.bot || !message.guild) return
 const prefix = "!"
 if (!message.content.startsWith(prefix)) return
 const args = message.content.slice(prefix.length).trim().split(/ +/g)
 const command = args.shift().toLowerCase()
 const cmd = client.commands.get(command) || client.commands.get(client.aliases.get(command))
 if (!cmd) return
 if (cmd.inVoiceChannel && !message.member.voice.channel) {
 return message.channel.send(`You must be in a voice channel!`)
 }
 try {
 cmd.run(client, message, args)
 } catch (e) {
 console.error(e)
 message.channel.send(`Error: \`${e}\``)
 }
})

// Add filters to the queue status :
// | Filter: \`${queue.filters.names.join(', ') || 'Off'}\` 

const status = queue =>
 `Volume: \`${queue.volume}%\` | Loop: \`${
 queue.repeatMode ? (queue.repeatMode === 2 ? 'All Queue' : 'This Song') : 'Off'
 }\` | Autoplay: \`${queue.autoplay ? 'On' : 'Off'}\``
client.distube
 .on('playSong', (queue, song) =>
 queue.textChannel.send({
 embeds: [
 new Discord.EmbedBuilder()
 .setTitle('Now playing')
 .setDescription(`\`${song.name}\` - \`${song.formattedDuration}\`\n${status(queue)}\n\nRequested by: \`${song.user.tag}\``)
 .setThumbnail(`${song.thumbnail}`)
 ]
 })
 )
 .on('addSong', (queue, song) =>
 queue.textChannel.send({
 embeds: [
 new Discord.EmbedBuilder()
 .setTitle('Song added to the queue')
 .setDescription(`${song.name} - \`${song.formattedDuration}\`\n\nRequested by: \`${song.user.tag}\``)
 .setThumbnail(`${song.thumbnail}`)
 ]
 })
 )
 .on('addList', (queue, playlist) =>
 queue.textChannel.send({
 embeds: [
 new Discord.EmbedBuilder()
 .setTitle(`Playlist added to the queue`)
 .setDescription(`\`${playlist.name}\` (${
 playlist.songs.length
 } songs)\n${status(queue)}\n\nRequested by: \`${song.user.tag}\``)
 .setThumbnail(`${song.thumbnail}`)
 ]
 })
 )
 .on('error', (channel, e) => {
 if (channel) channel.send(`An error encountered: ${e.toString().slice(0, 1974)}`)
 else console.error(e)
 })
 .on('empty', channel => channel.send('There is no one here. Im alone, again...'))
 .on('searchNoResult', (message, query) =>
 message.channel.send(`No result found for \`${query}\`!`)
 )
 .on('finish', queue => queue.textChannel.send("https://tenor.com/view/end-thats-all-folks-gif-10601784"))

client.on("ready", () => {
 client.user.setPresence({
 activities: [{
 name: 'AURORA',
 type: ActivityType.Listening
 }],
 status: "idle"
 })
})

client.login(process.env.TOKEN)



It does come from my ffpmeg, I need to install one of these packages instead of the npm installation : https://github.com/BtbN/FFmpeg-Builds/releases


How do I install it on a server (Vultr) ?