
Recherche avancée
Autres articles (66)
-
La file d’attente de SPIPmotion
28 novembre 2010, parUne file d’attente stockée dans la base de donnée
Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...) -
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 (...) -
Configurer la prise en compte des langues
15 novembre 2010, parAccéder à la configuration et ajouter des langues prises en compte
Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...)
Sur d’autres sites (7965)
-
Why is my discord bot not able to find the file that is there when I open the folder manually ?
22 juin 2021, par TomaI made a discord bot that should play music using ffmpeg.


It's connecting and downloading the youtube webm file after which it should convert and rename it to
song.mp3
but it doesn't manage to do so. I check the folder and the error message doesn't match what I see - the file is there and has been renamed.

- 

- Am I using the replace command correctly to move the file ?
- I'd note that I'm using windows10 and that the folders are all read only and that although I'm the admin I can't change that no matter what I do (I guess it's a win10 bug). Does that have anything to do with it ?
- Is there another mistake in the code that'd prevent the file from being found by the bot ?








My code :


import discord
from discord.ext import commands
import youtube_dl #for url music command
import os

client = commands.Bot(command_prefix = '><')

#connect to voice channel
@client.command(aliases = ['c'])
async def connect(ctx, vcName):
 voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
 voiceChannel = discord.utils.get(ctx.guild.channels, name=str(vcName))
 if voice == None: #if voice is not connected to any channel
 await voiceChannel.connect()
 else:
 if voice.channel == vcName: #if trying to connect to the same channel
 await ctx.send('already connected to this channel')
 else:
 await voice.move_to(vcName)

@client.command(aliases = ['d'])
async def delFile(ctx):
 song_there = os.path.exists(os.getcwd()+'/music/current/song.mp3') #true when song.mp3 exists in 'current' folder in 'music' folder
 if song_there:
 await ctx.send('song was detected')
 os.remove('song.mp3')
 if song_there:
 await ctx.send('song was not deleted')
 else:
 await ctx.send('File is not found. check the name again')

#play music from url

@client.command(aliases = ['p'])
async def playMusic(ctx, vcName, url : str): #play music file
 song_there = os.path.exists(os.path.join(os.getcwd(),'/music/current/song.mp3'))
 try:
 if song_there:
 print('previous song found')
 os.remove(os.path.join(os.getcwd(),'/music/current/song.mp3')) #removes the song in current to make room for a new song
 if song_there:
 print('song was not deleted')
 else:
 print('song deleted')
 except PermissionError:
 await ctx.send('A song is currently playing')
 return
 voiceChannel = discord.utils.get(ctx.guild.channels, name=str(vcName))
 ydl_opts = {
 'format': 'bestaudio/best',
 'postprocessors': [{
 'key': 'FFmpegExtractAudio',
 'preferredcodec': 'mp3',
 'preferredquality': '192',
 }]
 }


 for file in os.listdir('./'):
 if file.endswith('.mp3'): #if song.mp3 already exists delete it to make room for a new download
 os.remove('song.mp3')
 else: #download the file from youtube
 with youtube_dl.YoutubeDL(ydl_opts) as ydl:
 ydl.download([url])
 for file in os.listdir('./'): #after downloading rename the file and move it to current folder
 if not file == ('song.mp3') and file.endswith('.mp3'):
 os.rename(file, 'song.mp3')
 print(os.path.join(os.getcwd(), 'song.mp3'))
 print(os.path.join(os.getcwd(), '/music/current/song.mp3'))
 os.replace(os.path.join(os.getcwd(), 'song.mp3'), os.path.join(os.getcwd(), '/music/current/song.mp3')) #move file to current

 voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
 if not voice is None: #if voice is already created
 if not voice.is_connected(): #and is not connected
 await voiceChannel.connect()
 voice.play(discord.FFmpegPCMAudio('song.mp3'))
 else:
 await ctx.send('Bot made an oopsy. Cast mending and heal bot.')
client.run('token')



Error :


[youtube] wkJ7oDMqz0A: Downloading webpage
[download] The Minor Bee-wkJ7oDMqz0A.webm has already been downloaded
[download] 100% of 5.13MiB
[ffmpeg] Destination: The Minor Bee-wkJ7oDMqz0A.mp3
Deleting original file The Minor Bee-wkJ7oDMqz0A.webm (pass -k to keep)
[youtube] wkJ7oDMqz0A: Downloading webpage
[download] Destination: The Minor Bee-wkJ7oDMqz0A.webm
[download] 100% of 5.13MiB in 00:00 
[ffmpeg] Destination: The Minor Bee-wkJ7oDMqz0A.mp3
Deleting original file The Minor Bee-wkJ7oDMqz0A.webm (pass -k to keep)
[youtube] wkJ7oDMqz0A: Downloading webpage
[download] Destination: The Minor Bee-wkJ7oDMqz0A.webm
[download] 100% of 5.13MiB in 00:00 
[ffmpeg] Destination: The Minor Bee-wkJ7oDMqz0A.mp3
Deleting original file The Minor Bee-wkJ7oDMqz0A.webm (pass -k to keep)
C:.....song.mp3 -> **C:/music/current/song.mp3**
Ignoring exception in command playMusic:
Traceback (most recent call last):
 File "C:\Program Files\Python38\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
 ret = await coro(*args, **kwargs)
 File "C:...tut-bot.py", line 84, in playMusic
 os.replace(os.path.join(os.getcwd(), 'song.mp3'), os.path.join(os.getcwd(), '/music/current/song.mp3')) #move file to current
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\....\\song.mp3' -> 'C:/music/current/song.mp3'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
 File "C:\Program Files\Python38\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
 await ctx.command.invoke(ctx)
 File "C:\Program Files\Python38\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
 await injected(*ctx.args, **ctx.kwargs)
 File "C:\Program Files\Python38\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
 raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\...\\song.mp3' -> 'C:/music/current/song.mp3'



-
Why does my discord bot not able to find the file that is there when I open the folder manually ?
22 juin 2021, par TomaI made a discord bot that should play music using ffmpeg.


It's connecting and downloading the youtube webm file after which it should convert and rename it to
song.mp3
but it doesn't manage to do so. I check the folder and the error message doesn't match what I see - the file is there and has been renamed.

- 

- Am I using the replace command correctly to move the file ?
- I'd note that I'm using windows10 and that the folders are all read only and that although I'm the admin I can't change that no matter what I do (I guess it's a win10 bug). Does that have anything to do with it ?
- Is there another mistake in the code that'd prevent the file from being found by the bot ?








My code :


import discord
from discord.ext import commands
import youtube_dl #for url music command
import os

client = commands.Bot(command_prefix = '><')

#connect to voice channel
@client.command(aliases = ['c'])
async def connect(ctx, vcName):
 voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
 voiceChannel = discord.utils.get(ctx.guild.channels, name=str(vcName))
 if voice == None: #if voice is not connected to any channel
 await voiceChannel.connect()
 else:
 if voice.channel == vcName: #if trying to connect to the same channel
 await ctx.send('already connected to this channel')
 else:
 await voice.move_to(vcName)

@client.command(aliases = ['d'])
async def delFile(ctx):
 song_there = os.path.exists(os.getcwd()+'/music/current/song.mp3') #true when song.mp3 exists in 'current' folder in 'music' folder
 if song_there:
 await ctx.send('song was detected')
 os.remove('song.mp3')
 if song_there:
 await ctx.send('song was not deleted')
 else:
 await ctx.send('File is not found. check the name again')

#play music from url

@client.command(aliases = ['p'])
async def playMusic(ctx, vcName, url : str): #play music file
 song_there = os.path.exists(os.path.join(os.getcwd(),'/music/current/song.mp3'))
 try:
 if song_there:
 print('previous song found')
 os.remove(os.path.join(os.getcwd(),'/music/current/song.mp3')) #removes the song in current to make room for a new song
 if song_there:
 print('song was not deleted')
 else:
 print('song deleted')
 except PermissionError:
 await ctx.send('A song is currently playing')
 return
 voiceChannel = discord.utils.get(ctx.guild.channels, name=str(vcName))
 ydl_opts = {
 'format': 'bestaudio/best',
 'postprocessors': [{
 'key': 'FFmpegExtractAudio',
 'preferredcodec': 'mp3',
 'preferredquality': '192',
 }]
 }


 for file in os.listdir('./'):
 if file.endswith('.mp3'): #if song.mp3 already exists delete it to make room for a new download
 os.remove('song.mp3')
 else: #download the file from youtube
 with youtube_dl.YoutubeDL(ydl_opts) as ydl:
 ydl.download([url])
 for file in os.listdir('./'): #after downloading rename the file and move it to current folder
 if not file == ('song.mp3') and file.endswith('.mp3'):
 os.rename(file, 'song.mp3')
 print(os.path.join(os.getcwd(), 'song.mp3'))
 print(os.path.join(os.getcwd(), '/music/current/song.mp3'))
 os.replace(os.path.join(os.getcwd(), 'song.mp3'), os.path.join(os.getcwd(), '/music/current/song.mp3')) #move file to current

 voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
 if not voice is None: #if voice is already created
 if not voice.is_connected(): #and is not connected
 await voiceChannel.connect()
 voice.play(discord.FFmpegPCMAudio('song.mp3'))
 else:
 await ctx.send('Bot made an oopsy. Cast mending and heal bot.')
client.run('token')



Error :


[youtube] wkJ7oDMqz0A: Downloading webpage
[download] The Minor Bee-wkJ7oDMqz0A.webm has already been downloaded
[download] 100% of 5.13MiB
[ffmpeg] Destination: The Minor Bee-wkJ7oDMqz0A.mp3
Deleting original file The Minor Bee-wkJ7oDMqz0A.webm (pass -k to keep)
[youtube] wkJ7oDMqz0A: Downloading webpage
[download] Destination: The Minor Bee-wkJ7oDMqz0A.webm
[download] 100% of 5.13MiB in 00:00 
[ffmpeg] Destination: The Minor Bee-wkJ7oDMqz0A.mp3
Deleting original file The Minor Bee-wkJ7oDMqz0A.webm (pass -k to keep)
[youtube] wkJ7oDMqz0A: Downloading webpage
[download] Destination: The Minor Bee-wkJ7oDMqz0A.webm
[download] 100% of 5.13MiB in 00:00 
[ffmpeg] Destination: The Minor Bee-wkJ7oDMqz0A.mp3
Deleting original file The Minor Bee-wkJ7oDMqz0A.webm (pass -k to keep)
C:.....song.mp3 -> **C:/music/current/song.mp3**
Ignoring exception in command playMusic:
Traceback (most recent call last):
 File "C:\Program Files\Python38\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
 ret = await coro(*args, **kwargs)
 File "C:...tut-bot.py", line 84, in playMusic
 os.replace(os.path.join(os.getcwd(), 'song.mp3'), os.path.join(os.getcwd(), '/music/current/song.mp3')) #move file to current
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\....\\song.mp3' -> 'C:/music/current/song.mp3'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
 File "C:\Program Files\Python38\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
 await ctx.command.invoke(ctx)
 File "C:\Program Files\Python38\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
 await injected(*ctx.args, **ctx.kwargs)
 File "C:\Program Files\Python38\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
 raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\...\\song.mp3' -> 'C:/music/current/song.mp3'



-
avformat/dxa : Check fps to be within the supported range more precissely
24 avril 2021, par Michael Niedermayeravformat/dxa : Check fps to be within the supported range more precissely
Fixes : negation of -2147483648 cannot be represented in type 'int32_t' (aka 'int') ; cast to an unsigned type to negate this value to itself
Fixes : assertion failure
Fixes : 29102/clusterfuzz-testcase-minimized-ffmpeg_dem_DXA_fuzzer-6744985740378112Found-by : continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by : Michael Niedermayer <michael@niedermayer.cc>