From 0e08e97f459aec43fe2387e76e58e8381cb35d89 Mon Sep 17 00:00:00 2001 From: okjack Date: Mon, 15 Jul 2024 18:16:56 +0800 Subject: [PATCH] Fix yt list bug --- .../kiulian/downloader/parser/ParserImpl.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/youtube/src/main/java/com/github/kiulian/downloader/parser/ParserImpl.java b/youtube/src/main/java/com/github/kiulian/downloader/parser/ParserImpl.java index 1f42452b4..660b694ae 100644 --- a/youtube/src/main/java/com/github/kiulian/downloader/parser/ParserImpl.java +++ b/youtube/src/main/java/com/github/kiulian/downloader/parser/ParserImpl.java @@ -83,17 +83,17 @@ public class ParserImpl implements Parser { private VideoInfo parseVideoAndroid(String videoId, YoutubeCallback callback) throws YoutubeException { String url = "https://youtubei.googleapis.com/youtubei/v1/player?key=" + ANDROID_APIKEY; String body = "{" + - " \"videoId\": \"" + videoId + "\"," + - " \"context\": {" + - " \"client\": {" + - " \"hl\": \"en\"," + - " \"gl\": \"US\"," + - " \"clientName\": \"ANDROID_TESTSUITE\"," + - " \"clientVersion\": \"1.9\"," + - " \"androidSdkVersion\": 31" + - " }" + - " }" + - "}"; + " \"videoId\": \"" + videoId + "\"," + + " \"context\": {" + + " \"client\": {" + + " \"hl\": \"en\"," + + " \"gl\": \"US\"," + + " \"clientName\": \"ANDROID_TESTSUITE\"," + + " \"clientVersion\": \"1.9\"," + + " \"androidSdkVersion\": 31" + + " }" + + " }" + + "}"; RequestWebpage request = new RequestWebpage(url, "POST", body).header("Content-Type", "application/json"); Response response = downloader.downloadWebpage(request); if (!response.ok()) { @@ -424,11 +424,11 @@ public class ParserImpl implements Parser { } String html = response.data(); try { - JsonObject content; + JsonObject content = new JsonObject(); JsonObject jsonResponse = JsonParser.parseString(html).getAsJsonObject(); if (jsonResponse.has("continuationContents")) { content = jsonResponse.getAsJsonObject("continuationContents").getAsJsonObject("playlistVideoListContinuation"); - } else { + } else if (jsonResponse.has("onResponseReceivedActions")) { content = jsonResponse.getAsJsonArray("onResponseReceivedActions").get(0).getAsJsonObject().getAsJsonObject("appendContinuationItemsAction"); } populatePlaylist(content, videos, clientVersion);