Don't try to load followed models, if username is not set
This commit is contained in:
parent
306f07cf63
commit
f0d2a720ab
|
@ -1,11 +1,13 @@
|
|||
package ctbrec.sites.chaturbate;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -44,6 +46,9 @@ public class ChaturbateUpdateService extends PaginatedScheduledService {
|
|||
return new Task<List<Model>>() {
|
||||
@Override
|
||||
public List<Model> call() throws IOException {
|
||||
if(loginRequired && StringUtil.isBlank(ctbrec.Config.getInstance().getSettings().username)) {
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
String url = ChaturbateUpdateService.this.url + "?page="+page+"&keywords=&_=" + System.currentTimeMillis();
|
||||
LOG.debug("Fetching page {}", url);
|
||||
Request request = new Request.Builder().url(url).build();
|
||||
|
@ -58,6 +63,7 @@ public class ChaturbateUpdateService extends PaginatedScheduledService {
|
|||
throw new IOException("HTTP status " + code);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -3,9 +3,11 @@ package ctbrec.sites.mfc;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -36,6 +38,9 @@ public class FriendsUpdateService extends PaginatedScheduledService {
|
|||
return new Task<List<Model>>() {
|
||||
@Override
|
||||
public List<Model> call() throws IOException {
|
||||
if(StringUtil.isBlank(ctbrec.Config.getInstance().getSettings().username)) {
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
List<MyFreeCamsModel> models = new ArrayList<>();
|
||||
String url = myFreeCams.getBaseUrl() + "/php/manage_lists2.php?passcode=&list_type=friends&data_mode=online&get_user_list=1";
|
||||
Request req = new Request.Builder()
|
||||
|
@ -44,14 +49,14 @@ public class FriendsUpdateService extends PaginatedScheduledService {
|
|||
.build();
|
||||
Response resp = myFreeCams.getHttpClient().execute(req, true);
|
||||
if(resp.isSuccessful()) {
|
||||
String json = resp.body().string().substring(4);
|
||||
String body = resp.body().string().substring(4);
|
||||
try {
|
||||
JSONObject object = new JSONObject(json);
|
||||
for (String key : object.keySet()) {
|
||||
JSONObject json = new JSONObject(body);
|
||||
for (String key : json.keySet()) {
|
||||
int uid = Integer.parseInt(key);
|
||||
MyFreeCamsModel model = MyFreeCamsClient.getInstance().getModel(uid);
|
||||
if(model == null) {
|
||||
JSONObject modelObject = object.getJSONObject(key);
|
||||
JSONObject modelObject = json.getJSONObject(key);
|
||||
String name = modelObject.getString("u");
|
||||
model = myFreeCams.createModel(name);
|
||||
SessionState st = new SessionState();
|
||||
|
@ -67,8 +72,7 @@ public class FriendsUpdateService extends PaginatedScheduledService {
|
|||
models.add(model);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
LOG.info("JSON: {}", json);
|
||||
throw e;
|
||||
LOG.info("Exception getting friends list. Response was: {}", body);
|
||||
}
|
||||
} else {
|
||||
LOG.error("Couldn't load friends list {} {}", resp.code(), resp.message());
|
||||
|
@ -88,6 +92,7 @@ public class FriendsUpdateService extends PaginatedScheduledService {
|
|||
.limit(50)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue