Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,15 @@ public String getUrl() throws ParsingException {

@Override
public String getName() throws ParsingException {
final String name = getTextFromObject(videoInfo.getObject("title"));
final JsonObject title = videoInfo.getObject("title");
final String name = getTextFromObject(title);
if (!isNullOrEmpty(name)) {
return name;
}
// Videos can have no title, e.g. https://www.youtube.com/watch?v=nc1kN8ZSfGQ
if (!isNullOrEmpty(title) && !title.has("runs")) {
return "";
}
throw new ParsingException("Could not get name");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,29 @@ void lockupViewModelPremiere()
() -> assertFalse(extractor.isShortFormContent())
);
}

@Test
void emptyTitle() throws FileNotFoundException, JsonParserException {
final var json = JsonParser.object().from(new FileInputStream(getMockPath(
YoutubeStreamInfoItemTest.class, "emptyTitle") + ".json"));
final var timeAgoParser = TimeAgoPatternsManager.getTimeAgoParserFor(Localization.DEFAULT);
final var extractor = new YoutubeStreamInfoItemExtractor(json, timeAgoParser);
assertAll(
() -> assertEquals(StreamType.VIDEO_STREAM, extractor.getStreamType()),
() -> assertFalse(extractor.isAd()),
() -> assertEquals("https://www.youtube.com/watch?v=nc1kN8ZSfGQ", extractor.getUrl()),
() -> assertEquals("", extractor.getName()),
() -> assertEquals(39, extractor.getDuration()),
() -> assertEquals("hyper", extractor.getUploaderName()),
() -> assertEquals("https://www.youtube.com/channel/UCSezUnbvCLYBXuUlPcXU_QQ", extractor.getUploaderUrl()),
() -> assertFalse(extractor.getUploaderAvatars().isEmpty()),
() -> assertTrue(extractor.isUploaderVerified()),
() -> assertEquals("8 years ago", extractor.getTextualUploadDate()),
() -> assertNotNull(extractor.getUploadDate()),
() -> assertTrue(extractor.getViewCount() >= 1318193),
() -> assertFalse(extractor.getThumbnails().isEmpty()),
() -> assertNull(extractor.getShortDescription()),
() -> assertFalse(extractor.isShortFormContent())
);
}
}
Loading