This repository has been archived on 2021-04-24. You can view files and clone it, but cannot push or open issues or pull requests.
Mikubot/plugins/youtube_dl.lua

27 lines
1.2 KiB
Lua
Raw Normal View History

-- Requires: (sudo) apt-get install youtube-dl
-- 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)
if string.match(msg.text, '"') then
return 'Vergiss es'
2015-08-01 13:28:23 +02:00
end
if string.match(msg.text, "/mp4") then
text = run_bash("youtube-dl -o tmp/video.mp4 --no-continue " .. URL)
2015-05-24 18:23:30 +02:00
send_video(get_receiver(msg), "tmp/video.mp4", ok_cb, false)
end
2015-08-01 13:28:23 +02:00
if string.match(msg.text, "/mp3") then
text = run_bash("youtube-dl -o tmp/sound.mp3 --audio-format mp3 --no-continue " .. URL)
send_audio(get_receiver(msg), "tmp/sound.mp3", ok_cb, false)
end
print(text)
return URL .. ' wurde gedownloadet und wird jetzt gesendet! \nDas kann je nach Video sehr lang dauern! \nAlso habt Geduld!'
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-08-01 13:28:23 +02:00
usage = {"/mp4 [Link] (Um Video zu laden)","/mp3 [Link] (Um Audio zu laden)","Unterstützte Seiten: https://ponywave.de/a/youtubedl"},
patterns = {"^/mp4 (https?://[%w-_%.%?%.:/%+=&]+)$","^/mp3 (https?://[%w-_%.%?%.:/%+=&]+)$"},
2015-05-24 18:23:30 +02:00
run = run
}
--by Akamaru [https://ponywave.de]