Problem to find closed Twitch accounts

Problem to find closed Twitch accounts
0.0 0

#1

Well, my Challenge is almost over, everything is done, but I can’t yet find out when an account is closed and when is only offline. I’d appreciate any help to know when a channel is closed and when is offline.

This is the how the request I’m making looks, to a channel named touchdown_bundy, a channel I know is always offline, but is not closed.

$.ajax({
type: ‘GET’,
url: “https://api.twitch.tv/kraken/streams?client_id=mykey&channel=touchdown_bundy”,
dataType: “jsonp”,
jsonpCallback: “twitchcallback”
});

The info I’m getting looks like this:

{“streams”:[],"_total":0,"_links":{“self”:“https://api.twitch.tv/kraken/streams?channel=touchdown_bundy\u0026limit=25\u0026offset=0",“next”:“https://api.twitch.tv/kraken/streams?channel=touchdown_bundy\u0026limit=25\u0026offset=25”,“featured”:“https://api.twitch.tv/kraken/streams/featured”,“summary”:“https://api.twitch.tv/kraken/streams/summary”,“followed”:"https://api.twitch.tv/kraken/streams/followed”}}

Now, when I request the info concerning a channel that does not exist, for example touchdown_bundy123, I get the exact same information, so I can make no distinction between offline and closed:

{“streams”:[],"_total":0,"_links":{“self”:“https://api.twitch.tv/kraken/streams?channel=touchdown_bundy123\u0026limit=25\u0026offset=0",“next”:“https://api.twitch.tv/kraken/streams?channel=touchdown_bundy123\u0026limit=25\u0026offset=25”,“featured”:“https://api.twitch.tv/kraken/streams/featured”,“summary”:“https://api.twitch.tv/kraken/streams/summary”,“followed”:"https://api.twitch.tv/kraken/streams/followed”}}

You can take a look at my almost finished project right here: http://codepen.io/ralgtrx/full/RGGAVV


#2

I actually had this very same problem. Since they updated twitch’s api stuff the json info for closed accounts seems to be flat out gone. How I fixed mine was to set it so that if the jsonp(in my case) couldn’t find it(so had a problem with the call) then I had the error function create the closed account with the name of the user gotten from the array. Hope that helps I’m definitely just creeping into intermediate skill myself with JS.


#3

I actually did something like that, I set it so that if the streamer is not into the jsonp I’m getting, it would take the status as offline, but still can’t separate offline from closed. I’m taking all missing streamers as offline right now.


#4

One thing I do know is that part of the json data has a property called “stream”. If a user is offline that stream will be “null”. For mine I had an if statement where if data2.stream === null, then it would create the offline content.


#5

Yeah, the documentation says it should return null for offline, but it’s actually returning an empty array for all cases.
This is what I’m getting for offline streamers:

{“streams”:[],“total”:0,“links”…

I get this for closed channels:

{“streams”:[],“total”:0,“links”…

And This for channels that doesn’t exist:

{“streams”:[],“total”:0,“links”…


#6

Did you ever figure out what to do with separating the closed from the offline accounts? I’m having the same problem.