
Recherche avancée
Autres articles (39)
-
MediaSPIP version 0.1 Beta
16 avril 2011, parMediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
Pour avoir une installation fonctionnelle, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...) -
MediaSPIP 0.1 Beta version
25 avril 2011, parMediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
The zip file provided here only contains the sources of MediaSPIP in its standalone version.
To get a working installation, you must manually install all-software dependencies on the server.
If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...) -
Mise à jour de la version 0.1 vers 0.2
24 juin 2013, parExplications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...)
Sur d’autres sites (2211)
-
voice_client.play doesn't continue loop (Discord)
19 mars 2023, par Razuriosongs = asyncio.Queue(maxsize=0)
currently_playing = False


@client.command()
async def play(ctx, url):
 global songs
 global currently_playing
 if currently_playing:
 with yt_dlp.YoutubeDL({"format": "bestaudio", "outtmpl": "Queue_Download/%(title)s.%(ext)s"}) as ydl:
 info = ydl.extract_info(url, download=True)
 filename = ydl.prepare_filename(info)
 await songs.put({"file": filename, "info": video_info(url)})
 # print("test 1")
 else:
 with yt_dlp.YoutubeDL({"format": "bestaudio", "outtmpl": "Queue_Download/%(title)s.%(ext)s"}) as ydl:
 info = ydl.extract_info(url, download=True)
 filename = ydl.prepare_filename(info)
 await songs.put({"file": filename, "info": video_info(url)})
 # print("test 2")
 asyncio.create_task(queue(ctx))



async def queue(ctx):
 global songs
 global currently_playing
 currently_playing = True
 while True:
 if songs.empty():
 currently_playing = False
 await ctx.reply("Queue is now empty")
 await ctx.voice_client.disconnect() # disconnect from voice channel when queue is empty
 break
 else: 
 song = await songs.get()
 filename = song["file"]
 voice_channel = ctx.author.voice.channel
 if not ctx.voice_client: # check if bot is not already connected to a voice channel
 await voice_channel.connect()

 await ctx.reply('playing')
 await ctx.voice_client.play(discord.FFmpegPCMAudio(filename))

@client.command()
async def stop(ctx):
 global songs
 await ctx.voice_client.disconnect()
 await empty_queue(songs)
 await ctx.reply('Stopped')

async def empty_queue(songs):
 while not songs.empty():
 songs.get_nowait()



I have problems with the "await ctx.voice_client.play(discord.FFmpegPCMAudio(filename))" which doesn't continue after finishing.


I know you can use a after= parameter in voice_client.play() but I didn't manage to get it to work to recursivly call queue()


-
The problem is that the music does not play Discord py bot [closed]
7 mai 2023, par ImFoxterWhen I write the command : !yt
Such a mistake :
enter image description here 

I also have FFMPEG, but I don't really understand what to do with it, I've already tried a lot of things and it doesn't work enter image description here

Please help to fix this

I have an operating system : Windows

And the file is created
enter image description here

import asyncio

import discord
import youtube_dl

from discord.ext import commands

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'
}

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=url, download=not stream))
 
 if "entries" in data:
 data = data["entries"][0]
 
 file_name = data["url"] if stream else ytdl.prepare_filename(data)
 return cls(discord.FFmpegAudio(file_name, **ffmpeg_options), data=data)

class PlayMusicVoiceChannel(commands.Cog):
def __init__(self, bot):
self.bot = bot

 @commands.command(name="j")
 async def joined(self, ifx, *, channel: discord.VoiceChannel):
 if ifx.voice_client is not None:
 return await ifx.voice_client.move_to(channel)
 await channel.connect()
 
 @commands.command(name="p")
 async def playing(self, ifx, *, query):
 source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(query))
 ifx.voice_client.play(source, after=lambda e: print(f"Player error: {e}") if e else None)
 await ifx.send(content=f"New playing: {query}")
 
 @commands.command(name="yt")
 async def youtube(self, ifx, *, url):
 async with ifx.typing():
 player = await YTDLSource.from_url(url=url, loop=self.bot.loop)
 ifx.voice_client.play(
 player, after=lambda e: print(f"Player error: {e}") if e else None
 )
 await ifx.send(f"New playing: {player.title}")
 
 @commands.command(name="stream")
 async def stream(self, ifx, *, url):
 async with ifx.typing():
 player = await YTDLSource.from_url(url=url, loop=self.bot.loop, stream=True)
 ifx.voice_client.play(
 player, after=lambda e: print(f"Player error: {e}") if e else None
 )
 await ifx.send(f"New playing: {player.title}")
 
 @commands.command(name="l")
 async def leave(self, ifx):
 await ifx.voice_client.move_to(None)
 
 @playing.before_invoke
 @youtube.before_invoke
 @stream.before_invoke
 async def ensure_voice(self, ifx: commands.Context):
 if ifx.voice_client is None:
 if ifx.author.voice:
 await ifx.author.voice.channel.connect()
 else:
 await ifx.send(content="You are not connected to a voice channel")
 raise commands.CommandError(message="Author not connected to a voice channel")
 elif ifx.voice_client.is_playing():
 ifx.voice_client.stop()

async def setup(bot: commands.Bot):
await bot.add_cog(PlayMusicVoiceChannel(bot))



-
Why i get error when i try to run command play in python script of discord bot
30 mai 2022, par UNDERTAKER 86My code of music discord bot :


import ffmpeg
import asyncio
import discord
from discord.ext import commands
import os
import requests
import random
import json
from replit import db
import youtube_dl
from keep_alive import keep_alive

class music(commands.Cog):
 def __init__(self, client):
 self.client = client

 @commands.command()
 async def join(self, ctx):
 if ctx.author.voice is None:
 await ctx.send(f'{ctx.message.author.mention}, Ты не подключён к голосовому чату!')
 voice_channel = ctx.author.voice.channel
 if ctx.voice_client is None:
 await voice_channel.connect()
 else:
 await ctx.voice_client.move_to(voice_channel)
 
 @commands.command()
 async def leave(self, ctx):
 if ctx.author.voice is None:
 await ctx.send(f'{ctx.message.author.mention}, Ты не подключён к голосовому чату!')
 else:
 await ctx.voice_client.disconnect()
 await ctx.send(f'{ctx.message.author.mention}, Пока!')

 @commands.command()
 async def play(self, ctx, *, url):
 if ctx.author.voice is None:
 await ctx.send(f'{ctx.message.author.mention}, Ты не подключён к голосовому чату!')
 ctx.voice_client.stop()
 ffmpeg_options = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
 YDL_OPTIONS = {'format': 'bestaudio/best', 'noplaylist': 'True', 'simulate': 'True',
 'preferredquality': '32bits', 'preferredcodec': 'wav', 'key': 'FFmpegExtractAudio'}
 vc = ctx.voice_client

 with youtube_dl.YoutubeDL(YDL_OPTIONS) as ydl:
 if 'https://' in url:
 info = ydl.extract_info(url, download=False)
 else:
 info = ydl.extract_info(f'ytsearch:{url}', download=False)['entries'][0]
 url2 = info['formats'][0]['url']
 source = await discord.FFmpegOpusAudio.from_probe(url2, **ffmpeg_options)
 vc.play(source)

 @commands.command()
 async def pause(self, ctx):
 if ctx.author.voice is None:
 await ctx.send(f'{ctx.message.author.mention}, Ты не подключён к голосовому чату!')
 await ctx.voice_client.pause()
 await ctx.send(f'{ctx.message.author.mention}, Пауза')

 @commands.command()
 async def resume(self, ctx):
 if ctx.author.voice is None:
 await ctx.send(f'{ctx.message.author.mention}, Ты не подключён к голосовому чату!')
 await ctx.voice_client.resume()
 await ctx.send(f'{ctx.message.author.mention}, Играет')

# @commands.command()
 # async def stop(self, ctx):
 # await ctx.voice_client.stop()
 # ctx.send(f'{author.mention}, Остановлен')

# @commands.command()
 # async def repeat(self, ctx):
 # await ctx.voice_client.repeat()
 # ctx.send(f'{author.mention}, Повтор')

# @commands.command()
 # async def loop(self, ctx):
 # await ctx.voice_client.loop()
 # ctx.send(f'{author.mention}, Повтор')

keep_alive()
def setup(client):
 client.add_cog(music(client))



But i get error when i write in discord command play :


[youtube] rUd2diUWDyI: Downloading webpage
[youtube] Downloading just video rUd2diUWDyI because of --no-playlist
[youtube] rUd2diUWDyI: Downloading webpage
[youtube] Downloading just video rUd2diUWDyI because of --no-playlist
Ignoring exception in command play:
Traceback (most recent call last):
 File "/home/runner/MBOT/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
 ret = await coro(*args, **kwargs)
 File "/home/runner/MBOT/music.py", line 51, in play
 source = await discord.FFmpegOpusAudio.from_probe(url2, **ffmpeg_options)
 File "/home/runner/MBOT/venv/lib/python3.8/site-packages/discord/player.py", line 387, in from_probe
 return cls(source, bitrate=bitrate, codec=codec, **kwargs)
 File "/home/runner/MBOT/venv/lib/python3.8/site-packages/discord/player.py", line 324, in __init__
 super().__init__(source, executable=executable, args=args, **subprocess_kwargs)
 File "/home/runner/MBOT/venv/lib/python3.8/site-packages/discord/player.py", line 138, in __init__
 self._process = self._spawn_process(args, **kwargs)
 File "/home/runner/MBOT/venv/lib/python3.8/site-packages/discord/player.py", line 147, in _spawn_process
 raise ClientException(executable + ' was not found.') from None
discord.errors.ClientException: ffmpeg was not found.



I try install ffmpeg in console python, but this dont helped me. Please, give me answer on my question. I use service replit.com to coding on python. Because i want to install this script on server. How i can solve this problem ?