Parse browseEndpoint and watchEndpoint in descriptions
This commit is contained in:
parent
8dc39d517a
commit
8d503407ef
|
@ -229,7 +229,25 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
||||||
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;
|
||||||
}
|
}
|
||||||
continue;
|
} else if (textHolder.getObject("navigationEndpoint").getObject("browseEndpoint") != null) {
|
||||||
|
descriptionBuilder.append("<a href=\"https://www.youtube.com").append(
|
||||||
|
textHolder.getObject("navigationEndpoint").getObject("browseEndpoint")
|
||||||
|
.getString("canonicalBaseUrl")).append("\">").append(text).append("</a>");
|
||||||
|
htmlConversionRequired = true;
|
||||||
|
} else if (textHolder.getObject("navigationEndpoint").getObject("watchEndpoint") != null) {
|
||||||
|
if (textHolder.getObject("navigationEndpoint").getObject("watchEndpoint").getString("playlistId") != null) {
|
||||||
|
descriptionBuilder.append("<a href=\"https://www.youtube.com/watch?v=").append(
|
||||||
|
textHolder.getObject("navigationEndpoint").getObject("watchEndpoint")
|
||||||
|
.getString("videoId")).append("&list=")
|
||||||
|
.append(textHolder.getObject("navigationEndpoint")
|
||||||
|
.getObject("watchEndpoint").getString("playlistId"))
|
||||||
|
.append("\">").append(text).append("</a>");
|
||||||
|
} else {
|
||||||
|
descriptionBuilder.append("<a href=\"https://www.youtube.com/watch?v=").append(
|
||||||
|
textHolder.getObject("navigationEndpoint").getObject("watchEndpoint")
|
||||||
|
.getString("videoId")).append("\">").append(text).append("</a>");
|
||||||
|
}
|
||||||
|
htmlConversionRequired = true;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,21 +245,18 @@ public class YoutubeStreamExtractorDefaultTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetDescription() throws ParsingException {
|
public void testGetDescription() throws ParsingException {
|
||||||
|
System.out.println(extractor.getDescription().getContent());
|
||||||
assertNotNull(extractor.getDescription());
|
assertNotNull(extractor.getDescription());
|
||||||
assertFalse(extractor.getDescription().getContent().isEmpty());
|
assertFalse(extractor.getDescription().getContent().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetFullLinksInDescription() throws ParsingException {
|
public void testGetFullLinksInDescription() throws ParsingException {
|
||||||
assertTrue(extractor.getDescription().getContent().contains("https://www.youtube.com/watch?v=X7FLCHVXpsA&list=PL7u4lWXQ3wfI_7PgX0C-VTiwLeu0S4v34"));
|
final String description = extractor.getDescription().getContent();
|
||||||
assertTrue(extractor.getDescription().getContent().contains("https://www.youtube.com/watch?v=Lqv6G0pDNnw&list=PL7u4lWXQ3wfI_7PgX0C-VTiwLeu0S4v34"));
|
assertTrue(description.contains("https://www.youtube.com/watch?v=X7FLCHVXpsA&list=PL7u4lWXQ3wfI_7PgX0C-VTiwLeu0S4v34"));
|
||||||
assertTrue(extractor.getDescription().getContent().contains("https://www.youtube.com/watch?v=XxaRBPyrnBU&list=PL7u4lWXQ3wfI_7PgX0C-VTiwLeu0S4v34"));
|
assertTrue(description.contains("https://www.youtube.com/watch?v=Lqv6G0pDNnw&list=PL7u4lWXQ3wfI_7PgX0C-VTiwLeu0S4v34"));
|
||||||
assertTrue(extractor.getDescription().getContent().contains("https://www.youtube.com/watch?v=U-9tUEOFKNU&list=PL7u4lWXQ3wfI_7PgX0C-VTiwLeu0S4v34"));
|
assertTrue(description.contains("https://www.youtube.com/watch?v=XxaRBPyrnBU&list=PL7u4lWXQ3wfI_7PgX0C-VTiwLeu0S4v34"));
|
||||||
|
assertTrue(description.contains("https://www.youtube.com/watch?v=U-9tUEOFKNU&list=PL7u4lWXQ3wfI_7PgX0C-VTiwLeu0S4v34"));
|
||||||
assertFalse(extractor.getDescription().getContent().contains("https://youtu.be/X7FLCHVXpsA?list=PL7..."));
|
|
||||||
assertFalse(extractor.getDescription().getContent().contains("https://youtu.be/Lqv6G0pDNnw?list=PL7..."));
|
|
||||||
assertFalse(extractor.getDescription().getContent().contains("https://youtu.be/XxaRBPyrnBU?list=PL7..."));
|
|
||||||
assertFalse(extractor.getDescription().getContent().contains("https://youtu.be/U-9tUEOFKNU?list=PL7..."));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue