From 33cdb81c33018dfd4ed7bc79d870027be287dea8 Mon Sep 17 00:00:00 2001 From: Akamaru Date: Wed, 18 Nov 2015 20:12:06 +0100 Subject: [PATCH] YouTube download Plugin gefixt --- plugins/youtube_dl.lua | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/plugins/youtube_dl.lua b/plugins/youtube_dl.lua index a3fb41d..048cf7a 100644 --- a/plugins/youtube_dl.lua +++ b/plugins/youtube_dl.lua @@ -9,16 +9,20 @@ function run(msg, matches) end if string.match(msg.text, "/mp4") then - text = run_bash('youtube-dl -o "tmp/%(title)s.%(ext)s" --no-continue '..URL) - video = string.match(text,"Destination: (.*).mp4") - file = video..'.mp4' + text = run_bash('youtube-dl -o "tmp/%(title)s.%(ext)s" -i '..URL) + video = string.match(text, 'Merging formats into "tmp/(.*).mp4"') + if not video then + file = string.match(text, '%[download%] (.*) has already been downloaded') + else + file = 'tmp/'..video..'.mp4' + end send_video(get_receiver(msg), file, ok_cb, false) end if string.match(msg.text, "/mp3") then - text = run_bash("youtube-dl --extract-audio --audio-format mp3 " .. URL) - audio = string.match(text,"Destination: (.*).m4a") - file = audio..'.mp3' + text = run_bash('youtube-dl -o "tmp/%(title)s.%(ext)s" --extract-audio --audio-format mp3 '..URL) + audio = string.match(text, 'Correcting container in "tmp/(.*).m4a"') + file = 'tmp/'..audio..'.mp3' send_audio(get_receiver(msg), file, ok_cb, false) end @@ -33,7 +37,7 @@ end return { description = "Downloadet und sendet ein Video von verschiedenen Seiten mit youtube-dl", - usage = {"/mp4 [Link] (Um Video zu laden)","/mp3 [Link] (Um Audio zu laden)","Unterstützte Seiten: https://ponywave.de/a/youtubedl"}, + usage = {"/mp4 [Link] (Um Video zu laden)","/mp3 [Link] (Um Audio zu laden)","Unterstützte Seiten: PonyWave.de/a/youtubedl"}, patterns = {"^/mp4 (https?://[%w-_%.%?%.:/%+=&]+)$","^/mp3 (https?://[%w-_%.%?%.:/%+=&]+)$"}, run = run }