Tried to reduce frequency of Twitch API pulls
This commit is contained in:
parent
967c66040c
commit
3eb312abf8
BIN
sigIRCv2.jar
BIN
sigIRCv2.jar
Binary file not shown.
@ -138,6 +138,7 @@ public class TwitchModule extends Module{
|
|||||||
lastFollowerCheck = FOLLOWERCHECKTIMER;
|
lastFollowerCheck = FOLLOWERCHECKTIMER;
|
||||||
getFollowers(false);
|
getFollowers(false);
|
||||||
popFollowerFromQueue();
|
popFollowerFromQueue();
|
||||||
|
isStreamOnline(true);
|
||||||
}
|
}
|
||||||
if (lastFollowerAnnouncement>0) {
|
if (lastFollowerAnnouncement>0) {
|
||||||
lastFollowerAnnouncement--;
|
lastFollowerAnnouncement--;
|
||||||
@ -280,48 +281,55 @@ public class TwitchModule extends Module{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isStreamOnline() {
|
private boolean isStreamOnline() {
|
||||||
sigIRC.manager.streams().get(TextUtils.getActualChannelName(), new StreamResponseHandler() {
|
return isStreamOnline(false);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
private boolean isStreamOnline(boolean update) {
|
||||||
public void onFailure(Throwable arg0) {
|
if (update) {
|
||||||
TwitchModule.streamOnline=false;
|
sigIRC.manager.streams().get(TextUtils.getActualChannelName(), new StreamResponseHandler() {
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(int arg0, String arg1, String arg2) {
|
public void onFailure(Throwable arg0) {
|
||||||
System.out.println(arg0+","+arg1+","+arg2);
|
|
||||||
TwitchModule.streamOnline=false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSuccess(Stream arg0) {
|
|
||||||
//System.out.println("Stream data is available! "+arg0);
|
|
||||||
if (arg0==null) {
|
|
||||||
TwitchModule.streamOnline=false;
|
TwitchModule.streamOnline=false;
|
||||||
} else {
|
|
||||||
TwitchModule.streamOnline=true;
|
|
||||||
UpdateAllStreamStatistics(arg0);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateAllStreamStatistics(Stream data) {
|
@Override
|
||||||
if (data!=null) {
|
public void onFailure(int arg0, String arg1, String arg2) {
|
||||||
if (data.getGame()!=null && data.getGame().length()>0) {
|
System.out.println(arg0+","+arg1+","+arg2);
|
||||||
currentlyPlaying = data.getGame();
|
TwitchModule.streamOnline=false;
|
||||||
}
|
|
||||||
if (data.getCreatedAt()!=null) {
|
|
||||||
uptime = data.getCreatedAt();
|
|
||||||
}
|
|
||||||
viewers_numb.updateValue(data.getViewers());
|
|
||||||
views_numb.updateValue((int)data.getChannel().getViews());
|
|
||||||
followers_numb.updateValue(data.getChannel().getFollowers());
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
});
|
@Override
|
||||||
return TwitchModule.streamOnline;
|
public void onSuccess(Stream arg0) {
|
||||||
|
//System.out.println("Stream data is available! "+arg0);
|
||||||
|
if (arg0==null) {
|
||||||
|
TwitchModule.streamOnline=false;
|
||||||
|
} else {
|
||||||
|
TwitchModule.streamOnline=true;
|
||||||
|
UpdateAllStreamStatistics(arg0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateAllStreamStatistics(Stream data) {
|
||||||
|
if (data!=null) {
|
||||||
|
if (data.getGame()!=null && data.getGame().length()>0) {
|
||||||
|
currentlyPlaying = data.getGame();
|
||||||
|
}
|
||||||
|
if (data.getCreatedAt()!=null) {
|
||||||
|
uptime = data.getCreatedAt();
|
||||||
|
}
|
||||||
|
viewers_numb.updateValue(data.getViewers());
|
||||||
|
views_numb.updateValue((int)data.getChannel().getViews());
|
||||||
|
followers_numb.updateValue(data.getChannel().getFollowers());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
return TwitchModule.streamOnline;
|
||||||
|
} else {
|
||||||
|
return TwitchModule.streamOnline;
|
||||||
|
}
|
||||||
//TwitchModule.streamOnline=true;
|
//TwitchModule.streamOnline=true;
|
||||||
//return true;
|
//return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user