YouTube download Plugin gefixt

This commit is contained in:
Akamaru 2015-11-18 20:12:06 +01:00
parent f652e49c5d
commit 33cdb81c33
1 changed files with 11 additions and 7 deletions

View File

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