Overkillz Posted March 14, 2019 Share Posted March 14, 2019 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 Spoiler canBrowserNavigateBack canBrowserNavigateForward createBrowser executeBrowserJavascript focusBrowser getBrowserProperty getBrowserSettings getBrowserSource getBrowserTitle getBrowserURL injectBrowserMouseDown injectBrowserMouseMove injectBrowserMouseUp injectBrowserMouseWheel isBrowserDomainBlocked isBrowserFocused isBrowserLoading loadBrowserURL navigateBrowserBack navigateBrowserForward reloadBrowserPage requestBrowserDomains resizeBrowser setBrowserAjaxHandler setBrowserProperty setBrowserRenderingPaused setBrowserVolume toggleBrowserDevTools I have just tried getBrowserProperty by typing some keys words but without success. Thanks for reading. Regards. Link to comment
Mr.Loki Posted March 14, 2019 Share Posted March 14, 2019 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) 2 Link to comment
Overkillz Posted March 15, 2019 Author Share Posted March 15, 2019 Nice, but for a reason I can't get it. I have just created a new YouTube Data API v3 and It always drops me: API: Unable to connect to Google APIs Otherwise. Is there a way to get current video minute, buffer stored ... aswell ? Regards. Link to comment
Overkillz Posted March 15, 2019 Author Share Posted March 15, 2019 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
Mr.Loki Posted March 15, 2019 Share Posted March 15, 2019 34 minutes ago, Overkillz said: It always drops me: API: Unable to connect to Google APIs It works fine for me tho 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. 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now