diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java index 522e641d..9a9adf8b 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java @@ -760,10 +760,12 @@ public class YoutubeParsingHelper { final String alertType = alertRenderer.getString("type", EMPTY_STRING); if (alertType.equalsIgnoreCase("ERROR")) { if (alertText != null && alertText.contains("This account has been terminated")) { - if (alertText.contains("violation") || alertText.contains("violating")) { + if (alertText.contains("violation") || alertText.contains("violating") + || alertText.contains("infringement")) { // possible error messages: - // "This account has been terminated for violating YouTube's Community Guidelines." // "This account has been terminated for a violation of YouTube's Terms of Service." + // "This account has been terminated for violating YouTube's Community Guidelines." + // "This account has been terminated because we received multiple third-party claims of copyright infringement regarding material that the user posted." throw new AccountTerminatedException(alertText, AccountTerminatedException.Reason.VIOLATION); } else { throw new AccountTerminatedException(alertText); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java index e04a29fb..a99a0429 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java @@ -53,11 +53,47 @@ public class YoutubeChannelExtractorTest { } @Test(expected = AccountTerminatedException.class) - public void accountTerminatedFetch() throws Exception { + public void accountTerminatedTOSFetch() throws Exception { + final ChannelExtractor extractor = + YouTube.getChannelExtractor("https://www.youtube.com/channel/UCTGjY2I-ZUGnwVoWAGRd7XQ"); + try { + extractor.fetchPage(); + } catch (AccountTerminatedException e) { + assertEquals(e.getMessage(), + "This account has been terminated for a violation of YouTube's Terms of Service."); + assertEquals(e.getReason(), AccountTerminatedException.Reason.VIOLATION); + throw e; + } + } + + @Test(expected = AccountTerminatedException.class) + public void accountTerminatedCommunityFetch() throws Exception { final ChannelExtractor extractor = YouTube.getChannelExtractor("https://www.youtube.com/channel/UC0AuOxCr9TZ0TtEgL1zpIgA"); - extractor.fetchPage(); + try { + extractor.fetchPage(); + } catch (AccountTerminatedException e) { + assertEquals(e.getMessage(), + "This account has been terminated for violating YouTube's Community Guidelines."); + assertEquals(e.getReason(), AccountTerminatedException.Reason.VIOLATION); + throw e; + } } + + @Test(expected = AccountTerminatedException.class) + public void accountTerminatedCopyrightFetch() throws Exception { + final ChannelExtractor extractor = + YouTube.getChannelExtractor("https://www.youtube.com/channel/UCpExuV8qJMfCaSQNL1YG6bQ"); + try { + extractor.fetchPage(); + } catch (AccountTerminatedException e) { + assertEquals(e.getMessage(), + "This account has been terminated because we received multiple third-party claims of copyright infringement regarding material that the user posted."); + assertEquals(e.getReason(), AccountTerminatedException.Reason.VIOLATION); + throw e; + } + } + } public static class NotSupported {