From 4363dc5b4b335ed6243d9b27777163e27ad66dca Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sat, 9 Nov 2024 06:11:31 +0400 Subject: [PATCH] chore(YouTube - Announcements): Remove language parameter of API call (#3874) --- .../patches/announcements/AnnouncementsPatch.java | 11 ++++------- .../announcements/requests/AnnouncementsRoutes.java | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/announcements/AnnouncementsPatch.java b/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/announcements/AnnouncementsPatch.java index f1fdd2a26e..10309da966 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/announcements/AnnouncementsPatch.java +++ b/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/announcements/AnnouncementsPatch.java @@ -15,13 +15,10 @@ import androidx.annotation.RequiresApi; import org.json.JSONArray; -import org.json.JSONObject; import java.io.IOException; import java.net.HttpURLConnection; import java.time.LocalDateTime; -import java.util.Locale; -import java.util.logging.Level; import app.revanced.extension.shared.Logger; import app.revanced.extension.shared.Utils; @@ -84,8 +81,8 @@ public static void showAnnouncement(final Activity context) { try { if (isLatestAlready()) return; - HttpURLConnection connection = AnnouncementsRoutes.getAnnouncementsConnectionFromRoute( - GET_LATEST_ANNOUNCEMENTS, Locale.getDefault().toLanguageTag()); + HttpURLConnection connection = AnnouncementsRoutes + .getAnnouncementsConnectionFromRoute(GET_LATEST_ANNOUNCEMENTS); Logger.printDebug(() -> "Get latest announcements route connection url: " + connection.getURL()); @@ -98,11 +95,11 @@ public static void showAnnouncement(final Activity context) { LocalDateTime archivedAt = LocalDateTime.MAX; Level level = Level.INFO; try { - final var announcement = new JSONObject(jsonString); + final var announcement = new JSONArray(jsonString).getJSONObject(0); id = announcement.getInt("id"); title = announcement.getString("title"); - message = announcement.getJSONObject("content").getString("message"); + message = announcement.getString("content"); if (!announcement.isNull("archived_at")) { archivedAt = LocalDateTime.parse(announcement.getString("archived_at")); } diff --git a/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/announcements/requests/AnnouncementsRoutes.java b/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/announcements/requests/AnnouncementsRoutes.java index 6ee8b15a82..ea54e1bd6f 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/announcements/requests/AnnouncementsRoutes.java +++ b/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/announcements/requests/AnnouncementsRoutes.java @@ -9,9 +9,9 @@ import static app.revanced.extension.youtube.requests.Route.Method.GET; public class AnnouncementsRoutes { - public static final Route GET_LATEST_ANNOUNCEMENTS = new Route(GET, "/announcements/latest?tag=youtube"); - public static final Route GET_LATEST_ANNOUNCEMENT_IDS = new Route(GET, "/announcements/latest/id?tag=youtube"); private static final String ANNOUNCEMENTS_PROVIDER = "https://api.revanced.app/v4"; + public static final Route GET_LATEST_ANNOUNCEMENT_IDS = new Route(GET, "/announcements/latest/id?tag=youtube"); + public static final Route GET_LATEST_ANNOUNCEMENTS = new Route(GET, "/announcements/latest?tag=youtube"); private AnnouncementsRoutes() { }