fix artists catalog
This commit is contained in:
@@ -1,35 +1,29 @@
|
||||
package ru.vtosters.lite.music.catalog.inject;
|
||||
|
||||
import static ru.vtosters.lite.hooks.DateHook.getLocale;
|
||||
import static ru.vtosters.lite.music.cache.helpers.PlaylistHelper.getCatalogHeader;
|
||||
import static ru.vtosters.lite.music.cache.helpers.PlaylistHelper.getCatalogPlaylist;
|
||||
import static ru.vtosters.lite.music.cache.helpers.PlaylistHelper.getCatalogSeparator;
|
||||
import static ru.vtosters.lite.music.cache.helpers.PlaylistHelper.getPlaylist;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
|
||||
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserId;
|
||||
import static ru.vtosters.lite.utils.Preferences.dev;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import bruhcollective.itaysonlab.libvkx.client.LibVKXClient;
|
||||
import com.vk.core.network.Network;
|
||||
import com.vk.core.util.DeviceIdProvider;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import bruhcollective.itaysonlab.libvkx.client.LibVKXClient;
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
import ru.vtosters.lite.music.cache.CacheDatabaseDelegate;
|
||||
import ru.vtosters.lite.utils.AccountManagerUtils;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static ru.vtosters.lite.hooks.DateHook.getLocale;
|
||||
import static ru.vtosters.lite.music.cache.helpers.PlaylistHelper.*;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
|
||||
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserId;
|
||||
import static ru.vtosters.lite.utils.Preferences.dev;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
public class CatalogJsonInjector {
|
||||
private static final OkHttpClient mClient = VtOkHttpClient.getInstance();
|
||||
private static boolean isLoaded;
|
||||
@@ -232,29 +226,46 @@ public class CatalogJsonInjector {
|
||||
}
|
||||
}
|
||||
|
||||
var section = json.optJSONObject("section");
|
||||
if (section != null) {
|
||||
var blocks = section.optJSONArray("blocks");
|
||||
if (blocks != null) {
|
||||
for (int i = 0; i < blocks.length(); i++) {
|
||||
var block = blocks.optJSONObject(i);
|
||||
var layout = block.optJSONObject("layout");
|
||||
if (layout != null) {
|
||||
var name = layout.optString("name");
|
||||
if (name.equals("header_extended")) {
|
||||
if (layout.has("top_title")) blocks.remove(i);
|
||||
try {
|
||||
layout.put("name", "header");
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fixHeaders(json.getJSONObject("section"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return catalogInjector(json);
|
||||
}
|
||||
|
||||
public static JSONObject fixArtists(JSONObject json) {
|
||||
|
||||
try {
|
||||
fixHeaders(json.getJSONObject("catalog").getJSONArray("sections").getJSONObject(0));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
public static void fixHeaders(JSONObject json) {
|
||||
var blocks = json.optJSONArray("blocks");
|
||||
|
||||
if (blocks != null) {
|
||||
for (int i = 0; i < blocks.length(); i++) {
|
||||
var block = blocks.optJSONObject(i);
|
||||
var layout = block.optJSONObject("layout");
|
||||
if (layout != null) {
|
||||
var name = layout.optString("name");
|
||||
if (name.equals("header_extended")) {
|
||||
if (layout.has("top_title")) blocks.remove(i);
|
||||
try {
|
||||
layout.put("name", "header");
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return catalogInjector(json);
|
||||
}
|
||||
|
||||
private static JSONObject fetchCatalogId(String section) {
|
||||
|
||||
@@ -82,6 +82,10 @@
|
||||
|
||||
move-result-object p1
|
||||
|
||||
invoke-static {p1}, Lru/vtosters/lite/music/catalog/inject/CatalogJsonInjector;->fixArtists(Lorg/json/JSONObject;)Lorg/json/JSONObject;
|
||||
|
||||
move-result-object p1
|
||||
|
||||
const-string v1, "r.getJSONObject(ServerKeys.RESPONSE)"
|
||||
|
||||
invoke-static {p1, v1}, Lkotlin/jvm/internal/Intrinsics;->a(Ljava/lang/Object;Ljava/lang/String;)V
|
||||
|
||||
Reference in New Issue
Block a user