-
Notifications
You must be signed in to change notification settings - Fork 0
/
StreamingIntegration.json
231 lines (231 loc) · 8.06 KB
/
StreamingIntegration.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
{
"author": "",
"category": "Third-party",
"extensionNamespace": "",
"fullName": "Streaming Integration",
"helpPath": "",
"iconUrl": "",
"name": "StreamingIntegration",
"previewIconUrl": "",
"shortDescription": "An extention to expose Twitch and Youtube APIs datas in GDevelop",
"version": "0.0.1",
"description": [
"**FIRST USABLE BUILD**",
"",
"An extention to expose Twitch and Youtube APIs datas in GDevelop. ",
"",
"**STILL IN DEVELOPEMENT**",
"",
"24/12/23 :",
"Currently you can only recieve Twitch and/or Youtube followers count and show it into a Text Object."
],
"tags": [
"stream",
"twitch",
"youtube",
"followers"
],
"authorIds": [
"pfed0sUBHwTXQMZXkzrJFuOqPkJ2"
],
"dependencies": [],
"eventsFunctions": [
{
"description": "Add Twitch Credentials",
"fullName": "Set Twitch Credentials",
"functionType": "Action",
"group": "Init",
"name": "setTwitchCredentials",
"sentence": "Twitch Credentials Client ID : _PARAM1_ , AccessToken : _PARAM2_ , Channel ID : _PARAM3_",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
"inlineCode": [
"globalThis.twitchClientID = new gdjs.Variable();",
"globalThis.twitchClientID.setString(eventsFunctionContext.getArgument(\"clientID\"));",
"",
"globalThis.twitchAccessToken = new gdjs.Variable();",
"globalThis.twitchAccessToken.setString(eventsFunctionContext.getArgument(\"accessToken\"));",
"",
"globalThis.twitchChannelID = new gdjs.Variable();",
"globalThis.twitchChannelID.setString(eventsFunctionContext.getArgument(\"channelID\"));",
"",
""
],
"parameterObjects": "",
"useStrict": true,
"eventsSheetExpanded": false
}
],
"parameters": [
{
"description": "Client ID",
"name": "clientID",
"type": "string"
},
{
"description": "Access Token",
"name": "accessToken",
"type": "string"
},
{
"description": "Channel ID",
"name": "channelID",
"type": "string"
}
],
"objectGroups": []
},
{
"description": "Add Youtube Credentials",
"fullName": "Set Youtube Credentials",
"functionType": "Action",
"group": "Init",
"name": "setYoutubeCredentials",
"sentence": "Youtube Credentials Channel ID : _PARAM1_ , ApiKey: _PARAM2_",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
"inlineCode": [
"globalThis.youtubeApiKey = new gdjs.Variable();",
"globalThis.youtubeApiKey.setString(eventsFunctionContext.getArgument(\"apiKey\"));",
"",
"globalThis.youtubeChannelID = new gdjs.Variable();",
"globalThis.youtubeChannelID.setString(eventsFunctionContext.getArgument(\"channelID\"));",
"",
""
],
"parameterObjects": "",
"useStrict": true,
"eventsSheetExpanded": false
}
],
"parameters": [
{
"description": "Client ID",
"name": "channelID",
"type": "string"
},
{
"description": "Access Token",
"name": "apiKey",
"type": "string"
}
],
"objectGroups": []
}
],
"eventsBasedBehaviors": [
{
"description": "The the total number of followers of a specific channel.",
"fullName": "GetTotalFollowers",
"name": "GetTotalFollowers",
"objectType": "TextObject::Text",
"eventsFunctions": [
{
"fullName": "",
"functionType": "Action",
"name": "GetTotalTwitchFollowers",
"sentence": "Show total Twitch Followers in _PARAM0_",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
"inlineCode": [
" const display = eventsFunctionContext.getObjects(\"Object\")[0];",
" // Construct the API endpoint URL",
" const twitchApiUrl = `https://api.twitch.tv/helix/channels/followers?broadcaster_id=${twitchChannelID.getValue()}`;",
" // Make the API request with the Twitch API key in the headers",
" fetch(twitchApiUrl, {",
" headers: {",
" 'Client-ID': `${twitchClientID.getValue()}`,",
" 'Authorization': `Bearer ${twitchAccessToken.getValue()}`",
" }",
" })",
" .then(response => response.json())",
" .then(data => {",
" // Extract and display the number of followers",
" const followerCount = data.total;",
" console.log('Number of Followers:', followerCount);",
" display.setText(followerCount);",
" })",
" .catch(error => {",
" console.error('Error fetching Twitch followers:', error);",
" });"
],
"parameterObjects": "",
"useStrict": true,
"eventsSheetExpanded": true
}
],
"parameters": [
{
"description": "Object",
"name": "Object",
"supplementaryInformation": "TextObject::Text",
"type": "object"
},
{
"description": "Behavior",
"name": "Behavior",
"supplementaryInformation": "StreamingIntegration::GetTotalFollowers",
"type": "behavior"
}
],
"objectGroups": []
},
{
"fullName": "",
"functionType": "Action",
"name": "GetTotalYoutubeFollowers",
"sentence": "Show total Youtube Followers _PARAM0_",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
"inlineCode": [
"const display = eventsFunctionContext.getObjects(\"Object\")[0];",
"",
"// API endpoint for the YouTube Data API",
" const youtubeApiUrl = `https://www.googleapis.com/youtube/v3/channels?part=statistics&id=${youtubeChannelID.getValue()}&key=${youtubeApiKey.getValue()}`;",
"",
" fetch(youtubeApiUrl)",
" .then(response => response.json())",
" .then(data => {",
" // Extract and display the number of followers",
" const followerCount = data.items[0].statistics.subscriberCount;",
" console.log('Number of Followers:', followerCount);",
" display.setText(followerCount);",
" //display.toString(followerCount);",
" ",
" })",
" .catch(error => {",
" console.error('Error fetching Youtube followers:', error);",
" });"
],
"parameterObjects": "",
"useStrict": true,
"eventsSheetExpanded": true
}
],
"parameters": [
{
"description": "Object",
"name": "Object",
"supplementaryInformation": "TextObject::Text",
"type": "object"
},
{
"description": "Behavior",
"name": "Behavior",
"supplementaryInformation": "StreamingIntegration::GetTotalFollowers",
"type": "behavior"
}
],
"objectGroups": []
}
],
"propertyDescriptors": [],
"sharedPropertyDescriptors": []
}
],
"eventsBasedObjects": []
}