Skip to content

Commit

Permalink
[YouTube] Fix getting the comment text if the comment contains a hashtag
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiGr committed Jan 24, 2023
1 parent ff94e9f commit f5e7d4a
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,14 @@ public static String getUrlFromNavigationEndpoint(@Nonnull final JsonObject navi
|| internUrl.startsWith("/watch")) {
return "https://www.youtube.com" + internUrl;
}
} else 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");
}
throw new ParsingException("There is no url in the webCommandMetadata");
} else if (navigationEndpoint.has("browseEndpoint")) {
final JsonObject browseEndpoint = navigationEndpoint.getObject("browseEndpoint");
final String canonicalBaseUrl = browseEndpoint.getString("canonicalBaseUrl");
Expand Down

0 comments on commit f5e7d4a

Please sign in to comment.