diff --git a/README.md b/README.md new file mode 100644 index 0000000..4ad43aa --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +usage: + ./toitadesbot.py TOKEN diff --git a/main.py b/toitadesbot.py similarity index 89% rename from main.py rename to toitadesbot.py index 3c790ec..e586392 100755 --- a/main.py +++ b/toitadesbot.py @@ -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):