Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --=========--
- --Changelog--
- --=========--
- --Version 1.1.0
- --1. Fixed live() crash bug!
- --2. Made file smaller, to save on disk space using init()!
- --=========--
- --Changelog--
- --=========--
- function init(streamid)
- isjsoninstalled()
- os.loadAPI("json")
- str = http.get("https://api.twitch.tv/kraken/channels/"..streamid.."/follows?limit=1").readAll()
- obj = json.decode(str)
- follower = obj.follows[1].user.name
- str = http.get("https://api.twitch.tv/kraken/streams/"..streamid).readAll()
- obj = json.decode(str)
- stream = obj.stream
- return follower, stream
- end
- function isjsoninstalled()
- if fs.exists("json") then
- return true
- else
- print("JSON API Not found! Downloading...")
- resp = http.get("http://pastebin.com/raw.php?i=HAve6asF")
- if resp then
- handler = io.open("json","w")
- handler:write(resp.readAll())
- handler:close()
- end
- print("Finished downloading JSON API!")
- return true
- end
- end
- function live(streamid,colorLive,colorNotLive)
- isjsoninstalled()
- os.loadAPI("json")
- if checkLive(streamid) then
- term.setTextColor(colorLive)
- print(streamid.." is live!")
- term.setTextColor(colors.white)
- else
- term.setTextColor(colorNotLive)
- print(streamid.." is not live!")
- term.setTextColor(colors.white)
- end
- end
- function checkLive(streamid)
- lastfollow, stream = init(streamid)
- if stream ~= null then
- return true
- else
- return false
- end
- end
- function lastFollower(streamid)
- lastfollow, stream = init(streamid)
- return lastfollow
- end
- function followerCount(streamid)
- isjsoninstalled()
- os.loadAPI("json")
- str = http.get("https://api.twitch.tv/kraken/channels/" .. streamid .. "/follows?limit=1").readAll()
- obj = json.decode(str)
- follows = obj._total
- return follows
- end
- function viewerCount(streamid)
- lastfollow, stream = init(streamid)
- return stream.viewers
- end
- function viewCount(streamid)
- lastfollow, stream = init(streamid)
- return stream.channel.views
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement