diff --git a/extensions/community/YouTubeSDK.json b/extensions/community/YouTubeSDK.json new file mode 100644 index 000000000..1ee5c616a --- /dev/null +++ b/extensions/community/YouTubeSDK.json @@ -0,0 +1,2525 @@ +{ + "author": "", + "category": "Third-party", + "dimension": "", + "extensionNamespace": "", + "fullName": "YouTube SDK", + "gdevelopVersion": "", + "helpPath": "https://github.com/GDevelopApp/GDevelop-extensions/issues/new?template=bug-report.yml&title=%5BYouTubeSDK%5D", + "iconUrl": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0ibWRpLXlvdXR1YmUiIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTAsMTVMMTUuMTksMTJMMTAsOVYxNU0yMS41Niw3LjE3QzIxLjY5LDcuNjQgMjEuNzgsOC4yNyAyMS44NCw5LjA3QzIxLjkxLDkuODcgMjEuOTQsMTAuNTYgMjEuOTQsMTEuMTZMMjIsMTJDMjIsMTQuMTkgMjEuODQsMTUuOCAyMS41NiwxNi44M0MyMS4zMSwxNy43MyAyMC43MywxOC4zMSAxOS44MywxOC41NkMxOS4zNiwxOC42OSAxOC41LDE4Ljc4IDE3LjE4LDE4Ljg0QzE1Ljg4LDE4LjkxIDE0LjY5LDE4Ljk0IDEzLjU5LDE4Ljk0TDEyLDE5QzcuODEsMTkgNS4yLDE4Ljg0IDQuMTcsMTguNTZDMy4yNywxOC4zMSAyLjY5LDE3LjczIDIuNDQsMTYuODNDMi4zMSwxNi4zNiAyLjIyLDE1LjczIDIuMTYsMTQuOTNDMi4wOSwxNC4xMyAyLjA2LDEzLjQ0IDIuMDYsMTIuODRMMiwxMkMyLDkuODEgMi4xNiw4LjIgMi40NCw3LjE3QzIuNjksNi4yNyAzLjI3LDUuNjkgNC4xNyw1LjQ0QzQuNjQsNS4zMSA1LjUsNS4yMiA2LjgyLDUuMTZDOC4xMiw1LjA5IDkuMzEsNS4wNiAxMC40MSw1LjA2TDEyLDVDMTYuMTksNSAxOC44LDUuMTYgMTkuODMsNS40NEMyMC43Myw1LjY5IDIxLjMxLDYuMjcgMjEuNTYsNy4xN1oiIC8+PC9zdmc+", + "name": "YouTubeSDK", + "previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/9ae52130760954736a653fb090dfec5ed9a8ffc0d881f27616ad3a6192dd602c_youtube.svg", + "shortDescription": "Get Info About Account's Subscribers And More.", + "version": "0.0.1", + "description": [ + "Account", + "- Sub Count", + "- Account Name", + "- Videos Count", + "- Account Bio", + "- Account Join Date", + "- Account View Count", + "- Account Location", + "- Save Profile lcon", + "", + "Comments", + "- Get Comment In Video", + "- Video Comment Count", + "", + "Search", + "- Search Users", + "- Search Videos", + "", + "Video", + "- Load URL", + "- Load Using VID ID", + "- Get Like Count", + "- Get Video Title", + "- Get Video Description", + "- Get Video Publisher", + "- Get Video Publisher", + "- Save Thumbnail", + "- Get Video URL", + "- Get Video ID By URL", + "", + "Extra", + "Load Base64 Images On Objects." + ], + "tags": [ + "YouTube", + "SDK" + ], + "authorIds": [ + "LmDPcZ5ey4WWF4VdoEQcmPVTmFu2" + ], + "dependencies": [], + "globalVariables": [], + "sceneVariables": [], + "eventsFunctions": [ + { + "description": "Get Subscriber Count For Account.", + "fullName": "Subscriber Count", + "functionType": "Action", + "group": "Account", + "name": "SubCount", + "sentence": "Subscriber Count _PARAM1_,_PARAM2_,_PARAM3_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const username = eventsFunctionContext.getArgument(\"Username\");", + "const apiArgument = eventsFunctionContext.getArgument(\"API\");", + "const storeVar = eventsFunctionContext.getArgument(\"StoreVar\");", + "", + "let apiKey = apiArgument;", + "", + "if (apiKey === \"\") {", + " const extensionVariables =", + " runtimeScene.getGame().getVariablesForExtension(\"YouTubeSDK\");", + "", + " if (extensionVariables !== null && extensionVariables.has(\"API\")) {", + " apiKey = extensionVariables.get(\"API\").getAsString();", + " }", + " }", + "", + " if (apiKey === \"\") {", + " console.error(\"[YouTubeSDK] Missing API\");", + " return;", + " }", + "", + " if (username === \"\") {", + " console.error(\"[YouTubeSDK] Missing Username\");", + " return;", + " }", + "", + " let handle = username;", + "", + " if (handle.charAt(0) === \"@\") {", + " handle = handle.substring(1);", + " }", + "", + " const url =", + " \"https://www.googleapis.com/youtube/v3/channels\" +", + " \"?part=statistics\" +", + " \"&forHandle=\" + encodeURIComponent(handle) +", + " \"&key=\" + encodeURIComponent(apiKey);", + "", + " fetch(url)", + " .then(function(response) {", + " return response.json().then(function(data) {", + " if (!response.ok) {", + " if (data.error && data.error.message) {", + " throw new Error(data.error.message);", + " }", + "", + " throw new Error(\"YouTube API request failed\");", + " }", + "", + " return data;", + " });", + " })", + " .then(function(data) {", + " if (!data.items || data.items.length === 0) {", + " console.error(\"[YouTubeSDK] Channel not found\");", + " return;", + " }", + "", + " const subscriberCount =", + " String(data.items[0].statistics.subscriberCount);", + "", + " storeVar.setString(subscriberCount);", + " })", + " .catch(function(error) {", + " console.error(\"[YouTubeSDK] \" + error.message);", + " });" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Username", + "longDescription": "The YouTube's Account Username.", + "name": "Username", + "type": "string" + }, + { + "description": "API", + "longDescription": "Create API: https://console.cloud.google.com/.", + "name": "API", + "type": "string" + }, + { + "description": "Store Variable", + "name": "StoreVar", + "type": "variable" + } + ], + "objectGroups": [] + }, + { + "description": "Get Account Name Using Username.", + "fullName": "Account Name", + "functionType": "Action", + "group": "Account", + "name": "AccountName", + "sentence": "Account Name _PARAM1_,_PARAM2_,_PARAM3_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const username = eventsFunctionContext.getArgument(\"Username\");", + "const apiArgument = eventsFunctionContext.getArgument(\"API\");", + "const storeVar = eventsFunctionContext.getArgument(\"StoreVar\");", + "", + "let apiKey = apiArgument;", + "", + "if (apiKey === \"\") {", + " const extensionVariables =", + " runtimeScene.getGame().getVariablesForExtension(\"YouTubeSDK\");", + "", + " if (extensionVariables !== null && extensionVariables.has(\"API\")) {", + " apiKey = extensionVariables.get(\"API\").getAsString();", + " }", + " }", + "", + " if (apiKey === \"\") {", + " console.error(\"[YouTubeSDK] Missing API\");", + " return;", + " }", + "", + " if (username === \"\") {", + " console.error(\"[YouTubeSDK] Missing Username\");", + " return;", + " }", + "", + " let handle = username;", + "", + " if (handle.charAt(0) === \"@\") {", + " handle = handle.substring(1);", + " }", + "", + " const url =", + " \"https://www.googleapis.com/youtube/v3/channels\" +", + " \"?part=snippet\" +", + " \"&forHandle=\" + encodeURIComponent(handle) +", + " \"&key=\" + encodeURIComponent(apiKey);", + "", + " fetch(url)", + " .then(function(response) {", + " return response.json().then(function(data) {", + " if (!response.ok) {", + " if (data.error && data.error.message) {", + " throw new Error(data.error.message);", + " }", + "", + " throw new Error(\"YouTube API request failed\");", + " }", + "", + " return data;", + " });", + " })", + " .then(function(data) {", + " if (!data.items || data.items.length === 0) {", + " console.error(\"[YouTubeSDK] Channel not found\");", + " return;", + " }", + "", + " const channelName = data.items[0].snippet.title;", + "", + " storeVar.setString(channelName);", + " })", + " .catch(function(error) {", + " console.error(\"[YouTubeSDK] \" + error.message);", + " });" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Username", + "longDescription": "The YouTube's Account Username.", + "name": "Username", + "type": "string" + }, + { + "description": "API", + "longDescription": "Create API: https://console.cloud.google.com/.", + "name": "API", + "type": "string" + }, + { + "description": "Store Variable", + "name": "StoreVar", + "type": "variable" + } + ], + "objectGroups": [] + }, + { + "description": "Get Account's Number Of Videos.", + "fullName": "Number Of Videos", + "functionType": "Action", + "group": "Account", + "name": "VideosCount", + "sentence": "Number Of Videos _PARAM1_,_PARAM2_,_PARAM3_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const username = eventsFunctionContext.getArgument(\"Username\");", + "const apiArgument = eventsFunctionContext.getArgument(\"API\");", + "const storeVar = eventsFunctionContext.getArgument(\"StoreVar\");", + "", + "let apiKey = apiArgument;", + "", + "if (apiKey === \"\") {", + " const extensionVariables =", + " runtimeScene.getGame().getVariablesForExtension(\"YouTubeSDK\");", + "", + " if (extensionVariables !== null && extensionVariables.has(\"API\")) {", + " apiKey = extensionVariables.get(\"API\").getAsString();", + " }", + " }", + "", + " if (apiKey === \"\") {", + " console.error(\"[YouTubeSDK] Missing API\");", + " return;", + " }", + "", + " if (username === \"\") {", + " console.error(\"[YouTubeSDK] Missing Username\");", + " return;", + " }", + "", + " let handle = username;", + "", + " if (handle.charAt(0) === \"@\") {", + " handle = handle.substring(1);", + " }", + "", + " const url =", + " \"https://www.googleapis.com/youtube/v3/channels\" +", + " \"?part=statistics\" +", + " \"&forHandle=\" + encodeURIComponent(handle) +", + " \"&key=\" + encodeURIComponent(apiKey);", + "", + " fetch(url)", + " .then(function(response) {", + " return response.json().then(function(data) {", + " if (!response.ok) {", + " if (data.error && data.error.message) {", + " throw new Error(data.error.message);", + " }", + "", + " throw new Error(\"YouTube API request failed\");", + " }", + "", + " return data;", + " });", + " })", + " .then(function(data) {", + " if (!data.items || data.items.length === 0) {", + " console.error(\"[YouTubeSDK] Channel not found\");", + " return;", + " }", + "", + " const videoCount =", + " String(data.items[0].statistics.videoCount);", + "", + " storeVar.setString(videoCount);", + " })", + " .catch(function(error) {", + " console.error(\"[YouTubeSDK] \" + error.message);", + " });" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Username", + "longDescription": "The YouTube's Account Username.", + "name": "Username", + "type": "string" + }, + { + "description": "API", + "longDescription": "Create API: https://console.cloud.google.com/.", + "name": "API", + "type": "string" + }, + { + "description": "Store Variable", + "name": "StoreVar", + "type": "variable" + } + ], + "objectGroups": [] + }, + { + "description": "Get Account's Bio Or Description.", + "fullName": "Account Bio", + "functionType": "Action", + "group": "Account", + "name": "AccountBio", + "sentence": "Account Bio _PARAM1_,_PARAM2_,_PARAM3_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const username = eventsFunctionContext.getArgument(\"Username\");", + "const apiArgument = eventsFunctionContext.getArgument(\"API\");", + "const storeVar = eventsFunctionContext.getArgument(\"StoreVar\");", + "", + "let apiKey = apiArgument;", + "", + "if (apiKey === \"\") {", + " const extensionVariables =", + " runtimeScene.getGame().getVariablesForExtension(\"YouTubeSDK\");", + "", + " if (extensionVariables !== null && extensionVariables.has(\"API\")) {", + " apiKey = extensionVariables.get(\"API\").getAsString();", + " }", + " }", + "", + " if (apiKey === \"\") {", + " console.error(\"[YouTubeSDK] Missing API\");", + " return;", + " }", + "", + " if (username === \"\") {", + " console.error(\"[YouTubeSDK] Missing Username\");", + " return;", + " }", + "", + " let handle = username;", + "", + " if (handle.charAt(0) === \"@\") {", + " handle = handle.substring(1);", + " }", + "", + " const url =", + " \"https://www.googleapis.com/youtube/v3/channels\" +", + " \"?part=snippet\" +", + " \"&forHandle=\" + encodeURIComponent(handle) +", + " \"&key=\" + encodeURIComponent(apiKey);", + "", + " fetch(url)", + " .then(function(response) {", + " return response.json().then(function(data) {", + " if (!response.ok) {", + " if (data.error && data.error.message) {", + " throw new Error(data.error.message);", + " }", + "", + " throw new Error(\"YouTube API request failed\");", + " }", + "", + " return data;", + " });", + " })", + " .then(function(data) {", + " if (!data.items || data.items.length === 0) {", + " console.error(\"[YouTubeSDK] Channel not found\");", + " return;", + " }", + "", + " const bio = data.items[0].snippet.description;", + "", + " storeVar.setString(bio);", + " })", + " .catch(function(error) {", + " console.error(\"[YouTubeSDK] \" + error.message);", + " });" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Username", + "longDescription": "The YouTube's Account Username.", + "name": "Username", + "type": "string" + }, + { + "description": "API", + "longDescription": "Create API: https://console.cloud.google.com/.", + "name": "API", + "type": "string" + }, + { + "description": "Store Variable", + "name": "StoreVar", + "type": "variable" + } + ], + "objectGroups": [] + }, + { + "description": "Get Account's Join Date, When The Account Was Created.", + "fullName": "Account Join Date", + "functionType": "Action", + "group": "Account", + "name": "AccountJoinDate", + "sentence": "Account Join Date _PARAM1_,_PARAM2_,_PARAM3_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const username = eventsFunctionContext.getArgument(\"Username\");", + "const apiArgument = eventsFunctionContext.getArgument(\"API\");", + "const storeVar = eventsFunctionContext.getArgument(\"StoreVar\");", + "", + "let apiKey = apiArgument;", + "", + "if (apiKey === \"\") {", + " const extensionVariables =", + " runtimeScene.getGame().getVariablesForExtension(\"YouTubeSDK\");", + "", + " if (extensionVariables !== null && extensionVariables.has(\"API\")) {", + " apiKey = extensionVariables.get(\"API\").getAsString();", + " }", + " }", + "", + " if (apiKey === \"\") {", + " console.error(\"[YouTubeSDK] Missing API\");", + " return;", + " }", + "", + " if (username === \"\") {", + " console.error(\"[YouTubeSDK] Missing Username\");", + " return;", + " }", + "", + " let handle = username;", + "", + " if (handle.charAt(0) === \"@\") {", + " handle = handle.substring(1);", + " }", + "", + " const url =", + " \"https://www.googleapis.com/youtube/v3/channels\" +", + " \"?part=snippet\" +", + " \"&forHandle=\" + encodeURIComponent(handle) +", + " \"&key=\" + encodeURIComponent(apiKey);", + "", + " fetch(url)", + " .then(function(response) {", + " return response.json().then(function(data) {", + " if (!response.ok) {", + " if (data.error && data.error.message) {", + " throw new Error(data.error.message);", + " }", + "", + " throw new Error(\"YouTube API request failed\");", + " }", + "", + " return data;", + " });", + " })", + " .then(function(data) {", + " if (!data.items || data.items.length === 0) {", + " console.error(\"[YouTubeSDK] Channel not found\");", + " return;", + " }", + "", + " const joinDate = data.items[0].snippet.publishedAt;", + "", + " storeVar.setString(joinDate);", + " })", + " .catch(function(error) {", + " console.error(\"[YouTubeSDK] \" + error.message);", + " });" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Username", + "longDescription": "The YouTube's Account Username.", + "name": "Username", + "type": "string" + }, + { + "description": "API", + "longDescription": "Create API: https://console.cloud.google.com/.", + "name": "API", + "type": "string" + }, + { + "description": "Store Variable", + "name": "StoreVar", + "type": "variable" + } + ], + "objectGroups": [] + }, + { + "description": "Get Account's Views (Combined From Every Video).", + "fullName": "Account Views", + "functionType": "Action", + "group": "Account", + "name": "AccountViewCount", + "sentence": "Account Views _PARAM1_,_PARAM2_,_PARAM3_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const username = eventsFunctionContext.getArgument(\"Username\");", + "const apiArgument = eventsFunctionContext.getArgument(\"API\");", + "const storeVar = eventsFunctionContext.getArgument(\"StoreVar\");", + "", + "let apiKey = apiArgument;", + "", + "if (apiKey === \"\") {", + " const extensionVariables =", + " runtimeScene.getGame().getVariablesForExtension(\"YouTubeSDK\");", + "", + " if (extensionVariables !== null && extensionVariables.has(\"API\")) {", + " apiKey = extensionVariables.get(\"API\").getAsString();", + " }", + " }", + "", + " if (apiKey === \"\") {", + " console.error(\"[YouTubeSDK] Missing API\");", + " return;", + " }", + "", + " let handle = username;", + "", + " if (handle.charAt(0) === \"@\") {", + " handle = handle.substring(1);", + " }", + "", + " const url =", + " \"https://www.googleapis.com/youtube/v3/channels\" +", + " \"?part=statistics\" +", + " \"&forHandle=\" + encodeURIComponent(handle) +", + " \"&key=\" + encodeURIComponent(apiKey);", + "", + " fetch(url)", + " .then(function(response) {", + " return response.json().then(function(data) {", + " if (!response.ok) {", + " if (data.error && data.error.message) {", + " throw new Error(data.error.message);", + " }", + "", + " throw new Error(\"YouTube API request failed\");", + " }", + "", + " return data;", + " });", + " })", + " .then(function(data) {", + " if (!data.items || data.items.length === 0) {", + " console.error(\"[YouTubeSDK] Channel not found\");", + " return;", + " }", + "", + " storeVar.setString(", + " String(data.items[0].statistics.viewCount)", + " );", + " })", + " .catch(function(error) {", + " console.error(\"[YouTubeSDK] \" + error.message);", + " });" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Username", + "longDescription": "The YouTube's Account Username.", + "name": "Username", + "type": "string" + }, + { + "description": "API", + "longDescription": "Create API: https://console.cloud.google.com/.", + "name": "API", + "type": "string" + }, + { + "description": "Store Variable", + "name": "StoreVar", + "type": "variable" + } + ], + "objectGroups": [] + }, + { + "description": "Get Account's Location, Like US, FR, MK..", + "fullName": "Account Location", + "functionType": "Action", + "group": "Account", + "name": "AccountLocation", + "sentence": "Account Views _PARAM1_,_PARAM2_,_PARAM3_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const username = eventsFunctionContext.getArgument(\"Username\");", + "const apiArgument = eventsFunctionContext.getArgument(\"API\");", + "const storeVar = eventsFunctionContext.getArgument(\"StoreVar\");", + "", + "let apiKey = apiArgument;", + "", + "if (apiKey === \"\") {", + " const extensionVariables =", + " runtimeScene.getGame().getVariablesForExtension(\"YouTubeSDK\");", + "", + " if (extensionVariables !== null && extensionVariables.has(\"API\")) {", + " apiKey = extensionVariables.get(\"API\").getAsString();", + " }", + " }", + "", + " if (apiKey === \"\") {", + " console.error(\"[YouTubeSDK] Missing API\");", + " return;", + " }", + "", + " let handle = username;", + "", + " if (handle.charAt(0) === \"@\") {", + " handle = handle.substring(1);", + " }", + "", + " const url =", + " \"https://www.googleapis.com/youtube/v3/channels\" +", + " \"?part=snippet\" +", + " \"&forHandle=\" + encodeURIComponent(handle) +", + " \"&key=\" + encodeURIComponent(apiKey);", + "", + " fetch(url)", + " .then(function(response) {", + " return response.json().then(function(data) {", + " if (!response.ok) {", + " if (data.error && data.error.message) {", + " throw new Error(data.error.message);", + " }", + "", + " throw new Error(\"YouTube API request failed\");", + " }", + "", + " return data;", + " });", + " })", + " .then(function(data) {", + " if (!data.items || data.items.length === 0) {", + " console.error(\"[YouTubeSDK] Channel not found\");", + " return;", + " }", + "", + " const country = data.items[0].snippet.country || \"\";", + "", + " storeVar.setString(country);", + " })", + " .catch(function(error) {", + " console.error(\"[YouTubeSDK] \" + error.message);", + " });" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Username", + "longDescription": "The YouTube's Account Username.", + "name": "Username", + "type": "string" + }, + { + "description": "API", + "longDescription": "Create API: https://console.cloud.google.com/.", + "name": "API", + "type": "string" + }, + { + "description": "Store Variable", + "name": "StoreVar", + "type": "variable" + } + ], + "objectGroups": [] + }, + { + "description": "Get Account's Profile Icon And Saves It As Base64.", + "fullName": "Save Profile Icon", + "functionType": "Action", + "group": "Account", + "name": "SaveProfileIcon", + "sentence": "Save Profile Icon _PARAM1_,_PARAM2_,_PARAM3_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const username = eventsFunctionContext.getArgument(\"Username\");", + "const apiArgument = eventsFunctionContext.getArgument(\"API\");", + "const storeVar = eventsFunctionContext.getArgument(\"StoreVar\");", + "", + "let apiKey = apiArgument;", + "", + "if (apiKey === \"\") {", + " const extensionVariables =", + " runtimeScene.getGame().getVariablesForExtension(\"YouTubeSDK\");", + "", + " if (extensionVariables !== null && extensionVariables.has(\"API\")) {", + " apiKey = extensionVariables.get(\"API\").getAsString();", + " }", + " }", + "", + " if (apiKey === \"\") {", + " console.error(\"[YouTubeSDK] Missing API\");", + " return;", + " }", + "", + " if (username === \"\") {", + " console.error(\"[YouTubeSDK] Missing Username\");", + " return;", + " }", + "", + " let handle = username;", + "", + " if (handle.charAt(0) === \"@\") {", + " handle = handle.substring(1);", + " }", + "", + " const url =", + " \"https://www.googleapis.com/youtube/v3/channels\" +", + " \"?part=snippet\" +", + " \"&forHandle=\" + encodeURIComponent(handle) +", + " \"&key=\" + encodeURIComponent(apiKey);", + "", + " fetch(url)", + " .then(function(response) {", + " return response.json().then(function(data) {", + " if (!response.ok) {", + " throw new Error(\"YouTube API request failed\");", + " }", + "", + " return data;", + " });", + " })", + " .then(function(data) {", + " if (!data.items || data.items.length === 0) {", + " console.error(\"[YouTubeSDK] Channel not found\");", + " return;", + " }", + "", + " const thumbnails = data.items[0].snippet.thumbnails;", + "", + " let imageURL = \"\";", + "", + " if (thumbnails.high) {", + " imageURL = thumbnails.high.url;", + " } else if (thumbnails.medium) {", + " imageURL = thumbnails.medium.url;", + " } else if (thumbnails.default) {", + " imageURL = thumbnails.default.url;", + " }", + "", + " if (imageURL === \"\") {", + " console.error(\"[YouTubeSDK] Profile picture not found\");", + " return;", + " }", + "", + " return fetch(imageURL);", + " })", + " .then(function(response) {", + " if (!response) {", + " return;", + " }", + "", + " return response.blob();", + " })", + " .then(function(blob) {", + " if (!blob) {", + " return;", + " }", + "", + " return new Promise(function(resolve, reject) {", + " const reader = new FileReader();", + "", + " reader.onloadend = function() {", + " resolve(reader.result);", + " };", + "", + " reader.onerror = reject;", + "", + " reader.readAsDataURL(blob);", + " });", + " })", + " .then(function(base64) {", + " if (base64) {", + " storeVar.setString(base64);", + " }", + " })", + " .catch(function(error) {", + " console.error(\"[YouTubeSDK] \" + error.message);", + " });" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Username", + "longDescription": "The YouTube's Account Username.", + "name": "Username", + "type": "string" + }, + { + "description": "API", + "longDescription": "Create API: https://console.cloud.google.com/.", + "name": "API", + "type": "string" + }, + { + "description": "Store Variable", + "name": "StoreVar", + "type": "variable" + } + ], + "objectGroups": [] + }, + { + "description": "Load's Base64 Image On Top Of Objects.", + "fullName": "Load Base64 Image", + "functionType": "Action", + "name": "LoadBase64OBj", + "sentence": "Load Base64 Image _PARAM1_,_PARAM2_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const object = eventsFunctionContext.getObjects(\"Object\")[0];", + "const base64 = eventsFunctionContext.getArgument(\"Base64\");", + "", + "if (!object || !base64) {", + " return;", + " }", + "", + " const rendererObject = object.getRendererObject();", + "", + " if (!rendererObject) {", + " return;", + " }", + "", + " const texture = PIXI.Texture.from(base64);", + "", + " rendererObject.texture = texture;", + " rendererObject.width = object.getWidth();", + " rendererObject.height = object.getHeight();" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "type": "objectList" + }, + { + "description": "Base64", + "name": "Base64", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Load URL Video On Top Of Object.", + "fullName": "Load URL Video", + "functionType": "Action", + "group": "Video", + "name": "LoadURL", + "sentence": "Load URL Video _PARAM1_,_PARAM2_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const object = eventsFunctionContext.getObjects(\"Object\")[0];", + "const videoURL = eventsFunctionContext.getArgument(\"URL\");", + "", + "if (!object || !videoURL) {", + " return;", + " }", + "", + " const rendererObject = object.getRendererObject();", + "", + " if (!rendererObject) {", + " return;", + " }", + "", + " let videoId = \"\";", + "", + " try {", + " const url = new URL(videoURL);", + "", + " if (url.hostname === \"youtu.be\") {", + " videoId = url.pathname.substring(1);", + " } else if (", + " url.hostname === \"www.youtube.com\" ||", + " url.hostname === \"youtube.com\" ||", + " url.hostname === \"m.youtube.com\"", + " ) {", + " videoId = url.searchParams.get(\"v\") || \"\";", + "", + " if (videoId === \"\" && url.pathname.indexOf(\"/embed/\") === 0) {", + " videoId = url.pathname.substring(7);", + " }", + " }", + " } catch (error) {", + " return;", + " }", + "", + " if (videoId === \"\") {", + " return;", + " }", + "", + " const iframe = document.createElement(\"iframe\");", + "", + " iframe.src =", + " \"https://www.youtube.com/embed/\" +", + " encodeURIComponent(videoId) +", + " \"?autoplay=1\";", + "", + " iframe.style.position = \"fixed\";", + " iframe.style.border = \"0\";", + " iframe.style.margin = \"0\";", + " iframe.style.padding = \"0\";", + " iframe.style.pointerEvents = \"auto\";", + "", + " iframe.allow =", + " \"autoplay; encrypted-media; picture-in-picture\";", + "", + " iframe.allowFullscreen = true;", + "", + " const canvas = runtimeScene", + " .getGame()", + " .getRenderer()", + " .getCanvas();", + "", + " canvas.parentElement.appendChild(iframe);", + "", + " function updateVideo() {", + " if (!iframe.parentElement) {", + " return;", + " }", + "", + " const canvasRect = canvas.getBoundingClientRect();", + "", + " const gameWidth = canvas.width;", + " const gameHeight = canvas.height;", + "", + " const scaleX = canvasRect.width / gameWidth;", + " const scaleY = canvasRect.height / gameHeight;", + "", + " const x = rendererObject.x;", + " const y = rendererObject.y;", + " const width = rendererObject.width;", + " const height = rendererObject.height;", + "", + " iframe.style.left =", + " (canvasRect.left +", + " (x - width / 2) * scaleX) + \"px\";", + "", + " iframe.style.top =", + " (canvasRect.top +", + " (y - height / 2) * scaleY) + \"px\";", + "", + " iframe.style.width =", + " (width * scaleX) + \"px\";", + "", + " iframe.style.height =", + " (height * scaleY) + \"px\";", + " }", + "", + " updateVideo();", + "", + " if (!runtimeScene.__YouTubeSDKVideos) {", + " runtimeScene.__YouTubeSDKVideos = [];", + " }", + "", + " runtimeScene.__YouTubeSDKVideos.push({", + " iframe: iframe,", + " update: updateVideo", + " });" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "type": "objectList" + }, + { + "description": "URL Video", + "name": "URL", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Search Users And Get The Best Find.", + "fullName": "Search Users", + "functionType": "Action", + "group": "Search", + "name": "SearchUsers", + "sentence": "Search Users _PARAM1_,_PARAM2_,_PARAM3_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const search = eventsFunctionContext.getArgument(\"Search\");", + "const apiArgument = eventsFunctionContext.getArgument(\"API\");", + "const storeVar = eventsFunctionContext.getArgument(\"StoreVar\");", + "", + "let apiKey = apiArgument;", + "", + "if (apiKey === \"\") {", + " const extensionVariables =", + " runtimeScene.getGame().getVariablesForExtension(\"YouTubeSDK\");", + "", + " if (extensionVariables !== null && extensionVariables.has(\"API\")) {", + " apiKey = extensionVariables.get(\"API\").getAsString();", + " }", + " }", + "", + " if (apiKey === \"\") {", + " console.error(\"[YouTubeSDK] Missing API\");", + " return;", + " }", + "", + " if (search === \"\") {", + " console.error(\"[YouTubeSDK] Missing Search\");", + " return;", + " }", + "", + " const searchURL =", + " \"https://www.googleapis.com/youtube/v3/search\" +", + " \"?part=snippet\" +", + " \"&type=channel\" +", + " \"&maxResults=1\" +", + " \"&q=\" + encodeURIComponent(search) +", + " \"&key=\" + encodeURIComponent(apiKey);", + "", + " fetch(searchURL)", + " .then(function(response) {", + " return response.json().then(function(data) {", + " if (!response.ok) {", + " if (data.error && data.error.message) {", + " throw new Error(data.error.message);", + " }", + "", + " throw new Error(\"YouTube API request failed\");", + " }", + "", + " return data;", + " });", + " })", + " .then(function(data) {", + " if (!data.items || data.items.length === 0) {", + " console.error(\"[YouTubeSDK] Channel not found\");", + " return;", + " }", + "", + " const channelId = data.items[0].id.channelId;", + "", + " const channelURL =", + " \"https://www.googleapis.com/youtube/v3/channels\" +", + " \"?part=snippet\" +", + " \"&id=\" + encodeURIComponent(channelId) +", + " \"&key=\" + encodeURIComponent(apiKey);", + "", + " return fetch(channelURL)", + " .then(function(response) {", + " return response.json().then(function(channelData) {", + " if (!response.ok) {", + " throw new Error(\"YouTube API request failed\");", + " }", + "", + " return channelData;", + " });", + " });", + " })", + " .then(function(data) {", + " if (!data || !data.items || data.items.length === 0) {", + " return;", + " }", + "", + " const snippet = data.items[0].snippet;", + "", + " let username = \"\";", + "", + " if (snippet.customUrl) {", + " username = snippet.customUrl;", + "", + " if (username.charAt(0) !== \"@\") {", + " username = \"@\" + username;", + " }", + " }", + "", + " storeVar.setString(username);", + " })", + " .catch(function(error) {", + " console.error(\"[YouTubeSDK] \" + error.message);", + " });" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Search", + "name": "Search", + "type": "string" + }, + { + "description": "API", + "longDescription": "Create API: https://console.cloud.google.com/.", + "name": "API", + "type": "string" + }, + { + "description": "Store Variable", + "name": "StoreVar", + "type": "variable" + } + ], + "objectGroups": [] + }, + { + "description": "Search Videos And Get The Best Find, Stores The Video ID.", + "fullName": "Search Videos", + "functionType": "Action", + "group": "Search", + "name": "SearchVideos", + "sentence": "Search Videos _PARAM1_,_PARAM2_,_PARAM3_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const search = eventsFunctionContext.getArgument(\"Search\");", + "const apiArgument = eventsFunctionContext.getArgument(\"API\");", + "const storeVar = eventsFunctionContext.getArgument(\"StoreVar\");", + "", + "let apiKey = apiArgument;", + "", + "if (apiKey === \"\") {", + " const extensionVariables =", + " runtimeScene.getGame().getVariablesForExtension(\"YouTubeSDK\");", + "", + " if (extensionVariables !== null && extensionVariables.has(\"API\")) {", + " apiKey = extensionVariables.get(\"API\").getAsString();", + " }", + " }", + "", + " if (apiKey === \"\") {", + " console.error(\"[YouTubeSDK] Missing API\");", + " return;", + " }", + "", + " if (search === \"\") {", + " console.error(\"[YouTubeSDK] Missing Search\");", + " return;", + " }", + "", + " const url =", + " \"https://www.googleapis.com/youtube/v3/search\" +", + " \"?part=snippet\" +", + " \"&type=video\" +", + " \"&maxResults=1\" +", + " \"&q=\" + encodeURIComponent(search) +", + " \"&key=\" + encodeURIComponent(apiKey);", + "", + " fetch(url)", + " .then(function(response) {", + " return response.json().then(function(data) {", + " if (!response.ok) {", + " if (data.error && data.error.message) {", + " throw new Error(data.error.message);", + " }", + "", + " throw new Error(\"YouTube API request failed\");", + " }", + "", + " return data;", + " });", + " })", + " .then(function(data) {", + " if (!data.items || data.items.length === 0) {", + " console.error(\"[YouTubeSDK] Video not found\");", + " return;", + " }", + "", + " const videoId = data.items[0].id.videoId;", + "", + " storeVar.setString(videoId);", + " })", + " .catch(function(error) {", + " console.error(\"[YouTubeSDK] \" + error.message);", + " });" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Search", + "name": "Search", + "type": "string" + }, + { + "description": "API", + "longDescription": "Create API: https://console.cloud.google.com/.", + "name": "API", + "type": "string" + }, + { + "description": "Store Variable", + "name": "StoreVar", + "type": "variable" + } + ], + "objectGroups": [] + }, + { + "description": "Load Video On Top Of Object Using VideoID.", + "fullName": "Load Video From ID", + "functionType": "Action", + "group": "Video", + "name": "LoadUsingVIDID", + "sentence": "Load Video From ID _PARAM1_,_PARAM2_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const object = eventsFunctionContext.getObjects(\"Object\")[0];", + "const videoId = eventsFunctionContext.getArgument(\"VideoID\");", + "", + "if (!object || !videoId) {", + " return;", + " }", + "", + " const rendererObject = object.getRendererObject();", + "", + " if (!rendererObject) {", + " return;", + " }", + "", + " const iframe = document.createElement(\"iframe\");", + "", + " iframe.src =", + " \"https://www.youtube.com/embed/\" +", + " encodeURIComponent(videoId) +", + " \"?autoplay=1\";", + "", + " iframe.style.position = \"fixed\";", + " iframe.style.border = \"0\";", + " iframe.style.margin = \"0\";", + " iframe.style.padding = \"0\";", + " iframe.style.pointerEvents = \"auto\";", + "", + " iframe.allow =", + " \"autoplay; encrypted-media; picture-in-picture\";", + "", + " iframe.allowFullscreen = true;", + "", + " const canvas = runtimeScene", + " .getGame()", + " .getRenderer()", + " .getCanvas();", + "", + " canvas.parentElement.appendChild(iframe);", + "", + " function updateVideo() {", + " if (!iframe.parentElement) {", + " return;", + " }", + "", + " const canvasRect = canvas.getBoundingClientRect();", + "", + " const gameWidth = canvas.width;", + " const gameHeight = canvas.height;", + "", + " const scaleX = canvasRect.width / gameWidth;", + " const scaleY = canvasRect.height / gameHeight;", + "", + " const x = rendererObject.x;", + " const y = rendererObject.y;", + " const width = rendererObject.width;", + " const height = rendererObject.height;", + "", + " iframe.style.left =", + " (canvasRect.left +", + " (x - width / 2) * scaleX) + \"px\";", + "", + " iframe.style.top =", + " (canvasRect.top +", + " (y - height / 2) * scaleY) + \"px\";", + "", + " iframe.style.width =", + " (width * scaleX) + \"px\";", + "", + " iframe.style.height =", + " (height * scaleY) + \"px\";", + " }", + "", + " updateVideo();", + "", + " if (!runtimeScene.__YouTubeSDKVideos) {", + " runtimeScene.__YouTubeSDKVideos = [];", + " }", + "", + " runtimeScene.__YouTubeSDKVideos.push({", + " iframe: iframe,", + " update: updateVideo", + " });" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "type": "objectList" + }, + { + "description": "Video ID", + "name": "VideoID", + "type": "string" + } + ], + "objectGroups": [] + }, + { + "description": "Gets Comments In Videos Based On Index.", + "fullName": "Get Comment In Video", + "functionType": "Action", + "group": "Comments", + "name": "GetCommentInVid", + "sentence": "Get Comment In Video _PARAM1_,_PARAM2_,_PARAM3_,_PARAM4_,_PARAM5_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const videoId = eventsFunctionContext.getArgument(\"VideoID\");", + "const commentNum = Number(eventsFunctionContext.getArgument(\"CommentNum\"));", + "const sort = eventsFunctionContext.getArgument(\"Sort\");", + "const apiArgument = eventsFunctionContext.getArgument(\"API\");", + "const storeVar = eventsFunctionContext.getArgument(\"StoreVar\");", + "", + "let apiKey = apiArgument;", + "", + "if (apiKey === \"\") {", + " const extensionVariables =", + " runtimeScene.getGame().getVariablesForExtension(\"YouTubeSDK\");", + "", + " if (extensionVariables !== null && extensionVariables.has(\"API\")) {", + " apiKey = extensionVariables.get(\"API\").getAsString();", + " }", + " }", + "", + " if (apiKey === \"\") {", + " console.error(\"[YouTubeSDK] Missing API\");", + " return;", + " }", + "", + " if (videoId === \"\") {", + " console.error(\"[YouTubeSDK] Missing VideoID\");", + " return;", + " }", + "", + " if (!Number.isFinite(commentNum) || commentNum < 0) {", + " console.error(\"[YouTubeSDK] Invalid CommentNum\");", + " return;", + " }", + "", + " let order = \"time\";", + "", + " if (sort === \"Most Popular\") {", + " order = \"relevance\";", + " }", + "", + " const url =", + " \"https://www.googleapis.com/youtube/v3/commentThreads\" +", + " \"?part=snippet\" +", + " \"&videoId=\" + encodeURIComponent(videoId) +", + " \"&maxResults=100\" +", + " \"&order=\" + order +", + " \"&textFormat=plainText\" +", + " \"&key=\" + encodeURIComponent(apiKey);", + "", + " fetch(url)", + " .then(function(response) {", + " return response.json().then(function(data) {", + " if (!response.ok) {", + " if (data.error && data.error.message) {", + " throw new Error(data.error.message);", + " }", + "", + " throw new Error(\"YouTube API request failed\");", + " }", + "", + " return data;", + " });", + " })", + " .then(function(data) {", + " if (!data.items || commentNum >= data.items.length) {", + " console.error(\"[YouTubeSDK] Comment not found\");", + " return;", + " }", + "", + " const comment =", + " data.items[commentNum]", + " .snippet", + " .topLevelComment", + " .snippet", + " .textDisplay;", + "", + " storeVar.setString(comment);", + " })", + " .catch(function(error) {", + " console.error(\"[YouTubeSDK] \" + error.message);", + " });" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Video ID", + "name": "VideoID", + "type": "string" + }, + { + "description": "Comment Number", + "name": "CommentNum", + "type": "expression" + }, + { + "description": "Sort", + "name": "Sort", + "supplementaryInformation": "[\"Most Popular\",\"Newest\"]", + "type": "stringWithSelector" + }, + { + "description": "API", + "longDescription": "Create API: https://console.cloud.google.com/.", + "name": "API", + "type": "string" + }, + { + "description": "Store Variable", + "name": "StoreVar", + "type": "variable" + } + ], + "objectGroups": [] + }, + { + "description": "Get Number Of Likes On a Video.", + "fullName": "Like Count", + "functionType": "Action", + "group": "Video", + "name": "GetLikeCount", + "sentence": "Like Count _PARAM1_,_PARAM2_,_PARAM3_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const videoId = eventsFunctionContext.getArgument(\"VideoID\");", + "const apiArgument = eventsFunctionContext.getArgument(\"API\");", + "const storeVar = eventsFunctionContext.getArgument(\"StoreVar\");", + "", + "let apiKey = apiArgument;", + "", + "if (apiKey === \"\") {", + " const extensionVariables =", + " runtimeScene.getGame().getVariablesForExtension(\"YouTubeSDK\");", + "", + " if (extensionVariables !== null && extensionVariables.has(\"API\")) {", + " apiKey = extensionVariables.get(\"API\").getAsString();", + " }", + " }", + "", + " if (apiKey === \"\") {", + " console.error(\"[YouTubeSDK] Missing API\");", + " return;", + " }", + "", + " if (videoId === \"\") {", + " console.error(\"[YouTubeSDK] Missing VideoID\");", + " return;", + " }", + "", + " const url =", + " \"https://www.googleapis.com/youtube/v3/videos\" +", + " \"?part=statistics\" +", + " \"&id=\" + encodeURIComponent(videoId) +", + " \"&key=\" + encodeURIComponent(apiKey);", + "", + " fetch(url)", + " .then(function(response) {", + " return response.json().then(function(data) {", + " if (!response.ok) {", + " if (data.error && data.error.message) {", + " throw new Error(data.error.message);", + " }", + "", + " throw new Error(\"YouTube API request failed\");", + " }", + "", + " return data;", + " });", + " })", + " .then(function(data) {", + " if (!data.items || data.items.length === 0) {", + " console.error(\"[YouTubeSDK] Video not found\");", + " return;", + " }", + "", + " const statistics = data.items[0].statistics;", + "", + " if (statistics.likeCount === undefined) {", + " storeVar.setString(\"0\");", + " return;", + " }", + "", + " storeVar.setString(statistics.likeCount);", + " })", + " .catch(function(error) {", + " console.error(\"[YouTubeSDK] \" + error.message);", + " });" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Video ID", + "name": "VideoID", + "type": "string" + }, + { + "description": "API", + "longDescription": "Create API: https://console.cloud.google.com/.", + "name": "API", + "type": "string" + }, + { + "description": "Store Variable", + "name": "StoreVar", + "type": "variable" + } + ], + "objectGroups": [] + }, + { + "description": "Get The Title Of The Video.", + "fullName": "Video Title", + "functionType": "Action", + "group": "Video", + "name": "GetVideoTitle", + "sentence": "Video Title _PARAM1_,_PARAM2_,_PARAM3_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const videoId = eventsFunctionContext.getArgument(\"VideoID\");", + "const apiArgument = eventsFunctionContext.getArgument(\"API\");", + "const storeVar = eventsFunctionContext.getArgument(\"StoreVar\");", + "", + "let apiKey = apiArgument;", + "", + "if (apiKey === \"\") {", + " const extensionVariables =", + " runtimeScene.getGame().getVariablesForExtension(\"YouTubeSDK\");", + "", + " if (extensionVariables !== null && extensionVariables.has(\"API\")) {", + " apiKey = extensionVariables.get(\"API\").getAsString();", + " }", + " }", + "", + " if (apiKey === \"\") {", + " console.error(\"[YouTubeSDK] Missing API\");", + " return;", + " }", + "", + " if (videoId === \"\") {", + " console.error(\"[YouTubeSDK] Missing VideoID\");", + " return;", + " }", + "", + " const url =", + " \"https://www.googleapis.com/youtube/v3/videos\" +", + " \"?part=snippet\" +", + " \"&id=\" + encodeURIComponent(videoId) +", + " \"&key=\" + encodeURIComponent(apiKey);", + "", + " fetch(url)", + " .then(function(response) {", + " return response.json().then(function(data) {", + " if (!response.ok) {", + " if (data.error && data.error.message) {", + " throw new Error(data.error.message);", + " }", + "", + " throw new Error(\"YouTube API request failed\");", + " }", + "", + " return data;", + " });", + " })", + " .then(function(data) {", + " if (!data.items || data.items.length === 0) {", + " console.error(\"[YouTubeSDK] Video not found\");", + " return;", + " }", + "", + " const title = data.items[0].snippet.title;", + "", + " storeVar.setString(title);", + " })", + " .catch(function(error) {", + " console.error(\"[YouTubeSDK] \" + error.message);", + " });" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Video ID", + "name": "VideoID", + "type": "string" + }, + { + "description": "API", + "longDescription": "Create API: https://console.cloud.google.com/.", + "name": "API", + "type": "string" + }, + { + "description": "Store Variable", + "name": "StoreVar", + "type": "variable" + } + ], + "objectGroups": [] + }, + { + "description": "Get The Description Of The Video.", + "fullName": "Video Description", + "functionType": "Action", + "group": "Video", + "name": "GetVideoDescription", + "sentence": "Video Description _PARAM1_,_PARAM2_,_PARAM3_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const videoId = eventsFunctionContext.getArgument(\"VideoID\");", + "const apiArgument = eventsFunctionContext.getArgument(\"API\");", + "const storeVar = eventsFunctionContext.getArgument(\"StoreVar\");", + "", + "let apiKey = apiArgument;", + "", + "if (apiKey === \"\") {", + " const extensionVariables =", + " runtimeScene.getGame().getVariablesForExtension(\"YouTubeSDK\");", + "", + " if (extensionVariables !== null && extensionVariables.has(\"API\")) {", + " apiKey = extensionVariables.get(\"API\").getAsString();", + " }", + " }", + "", + " if (apiKey === \"\") {", + " console.error(\"[YouTubeSDK] Missing API\");", + " return;", + " }", + "", + " if (videoId === \"\") {", + " console.error(\"[YouTubeSDK] Missing VideoID\");", + " return;", + " }", + "", + " const url =", + " \"https://www.googleapis.com/youtube/v3/videos\" +", + " \"?part=snippet\" +", + " \"&id=\" + encodeURIComponent(videoId) +", + " \"&key=\" + encodeURIComponent(apiKey);", + "", + " fetch(url)", + " .then(function(response) {", + " return response.json().then(function(data) {", + " if (!response.ok) {", + " if (data.error && data.error.message) {", + " throw new Error(data.error.message);", + " }", + "", + " throw new Error(\"YouTube API request failed\");", + " }", + "", + " return data;", + " });", + " })", + " .then(function(data) {", + " if (!data.items || data.items.length === 0) {", + " console.error(\"[YouTubeSDK] Video not found\");", + " return;", + " }", + "", + " const description = data.items[0].snippet.description;", + "", + " storeVar.setString(description);", + " })", + " .catch(function(error) {", + " console.error(\"[YouTubeSDK] \" + error.message);", + " });" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Video ID", + "name": "VideoID", + "type": "string" + }, + { + "description": "API", + "longDescription": "Create API: https://console.cloud.google.com/.", + "name": "API", + "type": "string" + }, + { + "description": "Store Variable", + "name": "StoreVar", + "type": "variable" + } + ], + "objectGroups": [] + }, + { + "description": "Get The Publisher Of The Video, Returns Channel.", + "fullName": "Video Publisher", + "functionType": "Action", + "group": "Video", + "name": "GetVideoPublisher", + "sentence": "Video Publisher _PARAM1_,_PARAM2_,_PARAM3_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const videoId = eventsFunctionContext.getArgument(\"VideoID\");", + "const apiArgument = eventsFunctionContext.getArgument(\"API\");", + "const storeVar = eventsFunctionContext.getArgument(\"StoreVar\");", + "", + "let apiKey = apiArgument;", + "", + "if (apiKey === \"\") {", + " const extensionVariables =", + " runtimeScene.getGame().getVariablesForExtension(\"YouTubeSDK\");", + "", + " if (extensionVariables !== null && extensionVariables.has(\"API\")) {", + " apiKey = extensionVariables.get(\"API\").getAsString();", + " }", + " }", + "", + " if (apiKey === \"\") {", + " console.error(\"[YouTubeSDK] Missing API\");", + " return;", + " }", + "", + " if (videoId === \"\") {", + " console.error(\"[YouTubeSDK] Missing VideoID\");", + " return;", + " }", + "", + " const url =", + " \"https://www.googleapis.com/youtube/v3/videos\" +", + " \"?part=snippet\" +", + " \"&id=\" + encodeURIComponent(videoId) +", + " \"&key=\" + encodeURIComponent(apiKey);", + "", + " fetch(url)", + " .then(function(response) {", + " return response.json().then(function(data) {", + " if (!response.ok) {", + " if (data.error && data.error.message) {", + " throw new Error(data.error.message);", + " }", + "", + " throw new Error(\"YouTube API request failed\");", + " }", + "", + " return data;", + " });", + " })", + " .then(function(data) {", + " if (!data.items || data.items.length === 0) {", + " console.error(\"[YouTubeSDK] Video not found\");", + " return;", + " }", + "", + " const channelId = data.items[0].snippet.channelId;", + "", + " const channelURL =", + " \"https://www.googleapis.com/youtube/v3/channels\" +", + " \"?part=snippet\" +", + " \"&id=\" + encodeURIComponent(channelId) +", + " \"&key=\" + encodeURIComponent(apiKey);", + "", + " return fetch(channelURL)", + " .then(function(response) {", + " return response.json().then(function(channelData) {", + " if (!response.ok) {", + " throw new Error(\"YouTube API request failed\");", + " }", + "", + " return channelData;", + " });", + " });", + " })", + " .then(function(data) {", + " if (!data || !data.items || data.items.length === 0) {", + " return;", + " }", + "", + " const snippet = data.items[0].snippet;", + "", + " let username = snippet.customUrl || \"\";", + "", + " if (username !== \"\" && username.charAt(0) !== \"@\") {", + " username = \"@\" + username;", + " }", + "", + " storeVar.setString(username);", + " })", + " .catch(function(error) {", + " console.error(\"[YouTubeSDK] \" + error.message);", + " });" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Video ID", + "name": "VideoID", + "type": "string" + }, + { + "description": "API", + "longDescription": "Create API: https://console.cloud.google.com/.", + "name": "API", + "type": "string" + }, + { + "description": "Store Variable", + "name": "StoreVar", + "type": "variable" + } + ], + "objectGroups": [] + }, + { + "description": "Get The Number Of Comments In a Video.", + "fullName": "Video Comment Count", + "functionType": "Action", + "group": "Comments", + "name": "VideoCommentCount", + "sentence": "Video Comment Count _PARAM1_,_PARAM2_,_PARAM3_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const videoId = eventsFunctionContext.getArgument(\"VideoID\");", + "const apiArgument = eventsFunctionContext.getArgument(\"API\");", + "const storeVar = eventsFunctionContext.getArgument(\"StoreVar\");", + "", + "let apiKey = apiArgument;", + "", + "if (apiKey === \"\") {", + " const extensionVariables =", + " runtimeScene.getGame().getVariablesForExtension(\"YouTubeSDK\");", + "", + " if (extensionVariables !== null && extensionVariables.has(\"API\")) {", + " apiKey = extensionVariables.get(\"API\").getAsString();", + " }", + " }", + "", + " if (apiKey === \"\") {", + " console.error(\"[YouTubeSDK] Missing API\");", + " return;", + " }", + "", + " if (videoId === \"\") {", + " console.error(\"[YouTubeSDK] Missing VideoID\");", + " return;", + " }", + "", + " const url =", + " \"https://www.googleapis.com/youtube/v3/videos\" +", + " \"?part=statistics\" +", + " \"&id=\" + encodeURIComponent(videoId) +", + " \"&key=\" + encodeURIComponent(apiKey);", + "", + " fetch(url)", + " .then(function(response) {", + " return response.json().then(function(data) {", + " if (!response.ok) {", + " if (data.error && data.error.message) {", + " throw new Error(data.error.message);", + " }", + "", + " throw new Error(\"YouTube API request failed\");", + " }", + "", + " return data;", + " });", + " })", + " .then(function(data) {", + " if (!data.items || data.items.length === 0) {", + " console.error(\"[YouTubeSDK] Video not found\");", + " return;", + " }", + "", + " const statistics = data.items[0].statistics;", + "", + " if (statistics.commentCount === undefined) {", + " storeVar.setString(\"0\");", + " return;", + " }", + "", + " storeVar.setString(statistics.commentCount);", + " })", + " .catch(function(error) {", + " console.error(\"[YouTubeSDK] \" + error.message);", + " });" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Video ID", + "name": "VideoID", + "type": "string" + }, + { + "description": "API", + "longDescription": "Create API: https://console.cloud.google.com/.", + "name": "API", + "type": "string" + }, + { + "description": "Store Variable", + "name": "StoreVar", + "type": "variable" + } + ], + "objectGroups": [] + }, + { + "description": "Save The Thumbnail Of The Video As Base64.", + "fullName": "Save Thumbnail As Base64", + "functionType": "Action", + "group": "Video", + "name": "SaveThumbnail", + "sentence": "Save Thumbnail As Base64 _PARAM1_,_PARAM2_,_PARAM3_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const videoId = eventsFunctionContext.getArgument(\"VideoID\");", + "const apiArgument = eventsFunctionContext.getArgument(\"API\");", + "const storeVar = eventsFunctionContext.getArgument(\"StoreVar\");", + "", + "let apiKey = apiArgument;", + "", + "if (apiKey === \"\") {", + " const extensionVariables =", + " runtimeScene.getGame().getVariablesForExtension(\"YouTubeSDK\");", + "", + " if (extensionVariables !== null && extensionVariables.has(\"API\")) {", + " apiKey = extensionVariables.get(\"API\").getAsString();", + " }", + " }", + "", + " if (apiKey === \"\") {", + " console.error(\"[YouTubeSDK] Missing API\");", + " return;", + " }", + "", + " if (videoId === \"\") {", + " console.error(\"[YouTubeSDK] Missing VideoID\");", + " return;", + " }", + "", + " const url =", + " \"https://www.googleapis.com/youtube/v3/videos\" +", + " \"?part=snippet\" +", + " \"&id=\" + encodeURIComponent(videoId) +", + " \"&key=\" + encodeURIComponent(apiKey);", + "", + " fetch(url)", + " .then(function(response) {", + " return response.json().then(function(data) {", + " if (!response.ok) {", + " if (data.error && data.error.message) {", + " throw new Error(data.error.message);", + " }", + "", + " throw new Error(\"YouTube API request failed\");", + " }", + "", + " return data;", + " });", + " })", + " .then(function(data) {", + " if (!data.items || data.items.length === 0) {", + " console.error(\"[YouTubeSDK] Video not found\");", + " return;", + " }", + "", + " const thumbnails = data.items[0].snippet.thumbnails;", + "", + " const thumbnail =", + " thumbnails.maxres ||", + " thumbnails.standard ||", + " thumbnails.high ||", + " thumbnails.medium ||", + " thumbnails.default;", + "", + " if (!thumbnail || !thumbnail.url) {", + " console.error(\"[YouTubeSDK] Thumbnail not found\");", + " return;", + " }", + "", + " return fetch(thumbnail.url);", + " })", + " .then(function(response) {", + " if (!response) {", + " return;", + " }", + "", + " return response.blob();", + " })", + " .then(function(blob) {", + " if (!blob) {", + " return;", + " }", + "", + " const reader = new FileReader();", + "", + " reader.onloadend = function() {", + " storeVar.setString(reader.result);", + " };", + "", + " reader.readAsDataURL(blob);", + " })", + " .catch(function(error) {", + " console.error(\"[YouTubeSDK] \" + error.message);", + " });" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Video ID", + "name": "VideoID", + "type": "string" + }, + { + "description": "API", + "longDescription": "Create API: https://console.cloud.google.com/.", + "name": "API", + "type": "string" + }, + { + "description": "Store Variable", + "name": "StoreVar", + "type": "variable" + } + ], + "objectGroups": [] + }, + { + "description": "Get The Video URL.", + "fullName": "Get Video URL", + "functionType": "Action", + "group": "Video", + "name": "GetVideoURL", + "sentence": "Get Video URL _PARAM1_,_PARAM2_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const videoId = eventsFunctionContext.getArgument(\"VideoID\");", + "const storeVar = eventsFunctionContext.getArgument(\"StoreVar\");", + "", + "if (!videoId) {", + " return;", + " }", + "", + " storeVar.setString(", + " \"https://www.youtube.com/watch?v=\" + encodeURIComponent(videoId)", + " );" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Video ID", + "name": "VideoID", + "type": "string" + }, + { + "description": "Store Variable", + "name": "StoreVar", + "type": "variable" + } + ], + "objectGroups": [] + }, + { + "description": "Get The Video ID Using The Video URL.", + "fullName": "Get Video ID By URL", + "functionType": "Action", + "group": "Video", + "name": "GetVideoID_URL", + "sentence": "Get Video ID By URL _PARAM1_,_PARAM2_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const inputURL = eventsFunctionContext.getArgument(\"URL\");", + "const storeVar = eventsFunctionContext.getArgument(\"StoreVar\");", + "", + "if (!inputURL) {", + " return;", + " }", + "", + " let videoId = \"\";", + "", + " try {", + " const url = new URL(inputURL);", + "", + " if (url.hostname === \"youtu.be\") {", + " videoId = url.pathname.substring(1).split(\"/\")[0];", + " } else if (", + " url.hostname === \"youtube.com\" ||", + " url.hostname === \"www.youtube.com\" ||", + " url.hostname === \"m.youtube.com\"", + " ) {", + " videoId = url.searchParams.get(\"v\") || \"\";", + "", + " if (videoId === \"\" && url.pathname.startsWith(\"/embed/\")) {", + " videoId = url.pathname.substring(7).split(\"/\")[0];", + " }", + "", + " if (videoId === \"\" && url.pathname.startsWith(\"/shorts/\")) {", + " videoId = url.pathname.substring(8).split(\"/\")[0];", + " }", + " }", + " } catch (error) {", + " return;", + " }", + "", + " if (videoId === \"\") {", + " return;", + " }", + "", + " storeVar.setString(videoId);" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Video URL", + "name": "URL", + "type": "string" + }, + { + "description": "Store Variable", + "name": "StoreVar", + "type": "variable" + } + ], + "objectGroups": [] + }, + { + "description": "Get The Duration Of The Video.", + "fullName": "Video Duration", + "functionType": "Action", + "group": "Video", + "name": "GetVideoPublisher2", + "sentence": "Video Duration _PARAM1_,_PARAM2_,_PARAM3_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const videoId = eventsFunctionContext.getArgument(\"VideoID\");", + "const apiArgument = eventsFunctionContext.getArgument(\"API\");", + "const storeVar = eventsFunctionContext.getArgument(\"StoreVar\");", + "", + "let apiKey = apiArgument;", + "", + "if (apiKey === \"\") {", + " const extensionVariables =", + " runtimeScene.getGame().getVariablesForExtension(\"YouTubeSDK\");", + "", + " if (extensionVariables !== null && extensionVariables.has(\"API\")) {", + " apiKey = extensionVariables.get(\"API\").getAsString();", + " }", + " }", + "", + " if (apiKey === \"\" || videoId === \"\") {", + " return;", + " }", + "", + " const url =", + " \"https://www.googleapis.com/youtube/v3/videos\" +", + " \"?part=contentDetails\" +", + " \"&id=\" + encodeURIComponent(videoId) +", + " \"&key=\" + encodeURIComponent(apiKey);", + "", + " fetch(url)", + " .then(function(response) {", + " return response.json().then(function(data) {", + " if (!response.ok) {", + " throw new Error(", + " data.error && data.error.message", + " ? data.error.message", + " : \"YouTube API request failed\"", + " );", + " }", + "", + " return data;", + " });", + " })", + " .then(function(data) {", + " if (!data.items || data.items.length === 0) {", + " return;", + " }", + "", + " const duration = data.items[0].contentDetails.duration;", + "", + " const match = duration.match(", + " /^PT(?:(\\d+)H)?(?:(\\d+)M)?(?:(\\d+)S)?$/", + " );", + "", + " if (!match) {", + " return;", + " }", + "", + " const hours = Number(match[1] || 0);", + " const minutes = Number(match[2] || 0);", + " const seconds = Number(match[3] || 0);", + "", + " let result;", + "", + " if (hours > 0) {", + " result =", + " hours +", + " \":\" +", + " String(minutes).padStart(2, \"0\") +", + " \":\" +", + " String(seconds).padStart(2, \"0\");", + " } else {", + " result =", + " minutes +", + " \":\" +", + " String(seconds).padStart(2, \"0\");", + " }", + "", + " storeVar.setString(result);", + " })", + " .catch(function(error) {", + " console.error(\"[YouTubeSDK] \" + error.message);", + " });" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "description": "Video ID", + "name": "VideoID", + "type": "string" + }, + { + "description": "API", + "longDescription": "Create API: https://console.cloud.google.com/.", + "name": "API", + "type": "string" + }, + { + "description": "Store Variable", + "name": "StoreVar", + "type": "variable" + } + ], + "objectGroups": [] + } + ], + "eventsFunctionsFolderStructure": { + "folderName": "__ROOT", + "children": [ + { + "folderName": "Comments", + "children": [ + { + "functionName": "GetCommentInVid" + }, + { + "functionName": "VideoCommentCount" + } + ] + }, + { + "folderName": "Search", + "children": [ + { + "functionName": "SearchUsers" + }, + { + "functionName": "SearchVideos" + } + ] + }, + { + "folderName": "Account", + "children": [ + { + "functionName": "SubCount" + }, + { + "functionName": "AccountName" + }, + { + "functionName": "VideosCount" + }, + { + "functionName": "AccountBio" + }, + { + "functionName": "AccountJoinDate" + }, + { + "functionName": "AccountViewCount" + }, + { + "functionName": "AccountLocation" + }, + { + "functionName": "SaveProfileIcon" + } + ] + }, + { + "folderName": "Video", + "children": [ + { + "functionName": "LoadURL" + }, + { + "functionName": "LoadUsingVIDID" + }, + { + "functionName": "GetLikeCount" + }, + { + "functionName": "GetVideoTitle" + }, + { + "functionName": "GetVideoDescription" + }, + { + "functionName": "GetVideoPublisher" + }, + { + "functionName": "GetVideoPublisher2" + }, + { + "functionName": "SaveThumbnail" + }, + { + "functionName": "GetVideoURL" + }, + { + "functionName": "GetVideoID_URL" + } + ] + }, + { + "functionName": "LoadBase64OBj" + } + ] + }, + "eventsBasedBehaviors": [], + "eventsBasedObjects": [] +}