Skip to content

Commit

Permalink
Merge pull request #1086 from AudricV/yt_no-exception-channels-withou…
Browse files Browse the repository at this point in the history
…t-banner

[YouTube] Don't throw an exception when there is no banner available on a channel
  • Loading branch information
TobiGr authored Aug 2, 2023
2 parents 39a911d + bb1ab16 commit 9a59afb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,10 @@ public String getBannerUrl() throws ParsingException {
))
.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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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;
Expand Down Expand Up @@ -720,7 +721,8 @@ public void testAvatarUrl() throws Exception {

@Test
public void testBannerUrl() throws Exception {
// CarouselHeaderRender does not contain a banner
// CarouselHeaderRenders do not contain a banner
assertNull(extractor.getBannerUrl());
}

@Test
Expand Down

0 comments on commit 9a59afb

Please sign in to comment.