Skip to content

Commit

Permalink
fix music catalog
Browse files Browse the repository at this point in the history
  • Loading branch information
gdlbo committed Jun 21, 2024
1 parent c6cff1a commit 27b0771
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,14 @@ public static void fixDailyMix(JSONArray blocks) {
}
}

private static void removeUnsupportedLayouts(JSONArray blocks) throws JSONException {
private static void removeUnsupportedLayouts(JSONArray blocks) {
for (int i = blocks.length() - 1; i >= 0; i--) {
JSONObject block = blocks.optJSONObject(i);
if (block == null) continue;

JSONObject layout = block.optJSONObject("layout");
if (layout == null) continue;

String data_type = block.optString("data_type");

if (Objects.equals(data_type, "music_recommended_playlists") || Objects.equals(data_type, "radiostations")) {
Expand All @@ -233,8 +237,6 @@ private static void removeUnsupportedLayouts(JSONArray blocks) throws JSONExcept
continue; // Skip to the next iteration after removing
}

if (layout == null) continue; // Skip to the next iteration if layout is null

String name = layout.optString("name");
if (!name.equals("header_extended")) {
continue; // Skip to the next iteration if not header_extended
Expand All @@ -243,11 +245,14 @@ private static void removeUnsupportedLayouts(JSONArray blocks) throws JSONExcept
if (layout.has("top_title")) {
blocks.remove(i);
}
layout.put("name", "header");
try {
layout.put("name", "header");
} catch (JSONException e) {
e.fillInStackTrace();
}
}
}


private static void setDefaultAudioPage(JSONArray jsonArray, JSONObject catalog) throws JSONException {
for (int i = 0; i < jsonArray.length(); i++) {
var item = jsonArray.optJSONObject(i);
Expand Down

0 comments on commit 27b0771

Please sign in to comment.