From b9d09414113eba7ceab6ccc1a17a3ba055d2b0b7 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Tue, 31 Oct 2017 14:10:52 +0100 Subject: [PATCH] fix N.pointer exception for getUploaderName() --- .../extractor/services/youtube/YoutubeStreamExtractor.java | 3 ++- .../extractor/services/youtube/YoutubeServiceTest.java | 2 +- .../services/youtube/YoutubeStreamExtractorDefaultTest.java | 6 ++++++ .../services/youtube/YoutubeStreamExtractorGemaTest.java | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractor.java b/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractor.java index 20f520fec..8dbb9ead3 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractor.java @@ -737,7 +737,8 @@ public class YoutubeStreamExtractor extends StreamExtractor { @Override public String getUploaderName() throws ParsingException { - return li.select("span.g-hovercard").first().text(); + return li.select("span[class*=\"attribution\"").first() + .select("span").first().text(); } @Override diff --git a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeServiceTest.java b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeServiceTest.java index 8e29eee6f..64b7538b7 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeServiceTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeServiceTest.java @@ -53,6 +53,6 @@ public class YoutubeServiceTest { @Test public void testGetDefaultKiosk() throws Exception { - assertEquals(kioskList.getDefaultKioskExtractor(null).getName(), "Trending"); + assertEquals(kioskList.getDefaultKioskExtractor(null).getId(), "Trending"); } } diff --git a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java index 44663611a..63dfaed03 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java @@ -140,6 +140,12 @@ public class YoutubeStreamExtractorDefaultTest { public void testGetRelatedVideos() throws ExtractionException, IOException { StreamInfoItemCollector relatedVideos = extractor.getRelatedVideos(); assertFalse(relatedVideos.getItemList().isEmpty()); + if(!relatedVideos.getErrors().isEmpty()) { + for(Throwable e : relatedVideos.getErrors()) { + e.printStackTrace(); + System.err.println("----------------------"); + } + } assertTrue(relatedVideos.getErrors().isEmpty()); } } diff --git a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorGemaTest.java b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorGemaTest.java index 7bc1d5873..1c64c8189 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorGemaTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorGemaTest.java @@ -36,10 +36,10 @@ import static org.schabi.newpipe.extractor.ServiceList.YouTube; *

* WARNING: Deactivate this Test Case before uploading it to Github, otherwise CI will fail. */ -@Ignore public class YoutubeStreamExtractorGemaTest { @Test + @Ignore public void testGemaError() throws IOException, ExtractionException { try { NewPipe.init(Downloader.getInstance());