mIRC Homepage
Posted By: tayfurtarkan Twitch uptime records for VOD's - 20/09/16 07:07 PM
Hello,
I need a script that saves the stream time when a moderator types !highlight in chat. So i can easily edit the videos. I've tried this so far:

Originally Posted By: paper0rplastic
Using Froggie's JSON parser :

Code:
on *:text:!highlight:#: {
  highlight #
}

alias -l highlight {
  var %chan $1
  var %caster $mid(%chan,2)
  var %v highlight $+ $ticks
  JSONOpen -ud %v https://api.twitch.tv/kraken/streams/ $+ %caster
  var %id $json(%v,stream,_id)
  if (!%id) { msg %chan %caster is currently OFFLINE. | return }
  var %created $json(%v,stream,created_at)
  var %start $ctime($remove($replace(%created,T,$chr(32)),Z))
  var %uptime $duration($calc($gmt - %start))
  describe %chan + Highlight marker added at %uptime
  writeini highlights.ini %caster $ctime %uptime $+($chr(91),$asctime(m/d/yy),$chr(93))
}

on *:text:!display highlights:#: {
  var %caster $mid(#,2), %i 1 | while $ini(highlights.ini,%caster,%i) {
    var %m $v1 | var %r %r $readini highlights.ini %caster %m $chr(187) | inc %i
  }
  msg # $iif(%r,Highlight Markers: $left($v1,-2),There are no highlight markers.)
}


But for some reason its not working frown
Thanks for the help!
Posted By: Blas Re: Twitch uptime records for VOD's - 20/09/16 10:53 PM
I wrote a script that does exactly this on my GitHub. Just replace %streamer with your Twitch channel. SReject provided the "TwitchTime" alias. It would be pretty simple to write a !display command to read the highlights.txt file.
Posted By: Fonic_Artes Re: Twitch uptime records for VOD's - 21/09/16 01:03 AM
Twitch had an API change requiring you to have Client-ID in the headers.

Code:
JSONOpen -ud %v https://api.twitch.tv/kraken/streams/ $+ %caster

needs to become
Code:
JSONOpen -uwd %v https://api.twitch.tv/kraken/streams/ $+ %caster
JSONUrlMethod %v GET
JSONUrlHeader %v Client-ID: [YOUR CLIENT ID]
JSONUrlGet %v


You can get your Client-ID for your application on the connections page on Twitch.

https://twitch.tv/settings/connections

In the Developer Applications your program should be there, if not, just sign it up. I also believe that SReject does have this in his mTwitch applications.
Posted By: tayfurtarkan Re: Twitch uptime records for VOD's - 21/09/16 02:07 PM
Thanks for the answers. I have problem with that "Client-ID" thingy. I was using mirc on local. How do i supposed to connect with twitch?
Posted By: Fonic_Artes Re: Twitch uptime records for VOD's - 21/09/16 02:24 PM
When you register your application just use http://localhost as your redirect URI, I can assure that it works as I'm doing that for my stuff.
Posted By: tayfurtarkan Re: Twitch uptime records for VOD's - 21/09/16 05:44 PM
I guess i get the id but script is still not working for me frown

http://pastebin.com/V57SWP9V

It says stream is offline when stream is online.
© mIRC Discussion Forums