YouTube Plugin gefixt

This commit is contained in:
Akamaru 2016-01-31 22:29:17 +01:00
parent 9f4e1b7be1
commit 3ef8077b94

View File

@ -19,7 +19,7 @@ end
function get_yt_data (yt_code) function get_yt_data (yt_code)
local apikey = cred_data.google_apikey local apikey = cred_data.google_apikey
local url = BASE_URL..'/videos?part=snippet,statistics,contentDetails&key='..apikey..'&id='..yt_code..'&fields=items(snippet(channelTitle,localized(title,description),thumbnails),statistics(viewCount,likeCount,dislikeCount,commentCount),contentDetails(duration,regionRestriction(blocked)))' local url = BASE_URL..'/videos?part=snippet,statistics,contentDetails&key='..apikey..'&id='..yt_code..'&fields=items(snippet(publishedAt,channelTitle,localized(title,description),thumbnails),statistics(viewCount,likeCount,dislikeCount,commentCount),contentDetails(duration,regionRestriction(blocked)))'
local res,code = https.request(url) local res,code = https.request(url)
if code ~= 200 then return "HTTP-FEHLER" end if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res).items[1] local data = json:decode(res).items[1]
@ -68,19 +68,25 @@ end
function send_youtube_data(data, receiver, link, sendpic) function send_youtube_data(data, receiver, link, sendpic)
local title = data.snippet.localized.title local title = data.snippet.localized.title
-- local description = data.snippet.localized.description -- local description = data.snippet.localized.description
local upload_date = makeOurDate(data.snippet.publishedAt)
local uploader = data.snippet.channelTitle local uploader = data.snippet.channelTitle
local upload_date = makeOurDate(data.snippet.publishedAt)
local viewCount = comma_value(data.statistics.viewCount) local viewCount = comma_value(data.statistics.viewCount)
local duration = makeHumanTime(totalseconds)
if data.statistics.likeCount then if data.statistics.likeCount then
likeCount = comma_value(data.statistics.likeCount) likeCount = ', '..comma_value(data.statistics.likeCount)..' Likes und '
dislikeCount = comma_value(data.statistics.dislikeCount) dislikeCount = comma_value(data.statistics.dislikeCount)..' Dislikes'
else else
likeCount = '' likeCount = ''
dislikeCount = '' dislikeCount = ''
end end
local commentCount = comma_value(data.statistics.commentCount)
if data.statistics.commentCount then
commentCount = ', '..comma_value(data.statistics.commentCount)..' Kommentare'
else
commentCount = ''
end
local totalseconds = convertISO8601Time(data.contentDetails.duration) local totalseconds = convertISO8601Time(data.contentDetails.duration)
local duration = makeHumanTime(totalseconds)
if data.contentDetails.regionRestriction then if data.contentDetails.regionRestriction then
blocked = data.contentDetails.regionRestriction.blocked blocked = data.contentDetails.regionRestriction.blocked
blocked = table.contains(blocked, "DE") blocked = table.contains(blocked, "DE")
@ -88,8 +94,7 @@ function send_youtube_data(data, receiver, link, sendpic)
blocked = false blocked = false
end end
--text = 'Titel: '..title..'\nUploader: '..uploader..'\nAufrufe: '..viewCount..'\nLänge: '..duration..' Stunden\nLikes: '..likeCount..'\nDislikes: '..dislikeCount..'\nKommentare: '..commentCount..'\n' text = title..'\n('..uploader..' am '..upload_date..', '..viewCount..'x angesehen, Länge: '..duration..likeCount..dislikeCount..commentCount..')\n'
text = '"'..title..'" hochgeladen am '..upload_date..' von "'..uploader..'"\n'..viewCount..' Aufrufe, Länge: '..duration..' Stunden, '..likeCount..' Likes und '..dislikeCount..' Dislikes, '..commentCount..' Kommentare\n\n'
if link then if link then
text = link..'\n'..text text = link..'\n'..text
end end