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)
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)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res).items[1]
@ -67,20 +67,26 @@ end
function send_youtube_data(data, receiver, link, sendpic)
local title = data.snippet.localized.title
--local description = data.snippet.localized.description
local upload_date = makeOurDate(data.snippet.publishedAt)
-- local description = data.snippet.localized.description
local uploader = data.snippet.channelTitle
local upload_date = makeOurDate(data.snippet.publishedAt)
local viewCount = comma_value(data.statistics.viewCount)
local duration = makeHumanTime(totalseconds)
if data.statistics.likeCount then
likeCount = comma_value(data.statistics.likeCount)
dislikeCount = comma_value(data.statistics.dislikeCount)
likeCount = ', '..comma_value(data.statistics.likeCount)..' Likes und '
dislikeCount = comma_value(data.statistics.dislikeCount)..' Dislikes'
else
likeCount = ''
dislikeCount = ''
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 duration = makeHumanTime(totalseconds)
if data.contentDetails.regionRestriction then
blocked = data.contentDetails.regionRestriction.blocked
blocked = table.contains(blocked, "DE")
@ -88,8 +94,7 @@ function send_youtube_data(data, receiver, link, sendpic)
blocked = false
end
--text = 'Titel: '..title..'\nUploader: '..uploader..'\nAufrufe: '..viewCount..'\nLänge: '..duration..' Stunden\nLikes: '..likeCount..'\nDislikes: '..dislikeCount..'\nKommentare: '..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'
text = title..'\n('..uploader..' am '..upload_date..', '..viewCount..'x angesehen, Länge: '..duration..likeCount..dislikeCount..commentCount..')\n'
if link then
text = link..'\n'..text
end