Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Commit f926ed0

Browse files
committed
Added Groups parsing
1 parent 2df918e commit f926ed0

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

apiList.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"userId": "User ID",
33
"id": "Channel ID",
44
"token": "Username",
5+
"groups": "Groups",
56
"suspended": "Suspended",
67
"vodsEnabled": "VODs Enabled",
78
"createdAt": "Created at",

apiRunner.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//Version
2-
var scriptVersion = 'v0.2';
2+
var scriptVersion = 'v0.2.2';
33
document.getElementById('app-version').innerHTML = scriptVersion;
44
//API url
55
var apiUrl = 'https://mixer.com/api/v1/channels/';
@@ -22,9 +22,12 @@ function Get(url) {
2222
var statusCode = JSON.parse(response)['statusCode']
2323
console.log('Status Code ' + statusCode)
2424
if (statusCode == 404) {
25-
alert("User not found, API returned 404");
25+
var badResponse = '{"statusCode":404}';
26+
console.log(badResponse)
27+
return badResponse;
2628
}
2729
else {
30+
console.log(typeof(response))
2831
return response.toString();
2932
}
3033
}
@@ -34,6 +37,8 @@ function parseLightstream(channelId) {
3437
console.log('Parsing Lighstream')
3538
videoUrl = apiUrl + channelId.toString() + '/videoSettings';
3639
var rawData = JSON.parse(Get(videoUrl));
40+
if (rawData['statusCode'] === 404){rawData['isLSEnabled'] = 'not a Pro';}
41+
console.log(rawData)
3742
var lightstream = rawData['isLSEnabled'];
3843
console.log(lightstream, rawData);
3944
return lightstream;
@@ -53,6 +58,16 @@ function parseApi(keys, rawData) {
5358
if (apiName == 'createdAt') {
5459
status = status.substr(0,10);
5560
}
61+
//Gettings groups
62+
if (apiName == 'groups') {
63+
var allGroups = new Array()
64+
groupData = rawData.user['groups'];
65+
for (group in groupData) {
66+
allGroups.push(groupData[parseInt(group)].name)
67+
}
68+
console.log(allGroups.toString())
69+
status = allGroups.toString()
70+
}
5671
//Gettings Sparks
5772
if (apiName == 'sparks') {
5873
status = rawData.user.sparks;
@@ -91,6 +106,7 @@ function apiRunner() {
91106
resetHtml('generated');
92107
var url = buildUrl(input);
93108
var rawData = JSON.parse(Get(url));
109+
if (rawData["statusCode"] === 404) {alert("User not found, API returned 404");}
94110
var keys = 'apiList'
95111
parseApi(keys, rawData);
96112
}

0 commit comments

Comments
 (0)