Fix thumbnails in Camsoda search results
This commit is contained in:
parent
f7fc33afd6
commit
1b80458353
|
@ -1,6 +1,15 @@
|
||||||
package ctbrec.sites.camsoda;
|
package ctbrec.sites.camsoda;
|
||||||
|
|
||||||
import static ctbrec.io.HttpConstants.*;
|
import ctbrec.Model;
|
||||||
|
import ctbrec.io.HttpClient;
|
||||||
|
import ctbrec.io.HttpException;
|
||||||
|
import ctbrec.sites.AbstractSite;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
@ -10,17 +19,8 @@ import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import static ctbrec.io.HttpConstants.USER_AGENT;
|
||||||
import org.json.JSONObject;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import ctbrec.Model;
|
|
||||||
import ctbrec.io.HttpClient;
|
|
||||||
import ctbrec.io.HttpException;
|
|
||||||
import ctbrec.sites.AbstractSite;
|
|
||||||
import okhttp3.Request;
|
|
||||||
import okhttp3.Response;
|
|
||||||
|
|
||||||
public class Camsoda extends AbstractSite {
|
public class Camsoda extends AbstractSite {
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ public class Camsoda extends AbstractSite {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Model> search(String q) throws IOException, InterruptedException {
|
public List<Model> search(String q) throws IOException, InterruptedException {
|
||||||
String url = BASE_URI + "/api/v1/browse/autocomplete?s=" + URLEncoder.encode(q, "utf-8");
|
String url = BASE_URI + "/api/v1/browse/autocomplete?s=" + URLEncoder.encode(q, UTF_8);
|
||||||
Request req = new Request.Builder()
|
Request req = new Request.Builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
.addHeader(USER_AGENT, getConfig().getSettings().httpUserAgent)
|
.addHeader(USER_AGENT, getConfig().getSettings().httpUserAgent)
|
||||||
|
@ -139,7 +139,12 @@ public class Camsoda extends AbstractSite {
|
||||||
CamsodaModel model = (CamsodaModel) createModel(result.getString("username"));
|
CamsodaModel model = (CamsodaModel) createModel(result.getString("username"));
|
||||||
String thumb = result.getString("thumb");
|
String thumb = result.getString("thumb");
|
||||||
if (thumb != null) {
|
if (thumb != null) {
|
||||||
model.setPreview("https:" + thumb);
|
if (thumb.startsWith("//")) {
|
||||||
|
thumb = "https:" + thumb;
|
||||||
|
} else if (thumb.startsWith("/")) {
|
||||||
|
thumb = BASE_URI + thumb;
|
||||||
|
}
|
||||||
|
model.setPreview(thumb);
|
||||||
}
|
}
|
||||||
if (result.has("display_name")) {
|
if (result.has("display_name")) {
|
||||||
model.setDisplayName(result.getString("display_name"));
|
model.setDisplayName(result.getString("display_name"));
|
||||||
|
|
Loading…
Reference in New Issue