SHOW:
|
|
- or go back to the newest paste.
1 | --=========-- | |
2 | --Changelog-- | |
3 | --=========-- | |
4 | --Version 1.1.0 | |
5 | --1. Fixed live() crash bug! | |
6 | - | resp = http.get("http://pastebin.com/raw.php?i=4nRg9CHU") |
6 | + | --2. Made file smaller, to save on disk space using init()! |
7 | --=========-- | |
8 | --Changelog-- | |
9 | --=========-- | |
10 | function init(streamid) | |
11 | isjsoninstalled() | |
12 | - | print("Finished downloading JSON API!") |
12 | + | |
13 | str = http.get("https://api.twitch.tv/kraken/channels/"..streamid.."/follows?limit=1").readAll() | |
14 | obj = json.decode(str) | |
15 | follower = obj.follows[1].user.name | |
16 | - | |
16 | + | |
17 | obj = json.decode(str) | |
18 | stream = obj.stream | |
19 | return follower, stream | |
20 | end | |
21 | function isjsoninstalled() | |
22 | if fs.exists("json") then | |
23 | return true | |
24 | else | |
25 | print("JSON API Not found! Downloading...") | |
26 | resp = http.get("http://pastebin.com/raw.php?i=HAve6asF") | |
27 | if resp then | |
28 | handler = io.open("json","w") | |
29 | handler:write(resp.readAll()) | |
30 | handler:close() | |
31 | end | |
32 | print("Finished downloading JSON API!") | |
33 | return true | |
34 | end | |
35 | end | |
36 | ||
37 | function live(streamid,colorLive,colorNotLive) | |
38 | isjsoninstalled() | |
39 | os.loadAPI("json") | |
40 | if checkLive(streamid) then | |
41 | term.setTextColor(colorLive) | |
42 | print(streamid.." is live!") | |
43 | term.setTextColor(colors.white) | |
44 | else | |
45 | term.setTextColor(colorNotLive) | |
46 | print(streamid.." is not live!") | |
47 | term.setTextColor(colors.white) | |
48 | end | |
49 | end | |
50 | function checkLive(streamid) | |
51 | lastfollow, stream = init(streamid) | |
52 | if stream ~= null then | |
53 | return true | |
54 | else | |
55 | return false | |
56 | end | |
57 | end | |
58 | function lastFollower(streamid) | |
59 | lastfollow, stream = init(streamid) | |
60 | return lastfollow | |
61 | end | |
62 | function followerCount(streamid) | |
63 | isjsoninstalled() | |
64 | os.loadAPI("json") | |
65 | str = http.get("https://api.twitch.tv/kraken/channels/" .. streamid .. "/follows?limit=1").readAll() | |
66 | obj = json.decode(str) | |
67 | follows = obj._total | |
68 | return follows | |
69 | end | |
70 | function viewerCount(streamid) | |
71 | lastfollow, stream = init(streamid) | |
72 | return stream.viewers | |
73 | end | |
74 | function viewCount(streamid) | |
75 | lastfollow, stream = init(streamid) | |
76 | return stream.channel.views | |
77 | end |