11//Version
2- var scriptVersion = 'v0.2' ;
2+ var scriptVersion = 'v0.2.2 ' ;
33document . getElementById ( 'app-version' ) . innerHTML = scriptVersion ;
44//API url
55var 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