mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2025-01-06 01:20:32 +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};
|
return youtubeMusicKeys = new String[]{key, clientName, clientVersion};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static String getUrlFromNavigationEndpoint(JsonObject navigationEndpoint) throws ParsingException {
|
public static String getUrlFromNavigationEndpoint(JsonObject navigationEndpoint) throws ParsingException {
|
||||||
if (navigationEndpoint.has("urlEndpoint")) {
|
if (navigationEndpoint.has("urlEndpoint")) {
|
||||||
String internUrl = navigationEndpoint.getObject("urlEndpoint").getString("url");
|
String internUrl = navigationEndpoint.getObject("urlEndpoint").getString("url");
|
||||||
|
if (internUrl.startsWith("https://www.youtube.com/redirect?")) {
|
||||||
|
internUrl = internUrl.substring(23);
|
||||||
|
}
|
||||||
|
|
||||||
if (internUrl.startsWith("/redirect?")) {
|
if (internUrl.startsWith("/redirect?")) {
|
||||||
// q parameter can be the first parameter
|
// q parameter can be the first parameter
|
||||||
internUrl = internUrl.substring(10);
|
internUrl = internUrl.substring(10);
|
||||||
@ -450,6 +456,8 @@ public class YoutubeParsingHelper {
|
|||||||
}
|
}
|
||||||
} else if (internUrl.startsWith("http")) {
|
} else if (internUrl.startsWith("http")) {
|
||||||
return internUrl;
|
return internUrl;
|
||||||
|
} else if (internUrl.startsWith("/channel") || internUrl.startsWith("/user") || internUrl.startsWith("/watch")) {
|
||||||
|
return "https://www.youtube.com" + internUrl;
|
||||||
}
|
}
|
||||||
} else if (navigationEndpoint.has("browseEndpoint")) {
|
} else if (navigationEndpoint.has("browseEndpoint")) {
|
||||||
final JsonObject browseEndpoint = navigationEndpoint.getObject("browseEndpoint");
|
final JsonObject browseEndpoint = navigationEndpoint.getObject("browseEndpoint");
|
||||||
|
@ -224,7 +224,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Description getDescription() {
|
public Description getDescription() throws ParsingException {
|
||||||
assertPageFetched();
|
assertPageFetched();
|
||||||
// description with more info on links
|
// description with more info on links
|
||||||
try {
|
try {
|
||||||
@ -234,8 +234,15 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||||||
// age-restricted videos cause a ParsingException here
|
// 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
|
// raw non-html description
|
||||||
return new Description(playerResponse.getObject("videoDetails").getString("shortDescription"), Description.PLAIN_TEXT);
|
return new Description(description, Description.PLAIN_TEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -69,7 +69,15 @@ public class YoutubeTrendingExtractor extends KioskExtractor<StreamInfoItem> {
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getName() throws ParsingException {
|
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)) {
|
if (!isNullOrEmpty(name)) {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user