
Recherche avancée
Médias (91)
-
DJ Z-trip - Victory Lap : The Obama Mix Pt. 2
15 septembre 2011
Mis à jour : Avril 2013
Langue : English
Type : Audio
-
Matmos - Action at a Distance
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
DJ Dolores - Oslodum 2004 (includes (cc) sample of “Oslodum” by Gilberto Gil)
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Danger Mouse & Jemini - What U Sittin’ On ? (starring Cee Lo and Tha Alkaholiks)
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Cornelius - Wataridori 2
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
The Rapture - Sister Saviour (Blackstrobe Remix)
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
Autres articles (22)
-
Publier sur MédiaSpip
13 juin 2013Puis-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 -
Organiser par catégorie
17 mai 2013, parDans MédiaSPIP, une rubrique a 2 noms : catégorie et rubrique.
Les différents documents stockés dans MédiaSPIP peuvent être rangés dans différentes catégories. On peut créer une catégorie en cliquant sur "publier une catégorie" dans le menu publier en haut à droite ( après authentification ). Une catégorie peut être rangée dans une autre catégorie aussi ce qui fait qu’on peut construire une arborescence de catégories.
Lors de la publication prochaine d’un document, la nouvelle catégorie créée sera proposée (...) -
Les thèmes de MediaSpip
4 juin 20133 thèmes sont proposés à l’origine par MédiaSPIP. L’utilisateur MédiaSPIP peut rajouter des thèmes selon ses besoins.
Thèmes MediaSPIP
3 thèmes ont été développés au départ pour MediaSPIP : * SPIPeo : thème par défaut de MédiaSPIP. Il met en avant la présentation du site et les documents média les plus récents ( le type de tri peut être modifié - titre, popularité, date) . * Arscenic : il s’agit du thème utilisé sur le site officiel du projet, constitué notamment d’un bandeau rouge en début de page. La structure (...)
Sur d’autres sites (4019)
-
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.