Better proxying of images.

This commit is contained in:
FireMasterK 2020-12-09 18:59:12 +05:30
parent a395115f18
commit 26b92c751a
No known key found for this signature in database
GPG Key ID: 8DFF5DD33E93DB58

View File

@ -234,6 +234,9 @@ public class ResponseHelper {
if (Constants.debug) if (Constants.debug)
return old; return old;
if (old == null || old.isEmpty())
return null;
URL url = null; URL url = null;
try { try {
@ -246,14 +249,17 @@ public class ResponseHelper {
String query = url.getQuery(); String query = url.getQuery();
final boolean hasQuery = query != null; boolean hasQuery = query != null;
String path = url.getPath(); String path = url.getPath();
path = path.replace("-rj", "-rw"); path = path.replace("-rj", "-rw");
if (!hasQuery && path.startsWith("/vi/")) if (path.startsWith("/vi/") && !path.contains("_live")) {
path = path.replace("/vi/", "/vi_webp/").replace(".jpg", ".webp"); path = path.replace("/vi/", "/vi_webp/").replace(".jpg", ".webp").replace("hq720", "mqdefault")
.replace("hqdefault", "mqdefault");
hasQuery = false;
}
return Constants.PROXY_PART + path + (hasQuery ? "?" + query + "&host=" : "?host=") return Constants.PROXY_PART + path + (hasQuery ? "?" + query + "&host=" : "?host=")
+ URLUtils.silentEncode(host); + URLUtils.silentEncode(host);