Add Stripchat tags thx to @winkru
This commit is contained in:
parent
41d32ad681
commit
2f1ef7854a
|
@ -5,8 +5,12 @@ import ctbrec.ui.tabs.PaginatedScheduledService;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public abstract class AbstractStripchatUpdateService extends PaginatedScheduledService {
|
public abstract class AbstractStripchatUpdateService extends PaginatedScheduledService {
|
||||||
|
private static final Random RNG = new Random();
|
||||||
|
|
||||||
protected String getPreviewUrl(JSONObject model) {
|
protected String getPreviewUrl(JSONObject model) {
|
||||||
try {
|
try {
|
||||||
|
@ -21,4 +25,45 @@ public abstract class AbstractStripchatUpdateService extends PaginatedScheduledS
|
||||||
return model.optString("previewUrlThumbBig");
|
return model.optString("previewUrlThumbBig");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected List<String> createTags(JSONObject model) {
|
||||||
|
List<String> tags = new ArrayList<>();
|
||||||
|
if (model.optBoolean("isHd")) {
|
||||||
|
tags.add("HD");
|
||||||
|
}
|
||||||
|
if (model.optBoolean("isVr")) {
|
||||||
|
tags.add("VR");
|
||||||
|
}
|
||||||
|
if (model.optBoolean("isLovense")) {
|
||||||
|
tags.add("lovense");
|
||||||
|
}
|
||||||
|
if (model.optBoolean("isNew")) {
|
||||||
|
tags.add("new");
|
||||||
|
}
|
||||||
|
if (model.optBoolean("isMobile")) {
|
||||||
|
tags.add("mobile");
|
||||||
|
}
|
||||||
|
if (model.optBoolean("isNonNude")) {
|
||||||
|
tags.add("non-nude");
|
||||||
|
}
|
||||||
|
if (StringUtil.isNotBlank(model.optString("country"))) {
|
||||||
|
tags.add(model.getString("country").toUpperCase());
|
||||||
|
}
|
||||||
|
if (StringUtil.isNotBlank(model.optString("broadcastGender"))) {
|
||||||
|
tags.add(model.getString("broadcastGender"));
|
||||||
|
}
|
||||||
|
if (StringUtil.isNotBlank(model.optString("status"))) {
|
||||||
|
tags.add(model.getString("status"));
|
||||||
|
}
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getUniq() {
|
||||||
|
String dict = "0123456789abcdefghijklmnopqarstvwxyz";
|
||||||
|
char[] text = new char[16];
|
||||||
|
for (int i = 0; i < 16; i++) {
|
||||||
|
text[i] = dict.charAt(RNG.nextInt(dict.length()));
|
||||||
|
}
|
||||||
|
return new String(text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ import static ctbrec.io.HttpConstants.*;
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class StripchatFollowedUpdateService extends AbstractStripchatUpdateService {
|
public class StripchatFollowedUpdateService extends AbstractStripchatUpdateService {
|
||||||
|
|
||||||
private static final Random RNG = new Random();
|
|
||||||
private static final int MODELS_PER_PAGE = 60;
|
private static final int MODELS_PER_PAGE = 60;
|
||||||
private final Stripchat stripchat;
|
private final Stripchat stripchat;
|
||||||
private final boolean loginRequired;
|
private final boolean loginRequired;
|
||||||
|
@ -105,14 +104,4 @@ public class StripchatFollowedUpdateService extends AbstractStripchatUpdateServi
|
||||||
url = stripchat.getBaseUrl() + "/api/front/models/favorites/offline?sortBy=lastAdded";
|
url = stripchat.getBaseUrl() + "/api/front/models/favorites/offline?sortBy=lastAdded";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getUniq() {
|
|
||||||
String dict = "0123456789abcdefghijklmnopqarstvwxyz";
|
|
||||||
char[] text = new char[16];
|
|
||||||
for (int i = 0; i < 16; i++) {
|
|
||||||
text[i] = dict.charAt(RNG.nextInt(dict.length()));
|
|
||||||
}
|
|
||||||
return new String(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,10 +79,15 @@ public class StripchatUpdateService extends AbstractStripchatUpdateService {
|
||||||
var jsonModel = jsonModels.getJSONObject(i);
|
var jsonModel = jsonModels.getJSONObject(i);
|
||||||
try {
|
try {
|
||||||
StripchatModel model = stripchat.createModel(jsonModel.getString("username"));
|
StripchatModel model = stripchat.createModel(jsonModel.getString("username"));
|
||||||
model.setDescription("");
|
|
||||||
model.setPreview(getPreviewUrl(jsonModel));
|
model.setPreview(getPreviewUrl(jsonModel));
|
||||||
model.setDisplayName(model.getName());
|
model.setDisplayName(model.getName());
|
||||||
model.setOnlineState(Model.State.ONLINE);
|
model.setOnlineState(Model.State.ONLINE);
|
||||||
|
model.setTags(createTags(jsonModel));
|
||||||
|
StringBuilder description = new StringBuilder();
|
||||||
|
for (String tag : model.getTags()) {
|
||||||
|
description.append("#").append(tag).append(" ");
|
||||||
|
}
|
||||||
|
model.setDescription(description.toString());
|
||||||
models.add(model);
|
models.add(model);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.warn("Couldn't parse one of the models: {}", jsonModel, e);
|
LOG.warn("Couldn't parse one of the models: {}", jsonModel, e);
|
||||||
|
|
Loading…
Reference in New Issue