mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2024-12-14 06:10:33 +05:30
fix tests
This commit is contained in:
parent
d116680ea3
commit
a931e31239
@ -429,10 +429,16 @@ public class YoutubeParsingHelper {
|
||||
return youtubeMusicKeys = new String[]{key, clientName, clientVersion};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Nullable
|
||||
public static String getUrlFromNavigationEndpoint(JsonObject navigationEndpoint) throws ParsingException {
|
||||
if (navigationEndpoint.has("urlEndpoint")) {
|
||||
String internUrl = navigationEndpoint.getObject("urlEndpoint").getString("url");
|
||||
if (internUrl.startsWith("https://www.youtube.com/redirect?")) {
|
||||
internUrl = internUrl.substring(23);
|
||||
}
|
||||
|
||||
if (internUrl.startsWith("/redirect?")) {
|
||||
// q parameter can be the first parameter
|
||||
internUrl = internUrl.substring(10);
|
||||
@ -450,6 +456,8 @@ public class YoutubeParsingHelper {
|
||||
}
|
||||
} else if (internUrl.startsWith("http")) {
|
||||
return internUrl;
|
||||
} else if (internUrl.startsWith("/channel") || internUrl.startsWith("/user") || internUrl.startsWith("/watch")) {
|
||||
return "https://www.youtube.com" + internUrl;
|
||||
}
|
||||
} else if (navigationEndpoint.has("browseEndpoint")) {
|
||||
final JsonObject browseEndpoint = navigationEndpoint.getObject("browseEndpoint");
|
||||
|
@ -224,7 +224,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Description getDescription() {
|
||||
public Description getDescription() throws ParsingException {
|
||||
assertPageFetched();
|
||||
// description with more info on links
|
||||
try {
|
||||
@ -234,8 +234,15 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
||||
// age-restricted videos cause a ParsingException here
|
||||
}
|
||||
|
||||
String description = playerResponse.getObject("videoDetails").getString("shortDescription");
|
||||
if (description == null) {
|
||||
final JsonObject descriptionObject = playerResponse.getObject("microformat")
|
||||
.getObject("playerMicroformatRenderer").getObject("description");
|
||||
description = getTextFromObject(descriptionObject);
|
||||
}
|
||||
|
||||
// raw non-html description
|
||||
return new Description(playerResponse.getObject("videoDetails").getString("shortDescription"), Description.PLAIN_TEXT);
|
||||
return new Description(description, Description.PLAIN_TEXT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -69,7 +69,15 @@ public class YoutubeTrendingExtractor extends KioskExtractor<StreamInfoItem> {
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName() throws ParsingException {
|
||||
String name = getTextFromObject(initialData.getObject("header").getObject("feedTabbedHeaderRenderer").getObject("title"));
|
||||
final JsonObject header = initialData.getObject("header");
|
||||
JsonObject title = null;
|
||||
if (header.has("feedTabbedHeaderRenderer")) {
|
||||
title = header.getObject("feedTabbedHeaderRenderer").getObject("title");
|
||||
} else if (header.has("c4TabbedHeaderRenderer")) {
|
||||
title = header.getObject("c4TabbedHeaderRenderer").getObject("title");
|
||||
}
|
||||
|
||||
String name = getTextFromObject(title);
|
||||
if (!isNullOrEmpty(name)) {
|
||||
return name;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user