Skip to content

Commit 9a59afb

Browse files
authored
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
2 parents 39a911d + bb1ab16 commit 9a59afb

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,10 @@ public String getBannerUrl() throws ParsingException {
282282
))
283283
.filter(url -> !url.contains("s.ytimg.com") && !url.contains("default_banner"))
284284
.map(YoutubeParsingHelper::fixThumbnailUrl)
285-
.orElseThrow(() -> new ParsingException("Could not get banner"));
285+
// Channels may not have a banner, so no exception should be thrown if no banner is
286+
// found
287+
// Return null in this case
288+
.orElse(null);
286289
}
287290

288291
@Override

extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
44
import static org.junit.jupiter.api.Assertions.assertFalse;
5+
import static org.junit.jupiter.api.Assertions.assertNull;
56
import static org.junit.jupiter.api.Assertions.assertThrows;
67
import static org.junit.jupiter.api.Assertions.assertTrue;
78
import static org.junit.jupiter.api.Assertions.fail;
@@ -720,7 +721,8 @@ public void testAvatarUrl() throws Exception {
720721

721722
@Test
722723
public void testBannerUrl() throws Exception {
723-
// CarouselHeaderRender does not contain a banner
724+
// CarouselHeaderRenders do not contain a banner
725+
assertNull(extractor.getBannerUrl());
724726
}
725727

726728
@Test

0 commit comments

Comments
 (0)