SReject / mTwitch

Twitch normalizer for mIRC
21 stars 8 forks source link

Twitch API v5 timestamps and displayname #18

Closed wallrik closed 7 years ago

wallrik commented 7 years ago

Yes, v3 will continue to work until 2018 but they still recommend people to migrate whenever possible.

Specifically these changes I've noticed so far affect mTwitch.

  • The new version of the API uses user IDs instead of user names to reference users.
  • Sub-second precision was added to time fields

alias mTwitch.ConvertTime This is going to have to accept the new timestamps.

mTwitch.DisplayName.mrc This request is no longer going to work because it will expect a user ID: https://api.twitch.tv/kraken/users/ $+ $mTwitch.UrlEncode($me)

API documentation: Translating from User Names to User IDs Actually, it also returns _displayname (as shown in the example) so we're not gonna need to make another request 👍 Live sample data

So I guess it would look something like this:

JSONOpen -uw mTwitch_NameFix https://api.twitch.tv/kraken/users?login= $+ $mTwitch.UrlEncode($me)
JSONHttpHeader mTwitch_NameFix Client-ID gjiaolylvp6t7gukddfzee9ehets66w
JSONHttpHeader mTwitch_NameFix Accept application/vnd.twitchtv.v5

I would submit a pull request if I knew how to handle the output.

(I'm sure mTwitch.StateToTopic.mrc is going to need a lot of work, but I'm not using that myself)

Thanks for the excellent work with this script!

SReject commented 7 years ago

I don't think mTwitch.StateToTopic.mrc will need to be addressed unless the format of the response changes.

wallrik commented 7 years ago

https://api.twitch.tv/kraken/streams?limit=100&channel= This call will expect channel ID in v5, not channel names. https://dev.twitch.tv/docs/v5/reference/streams/#get-live-streams

So I think we're going to need to do 2 calls. First finding all the ID's then checking streams. https://api.twitch.tv/kraken/users?login=channel1,channel2,channel3 https://api.twitch.tv/kraken/streams?limit=100&channel=channelId1,channelId2,channelId3

Awkward way of doing it in my opinion, but I guess that's how they want it from now on?

I was imagining a scenario where you just check channel ID when you join a channel and save it, but that would spam a lot when you connect and auto-join all channels. So maybe not. Unless they were persistent across client restarts.