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:
commit
9a59afbcf5
|
@ -282,7 +282,10 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
||||||
))
|
))
|
||||||
.filter(url -> !url.contains("s.ytimg.com") && !url.contains("default_banner"))
|
.filter(url -> !url.contains("s.ytimg.com") && !url.contains("default_banner"))
|
||||||
.map(YoutubeParsingHelper::fixThumbnailUrl)
|
.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
|
@Override
|
||||||
|
|
|
@ -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.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
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.assertThrows;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
@ -720,7 +721,8 @@ public class YoutubeChannelExtractorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBannerUrl() throws Exception {
|
public void testBannerUrl() throws Exception {
|
||||||
// CarouselHeaderRender does not contain a banner
|
// CarouselHeaderRenders do not contain a banner
|
||||||
|
assertNull(extractor.getBannerUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue