Jump to content

get some CEF properties


Overkillz

Recommended Posts

Hey there lovely community. Today I started to do some research about CEF and 

I would like to know if there is a way to get youtube video length withou using an api or external websites.

What do i mean ?

I mean if is possible to reach it by using some of the followings functions

I have just tried getBrowserProperty by typing some keys words but without success.

Thanks for reading. Regards.

Link to comment

I think hacking together a way to get the video length would be far too troublesome than to just use the YouTube API:

local apiKey - "yourKey"
local videoID = "-6u8vrRM52g"

fetchRemote("https://www.googleapis.com/youtube/v3/videos?id="..videoID.."&key="..apiKey.."&fields=items(contentDetails(duration))&part=snippet,contentDetails",fetchCompleted,"",true)

function fetchCompleted(data,err)
	if err == 0 then
		local videoLengthData = fromJSON(data)
		if videoLengthData then
			iprint(videoLengthData)
		end
	else
		outputDebugString("API: Unable to connect to Google APIs")
	end
end

If you want to use multiple video ids in a table you can do this:
 

local videoIDS = {
  "KiVBoh71yqU",
  "KiVBoh71yqU",
  "-6u8vrRM52g"
}

fetchRemote("https://www.googleapis.com/youtube/v3/videos?id="..table.concat(videoIDs,",").."&key="..apiKey.."&fields=items(contentDetails(duration))&part=snippet,contentDetails",fetchCompleted,"",true)

 

  • Like 2
Link to comment

Edit: I just change few things from your code to reach the goal

function downloadCallback2(data,err)
	if err == 0 then
		local videoLengthData = fromJSON(data)
		if videoLengthData then
			iprint(videoLengthData.items[1].contentDetails.duration)
		end
	else
		outputDebugString("API: Unable to connect to Google APIs")
	end
end

local apiKey = "myCustomAPIKey"
local videoID = "ZRG5oOL5WO0"

fetchRemote("https://www.googleapis.com/youtube/v3/videos?part=contentDetails&id="..videoID.."&key="..apiKey,downloadCallback2,"",true)

But, Im still asking, 

Is there a way to get current video minute, buffer stored ... aswell ?

Regards.

Link to comment
34 minutes ago, Overkillz said:

It always drops me: API: Unable to connect to Google APIs

It works fine for me tho

ZfiQ7PF.png

Try adding the googleapis domain to your whitelist if you're fetching from client

36 minutes ago, Overkillz said:

Is there a way to get current video minute, buffer stored ... aswell ?

I honestly have no idea. I searched a lot before using the API ad couldn't find anything. Would probably need to enable debugging and check there.

  • Like 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...