
Recherche avancée
Médias (1)
-
Sintel MP4 Surround 5.1 Full
13 mai 2011, par
Mis à jour : Février 2012
Langue : English
Type : Video
Autres articles (73)
-
Amélioration de la version de base
13 septembre 2013Jolie sélection multiple
Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...) -
Le profil des utilisateurs
12 avril 2011, parChaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...) -
Menus personnalisés
14 novembre 2010, parMediaSPIP utilise le plugin Menus pour gérer plusieurs menus configurables pour la navigation.
Cela permet de laisser aux administrateurs de canaux la possibilité de configurer finement ces menus.
Menus créés à l’initialisation du site
Par défaut trois menus sont créés automatiquement à l’initialisation du site : Le menu principal ; Identifiant : barrenav ; Ce menu s’insère en général en haut de la page après le bloc d’entête, son identifiant le rend compatible avec les squelettes basés sur Zpip ; (...)
Sur d’autres sites (7736)
-
ffmpeg doesn't work, when starting up it doesn't play music, it gives errors
14 août 2024, par Оля Михееваimport discord
from discord import FFmpegPCMAudio
import os
import random
from gtts import gTTS
import asyncio

TOKEN="***"
VOICE_CHANNEL_ID=11122224444

class Voice_Bot(discord.Client):
 def __init__(self):
 intents = discord.Intents.default()
 intents.message_content = True
 intents.voice_states=True
 super().__init__(intents=intents)
 print(os.getcwd())
 self.sounds_hello = os.listdir(os.path.join('sounds','hello'))
 self.sounds_bye = os.listdir('sounds\\bye')
 self.sounds = os.listdir('sounds\\nature')

 async def on_ready(self): 
 self.voice_channel = self.get_channel(VOICE_CHANNEL_ID) 
 if self.voice_channel == None:
 print('Не удалось подключиться к голосовому каналу.')
 return
 self.voice_client = await self.voice_channel.connect()
 print('Бот подключен к голосовому каналу')
 await self.text_to_speech("Lets play Guess the Tune")
 
 async def on_message(self,message):
 if message.author==self.user:
 return
 if message.content.startswith("game"):
 await self.text_to_speech("let's start the game guess the melody")
 music=os.listdir("sounds\\music")
 self.melody=random.choice(music)
 await self.play_sound(f"sounds\\music\\{self.melody}")
 elif message.content==self.melody[0:len(self.melody)-4]:
 if (self.voice_client.is_playing()):
 self.voice_client.stop()
 await self.text_to_speech(f"Congratulations, {message.author.name} answered correctly! To continue, type game")
 else:
 if (self.voice_client.is_playing()):
 self.voice_client.stop()
 await self.text_to_speech(f"Unfortunately, {message.author.name} did not guess. To continue, write game")


 async def on_voice_state_update(self,member,before,after):
 if member.id ==self.user.id:
 print('Someone entered or left the voice channel.')
 else:
 try:
 if before.channel == None:
 print(f'{member.name} entered the voice channel {after.channel}.')
 await self.play_sound(f'sounds\\hello\\{random.choice(self.sounds_hello)}')
 elif after.channel == None:
 print(f'{member.name} left the voice channel {before.channel}.')
 await self.play_sound(f'sounds\\bye\\{random.choice(self.sounds_bye)}')
 except Exception as e:
 print(f"Error in on_voise_state_update: {e}")

 async def text_to_speech(self,text):
 try:
 tts = gTTS(text=text, lang ="en")
 tts.save("text.mp3")
 except Exception as e:
 print(f"Error e: {e}")
 await self.voice_channel.send(text)
 await self.play_sound("text.mp3")

 def play_sound(self,path):
 print(path)
 source=discord.FFmpegPCMAudio(source=path, executable="ffmpeg\\bin\\ffmpeg.exe")
 if (self.voice_client.is_playing()):
 self.voice_client.stop()
 self.voice_client.play(source) 

client = Voice_Bot()
client.run(TOKEN)



[enter image description here](https://i.sstatic.net/ys8Xza0w.jpg)


-
Python Discord Music Bot : Playing next song while current song is playing
8 février, par DeltracI've been working on a Discord bot and got it working 90% of the time. On some occasions, the bot will be playing a song and it will stop playing and just move to the next song. My assumption is that it's because of how I am handling my
play
command and theplay_next
command as well.

I've tried to re-arrange the code, change functionality, etc. without success.


Here are the two commands :


@client.command(name="p")
async def play(ctx, *, search_query: str):
 global bot_disconnect
 try:
 # Only start a song if the user trying to play a song is in a voice channel
 if ctx.author.voice:
 voice_channel = ctx.author.voice.channel
 voice_client = await voice_channel.connect() # Find who played the song and have the bot enter that channel
 voice_clients[voice_client.guild.id] = voice_client
 else:
 await ctx.channel.send("Get in a voice channel")
 return
 except Exception as e:
 print(e)
 try:
 if is_youtube_url(search_query):
 loop = asyncio.get_event_loop() # Let's the bot multi-task (Similar behavior to interrupts in C/C++)
 data = await loop.run_in_executor(None, lambda: ytdl.extract_info(search_query, download = False))
 video_url = data["webpage_url"] # Save the youtube video URL to variable
 song_url = data["url"] # Save the extracted URL to a variable
 title = data["title"]
 else:
 url = f"ytsearch:{search_query}"
 loop = asyncio.get_event_loop() # Let's the bot multi-task (Similar behavior to interrupts in C/C++)
 data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download = False)) 
 entry = data['entries'][0]
 video_url = entry["webpage_url"] # Save the youtube video URL to variable
 song_url = entry["url"] # Save the extracted URL to a variable
 title = entry["title"]

 if ctx.guild.id in voice_clients and voice_clients[ctx.guild.id].is_playing():
 await queue(ctx, search_query = video_url, title = title)
 else:
 player = discord.FFmpegOpusAudio(song_url, **ffmpeg_options) # THIS IS WHAT PLAYS THE ACTUAL SONG!!!!!!
 await ctx.channel.send(f"Now Playing: {video_url} \n[DOWNLOAD LINK HERE]({song_url})") # Send the video URL to discord channel and include a download link as well
 bot_disconnect = False
 voice_clients[ctx.guild.id].play(player, after=lambda e: asyncio.run_coroutine_threadsafe(play_next(ctx), client.loop))
 except Exception as e:
 print(e)



async def play_next(ctx):
 if len(queues) != 0 and queues.get(ctx.guild.id): 
 search_query = queues[ctx.guild.id].pop(0)[0] # Pull the URL from the next index
 loop = asyncio.get_event_loop() # Let's the bot multi-task (Similar behavior to interrupts in C/C++)
 print(f"{search_query}")
 data = await loop.run_in_executor(None, lambda: ytdl.extract_info(search_query, download = False))
 player = discord.FFmpegOpusAudio(data["url"], **ffmpeg_options)
 voice_client = voice_clients[ctx.guild.id]
 voice_client.play(player, after=lambda e: asyncio.run_coroutine_threadsafe(play_next(ctx), client.loop))
 await ctx.channel.send(f"Now Playing: {data['webpage_url']} \n[DOWNLOAD LINK HERE]({data['url']})") # Send the video URL to discord channel and include a download link as well
 else:
 await ctx.send("No songs in queue")



I can also link the full code, if required.


-
My discord music bot is not playing the entire music
21 décembre 2024, par james12My discord music bot based on discord.py, yt_dlp and ffmpeg is not working.
I downloaded every module that is required and added environmental variables.
But, my discord bot is not working properly.
The bot plays the music properly at first, but the music ends before the song finishes.


Full code below :


import discord
from discord.ext import commands
import yt_dlp

app = commands.Bot(command_prefix='!', intents=discord.Intents.all())
ydl_opts = {
 'format': 'bestaudio/best',
 'extractaudio': True,
 'audioformat': 'mp3',
 'outtmpl': 'downloads/%(title)s.%(ext)s',
 'quiet': True,
}

@app.event
async def on_ready():
 print('Done')
 await app.change_presence(status=discord.Status.online, activity=None)

@app.command()
async def play(ctx, *, search: str):
 channel = ctx.author.voice.channel
 voice_client = discord.utils.get(app.voice_clients, guild=ctx.guild)

 if not voice_client:
 voice_client = await channel.connect()

 with yt_dlp.YoutubeDL(ydl_opts) as ydl:
 info = ydl.extract_info(f"ytsearch:{search}", download=False)['entries'][0]
 url = info['url']
 title = info['title']

 # 음악 재생
 voice_client.play(discord.FFmpegPCMAudio(url, executable="ffmpeg"), after=lambda e: print("재생 완료"))
 await ctx.send(f"{ctx.author.mention}님이 요청하신 {title} 노래 재생 중")

@app.command()
async def stop(ctx):
 voice_client = discord.utils.get(app.voice_clients, guild=ctx.guild)
 if voice_client and voice_client.is_playing():
 voice_client.stop()
 await voice_client.disconnect()
 
app.run('token')



I tried to add options in FFmpeg like this :
options="-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5"

but it doesn't work.
I also added extra yt-dlp options.
I hope the bot properly plays the full version of music from youtube in discord.