mIRC Home    About    Download    Register    News    Help

Print Thread
#259862 06/02/17 04:43 PM
Joined: Dec 2016
Posts: 16
H
Hazman Offline OP
Pikka bird
OP Offline
Pikka bird
H
Joined: Dec 2016
Posts: 16
Hello, Can anyone give me a script that can fetch the current stream title? I cannot find one anywhere.

Joined: Oct 2015
Posts: 112
B
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2015
Posts: 112
Are you asking for a !command that will display the stream title of the current live stream? I recommend using SReject's JSON-For-mIRC for things like this. It makes writing commands like this super easy. Once you have that script loaded, the following code should return the stream title in chat when you type !title.

Code:
ON $*:TEXT:/^!title$/iS:#: {
  JSONOpen -uw streamtitle https://api.twitch.tv/kraken/channels/ $+ $remove($chan,$chr(35))
  JSONHttpHeader streamtitle Client-ID avm4vi7zv0xpjkpi3d4x0qzk8xbrdw8
  JSONHttpFetch streamtitle
  MSG $chan $IIF($json(streamtitle, status).value,$v1,ERROR)
  JSONClose streamtitle
}

Blas #259872 07/02/17 06:24 AM
Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
Same functionality as above but a bit easier to follow:

Code:
;; on text event that matches channel messages of: !title
on *:TEXT:!title:#: {

  ;; create a JSON handle
  ;; that will retrieve data from a url(-u)
  ;; but wait(-w) for /JSONHttpFetch to be called before making the request
  ;; once this script finishes, destroy the handle(-d)
  JSONOpen -uwd streamtitle https://api.twitch.tv/kraken/channels/ $+ $remove($chan,$chr(35))

  ;; Set the Client-ID request header
  JSONHttpHeader streamtitle Client-ID avm4vi7zv0xpjkpi3d4x0qzk8xbrdw8

  ;; make the request to twitch
  JSONHttpFetch streamtitle

  ;; check for errors and that the response from twitch's servers
  ;; contains a value for 'status'
  if (!$JSONError && $JSON(streamtitle, status).value !== $null) {

    ;; msg the channel with that value
    msg $chan [Title] $v1
  }


  ;; an error occurred
  else {
    msg $chan [Title] An error occured
  }
}


I am SReject
My Stuff
Blas #259874 07/02/17 12:41 PM
Joined: Dec 2016
Posts: 16
H
Hazman Offline OP
Pikka bird
OP Offline
Pikka bird
H
Joined: Dec 2016
Posts: 16
Thanks smile


Link Copied to Clipboard