youtube_search sends video info
This commit is contained in:
parent
bc044b3e44
commit
99391a8667
@ -1,5 +1,3 @@
|
|||||||
do
|
|
||||||
|
|
||||||
-- HOW TO USE:
|
-- HOW TO USE:
|
||||||
-- 1. Go to the Google Developers Console.
|
-- 1. Go to the Google Developers Console.
|
||||||
-- 2. Select a project.
|
-- 2. Select a project.
|
||||||
@ -10,6 +8,10 @@ do
|
|||||||
-- google_apikey = "YOURKEY-HERE",
|
-- google_apikey = "YOURKEY-HERE",
|
||||||
-- Your quota is 50.000.000 per day and a search takes 100 points. So if you manage to use this in one day, you're a real spammer :P
|
-- Your quota is 50.000.000 per day and a search takes 100 points. So if you manage to use this in one day, you're a real spammer :P
|
||||||
|
|
||||||
|
do
|
||||||
|
|
||||||
|
require("./plugins/youtube")
|
||||||
|
|
||||||
local function searchYoutubeVideo(text)
|
local function searchYoutubeVideo(text)
|
||||||
local apikey = cred_data.google_apikey
|
local apikey = cred_data.google_apikey
|
||||||
local data = httpsRequest('https://www.googleapis.com/youtube/v3/search?part=snippet&key='..apikey..'&maxResults=1&type=video&q=' .. URL.escape(text))
|
local data = httpsRequest('https://www.googleapis.com/youtube/v3/search?part=snippet&key='..apikey..'&maxResults=1&type=video&q=' .. URL.escape(text))
|
||||||
@ -33,11 +35,15 @@ end
|
|||||||
function run(msg, matches)
|
function run(msg, matches)
|
||||||
local text = msg.text:sub(string.len(matches[1]) + 1,-1)
|
local text = msg.text:sub(string.len(matches[1]) + 1,-1)
|
||||||
local link = searchYoutubeVideo(text)
|
local link = searchYoutubeVideo(text)
|
||||||
|
local yt_code = videoId
|
||||||
|
local data = get_yt_data(yt_code)
|
||||||
|
local receiver = get_receiver(msg)
|
||||||
|
send_youtube_data(data, receiver, link)
|
||||||
return searchYoutubeVideo(text)
|
return searchYoutubeVideo(text)
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
description = "Sucht YouTube-Video und sendet es",
|
description = "Sucht ein YouTube-Video und sendet es",
|
||||||
usage = {"/youtube [Suchbegriff]","/yt [Suchbegriff]"},
|
usage = {"/youtube [Suchbegriff]","/yt [Suchbegriff]"},
|
||||||
patterns = {"^/youtube","^/yt"},
|
patterns = {"^/youtube","^/yt"},
|
||||||
run = run
|
run = run
|
||||||
|
Reference in New Issue
Block a user