Fix parsing description for navigationEndpoint without urlEndpoint
This commit is contained in:
parent
26fb44595f
commit
729fd2eaee
|
@ -173,7 +173,6 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
||||||
@Override
|
@Override
|
||||||
public Description getDescription() throws ParsingException {
|
public Description getDescription() throws ParsingException {
|
||||||
assertPageFetched();
|
assertPageFetched();
|
||||||
|
|
||||||
// description with more info on links
|
// description with more info on links
|
||||||
try {
|
try {
|
||||||
boolean htmlConversionRequired = false;
|
boolean htmlConversionRequired = false;
|
||||||
|
@ -184,6 +183,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
||||||
String text = textHolder.getString("text");
|
String text = textHolder.getString("text");
|
||||||
if (textHolder.getObject("navigationEndpoint") != null) {
|
if (textHolder.getObject("navigationEndpoint") != null) {
|
||||||
// The text is a link. Get the URL it points to and generate a HTML link of it
|
// The text is a link. Get the URL it points to and generate a HTML link of it
|
||||||
|
if (textHolder.getObject("navigationEndpoint").getObject("urlEndpoint") != null) {
|
||||||
String internUrl = textHolder.getObject("navigationEndpoint").getObject("urlEndpoint").getString("url");
|
String internUrl = textHolder.getObject("navigationEndpoint").getObject("urlEndpoint").getString("url");
|
||||||
if (internUrl.startsWith("/redirect?")) {
|
if (internUrl.startsWith("/redirect?")) {
|
||||||
// q parameter can be the first parameter
|
// q parameter can be the first parameter
|
||||||
|
@ -204,10 +204,12 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
||||||
} else if (internUrl.startsWith("http")) {
|
} else if (internUrl.startsWith("http")) {
|
||||||
descriptionBuilder.append("<a href=\"").append(internUrl).append("\">").append(text).append("</a>");
|
descriptionBuilder.append("<a href=\"").append(internUrl).append("\">").append(text).append("</a>");
|
||||||
htmlConversionRequired = true;
|
htmlConversionRequired = true;
|
||||||
} else if (text != null) {
|
|
||||||
descriptionBuilder.append(text);
|
|
||||||
}
|
}
|
||||||
} else if (text != null) {
|
continue;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (text != null) {
|
||||||
descriptionBuilder.append(text);
|
descriptionBuilder.append(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue