Merge pull request #1086 from AudricV/yt_no-exception-channels-without-banner

[YouTube] Don't throw an exception when there is no banner available on a channel
This commit is contained in:
Tobi 2023-08-02 18:56:26 +02:00 committed by GitHub
commit 9a59afbcf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -282,7 +282,10 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
))
.filter(url -> !url.contains("s.ytimg.com") && !url.contains("default_banner"))
.map(YoutubeParsingHelper::fixThumbnailUrl)
.orElseThrow(() -> new ParsingException("Could not get banner"));
// Channels may not have a banner, so no exception should be thrown if no banner is
// found
// Return null in this case
.orElse(null);
}
@Override

View File

@ -2,6 +2,7 @@ package org.schabi.newpipe.extractor.services.youtube;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
@ -720,7 +721,8 @@ public class YoutubeChannelExtractorTest {
@Test
public void testBannerUrl() throws Exception {
// CarouselHeaderRender does not contain a banner
// CarouselHeaderRenders do not contain a banner
assertNull(extractor.getBannerUrl());
}
@Test