resetRateLimitCache();
myWait(0.5f);
}
ResponseList res = null;
IDs ids = null;
try {
if (friends)
ids = twitter.getFriendsIDs(userName, cursor);
else
ids = twitter.getFollowersIDs(userName, cursor);
rateLimit--;
} catch (TwitterException ex) {
logger.warn(ex.getMessage());
break;
}
if (ids.getIDs().length == 0)
break;
long[] intids = ids.getIDs();
// split into max 100 batch
for (int offset = 0; offset < intids.length; offset += 100) {
long[] limitedIds = new long[100];
for (int ii = 0; ii + offset < intids.length && ii < limitedIds.length; ii++) {
limitedIds[ii] = intids[ii + offset];
}
// retry at max N times for every id bunch
for (int i = 0; i < 5; i++) {
try {
res = twitter.lookupUsers(limitedIds);
rateLimit--;
for (Object o : res) {
User user = (User) o;
// strange that this was necessary for ibood
if (user.getScreenName().trim().isEmpty())
continue;
JUser jUser = new JUser(user);
if (executor.execute(jUser) == null)
break MAIN;
}
break;
} catch (Exception ex) {
ex.printStackTrace();
myWait(5);
continue;
}
}
if (res == null) {
logger.error("giving up");
break;
}
}
if (!ids.hasNext())
break;
cursor = ids.getNextCursor();
}
}