2015-11-12 17:42:03 +01:00
|
|
|
-- Requires: sudo apt-get install youtube-dl
|
2015-06-29 21:11:31 +02:00
|
|
|
-- See https://github.com/rg3/youtube-dl/blob/master/README.md#options
|
2015-05-24 18:23:30 +02:00
|
|
|
function run(msg, matches)
|
|
|
|
URL = matches[1]
|
|
|
|
local receiver = get_receiver(msg)
|
2015-11-12 17:42:03 +01:00
|
|
|
|
2015-06-17 20:30:14 +02:00
|
|
|
if string.match(msg.text, '"') then
|
|
|
|
return 'Vergiss es'
|
2015-08-01 13:28:23 +02:00
|
|
|
end
|
2015-11-12 17:42:03 +01:00
|
|
|
|
2015-08-01 13:28:23 +02:00
|
|
|
if string.match(msg.text, "/mp4") then
|
2015-11-22 14:40:34 +01:00
|
|
|
text = run_bash('youtube-dl -o "tmp/%(title)s.%(ext)s" '..URL)
|
|
|
|
video = string.match(text, 'Merging formats into "tmp/(.*)"')
|
2015-11-18 20:12:06 +01:00
|
|
|
if not video then
|
|
|
|
file = string.match(text, '%[download%] (.*) has already been downloaded')
|
2016-01-11 19:39:19 +01:00
|
|
|
--else
|
|
|
|
--file = string.match(text, '%[download%] Destination: (.*).flv')
|
2015-11-18 20:12:06 +01:00
|
|
|
else
|
2015-11-22 14:40:34 +01:00
|
|
|
file = 'tmp/'..video
|
2015-11-18 20:12:06 +01:00
|
|
|
end
|
2015-11-12 17:42:03 +01:00
|
|
|
send_video(get_receiver(msg), file, ok_cb, false)
|
2015-06-17 20:30:14 +02:00
|
|
|
end
|
2015-11-12 17:42:03 +01:00
|
|
|
|
2015-08-01 13:28:23 +02:00
|
|
|
if string.match(msg.text, "/mp3") then
|
2015-11-18 20:12:06 +01:00
|
|
|
text = run_bash('youtube-dl -o "tmp/%(title)s.%(ext)s" --extract-audio --audio-format mp3 '..URL)
|
2015-12-19 15:17:45 +01:00
|
|
|
audio = string.match(text, '%[avconv%] Destination: tmp/(.*).mp3')
|
2015-11-18 20:12:06 +01:00
|
|
|
file = 'tmp/'..audio..'.mp3'
|
2015-11-12 17:42:03 +01:00
|
|
|
send_audio(get_receiver(msg), file, ok_cb, false)
|
2015-08-01 13:28:23 +02:00
|
|
|
end
|
2015-11-12 17:42:03 +01:00
|
|
|
|
|
|
|
print('Sende: '..file)
|
|
|
|
message = '"'..file..'" wurde gedownloadet und wird jetzt gesendet! \nDas kann je nach Video sehr lang dauern! \nAlso habt Geduld!'
|
|
|
|
message = string.gsub(message, "tmp/", "")
|
|
|
|
message = string.gsub(message, ".mp3", "")
|
|
|
|
message = string.gsub(message, ".mp4", "")
|
2015-11-22 14:40:34 +01:00
|
|
|
message = string.gsub(message, ".mkv", "")
|
|
|
|
message = string.gsub(message, ".flv", "")
|
2015-11-12 17:42:03 +01:00
|
|
|
return message
|
|
|
|
|
2015-05-24 18:23:30 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
return {
|
2015-06-06 22:15:31 +02:00
|
|
|
description = "Downloadet und sendet ein Video von verschiedenen Seiten mit youtube-dl",
|
2015-11-18 20:12:06 +01:00
|
|
|
usage = {"/mp4 [Link] (Um Video zu laden)","/mp3 [Link] (Um Audio zu laden)","Unterstützte Seiten: PonyWave.de/a/youtubedl"},
|
2015-08-01 13:28:23 +02:00
|
|
|
patterns = {"^/mp4 (https?://[%w-_%.%?%.:/%+=&]+)$","^/mp3 (https?://[%w-_%.%?%.:/%+=&]+)$"},
|
2015-05-24 18:23:30 +02:00
|
|
|
run = run
|
|
|
|
}
|
|
|
|
--by Akamaru [https://ponywave.de]
|