Add check when adding a new sound, add readme and rename main file
This commit is contained in:
parent
f9b53454d5
commit
51bda764fa
@ -11,7 +11,7 @@ from pydub import AudioSegment
|
||||
from discord.ext import commands
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print("./main.py TOKEN")
|
||||
print("./toitadesbot.py TOKEN")
|
||||
exit(1)
|
||||
|
||||
sounds_folder = 'Sounds'
|
||||
@ -36,8 +36,11 @@ async def play(ctx, arg):
|
||||
|
||||
@bot.command()
|
||||
async def add(ctx, name, url, start, end):
|
||||
if os.path.isfile(computePath(name)):
|
||||
await ctx.send("Ce nom est déjà utilisé, merci d'en choisir un autre.")
|
||||
return
|
||||
downloadAndCutVideo(url, name, start, end)
|
||||
await ctx.send("Téléchargé !")
|
||||
await play(name)
|
||||
|
||||
@bot.command()
|
||||
async def remove(ctx, name):
|
||||
@ -62,12 +65,11 @@ def downloadAndCutVideo(url, filename, start = -1, end = -1):
|
||||
tmpFilename = filename + "tmp"
|
||||
downloadVideo(url, tmpFilename)
|
||||
song = AudioSegment.from_mp3(computePath(tmpFilename))
|
||||
|
||||
if start != -1:
|
||||
start = start * 1000
|
||||
if end != -1:
|
||||
end = end * 1000
|
||||
cutted_song = song[start:end].export(computePath(filename), format="mp3")
|
||||
song[start:end].export(computePath(filename), format="mp3")
|
||||
os.remove(computePath(tmpFilename))
|
||||
|
||||
def downloadVideo(url, filename):
|
Loading…
Reference in New Issue
Block a user