From 3f7df9536effad6ad79b20e22d06d39d09c80e54 Mon Sep 17 00:00:00 2001 From: TobiGr Date: Sun, 29 Jan 2023 20:33:51 +0100 Subject: [PATCH] [YouTube] Fix getting the comment text if the comment contains a hashtag --- .../extractor/services/youtube/YoutubeParsingHelper.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java index fdfe48164..81e9fdc60 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java @@ -845,6 +845,14 @@ public final class YoutubeParsingHelper { @Nullable public static String getUrlFromNavigationEndpoint(@Nonnull final JsonObject navigationEndpoint) throws ParsingException { + if (navigationEndpoint.has("webCommandMetadata")) { + // this case needs to be handled before the browseEndpoint, + // e.g. for hashtags in comments + final JsonObject metadata = navigationEndpoint.getObject("webCommandMetadata"); + if (metadata.has("url")) { + return "https://www.youtube.com" + metadata.getString("url"); + } + } if (navigationEndpoint.has("urlEndpoint")) { String internUrl = navigationEndpoint.getObject("urlEndpoint").getString("url"); if (internUrl.startsWith("https://www.youtube.com/redirect?")) {