|
1 | 1 | package org.schabi.newpipe.extractor.services.youtube; |
2 | 2 |
|
| 3 | +import com.grack.nanojson.JsonArray; |
| 4 | +import com.grack.nanojson.JsonObject; |
| 5 | +import com.grack.nanojson.JsonParser; |
3 | 6 | import org.junit.BeforeClass; |
4 | 7 | import org.junit.Test; |
5 | 8 | import org.schabi.newpipe.downloader.DownloaderFactory; |
6 | 9 | import org.schabi.newpipe.downloader.DownloaderTestImpl; |
| 10 | +import org.schabi.newpipe.extractor.Extractor; |
7 | 11 | import org.schabi.newpipe.extractor.NewPipe; |
8 | 12 | import org.schabi.newpipe.extractor.channel.ChannelExtractor; |
9 | 13 | import org.schabi.newpipe.extractor.exceptions.AccountTerminatedException; |
|
12 | 16 | import org.schabi.newpipe.extractor.exceptions.ParsingException; |
13 | 17 | import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest; |
14 | 18 | import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeChannelExtractor; |
| 19 | +import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeChannelLinkHandlerFactory; |
15 | 20 |
|
16 | 21 | import java.io.IOException; |
17 | 22 | import java.util.Random; |
@@ -80,6 +85,48 @@ public void accountTerminatedCommunityFetch() throws Exception { |
80 | 85 | } |
81 | 86 | } |
82 | 87 |
|
| 88 | + @Test(expected = AccountTerminatedException.class) |
| 89 | + public void accountTerminatedHateFetch() throws Exception { |
| 90 | + final ChannelExtractor extractor = |
| 91 | + YouTube.getChannelExtractor("https://www.youtube.com/channel/UCPWXIOPK-9myzek6jHR5yrg"); |
| 92 | + try { |
| 93 | + extractor.fetchPage(); |
| 94 | + } catch (AccountTerminatedException e) { |
| 95 | + assertTrue(e.getMessage().contains( |
| 96 | + "This account has been terminated due to multiple or severe violations of YouTube's policy prohibiting hate speech.")); |
| 97 | + assertEquals(e.getReason(), AccountTerminatedException.Reason.VIOLATION); |
| 98 | + throw e; |
| 99 | + } |
| 100 | + } |
| 101 | + |
| 102 | + @Test(expected = AccountTerminatedException.class) |
| 103 | + public void accountTerminatedBullyFetch() throws Exception { |
| 104 | + final ChannelExtractor extractor = |
| 105 | + YouTube.getChannelExtractor("https://youtube.com/channel/UCB1o7_gbFp2PLsamWxFenBg"); |
| 106 | + try { |
| 107 | + extractor.fetchPage(); |
| 108 | + } catch (AccountTerminatedException e) { |
| 109 | + assertEquals(e.getMessage(), |
| 110 | + "This account has been terminated due to multiple or severe violations of YouTube's policy prohibiting content designed to harass, bully or threaten."); |
| 111 | + assertEquals(e.getReason(), AccountTerminatedException.Reason.VIOLATION); |
| 112 | + throw e; |
| 113 | + } |
| 114 | + } |
| 115 | + |
| 116 | + @Test(expected = AccountTerminatedException.class) |
| 117 | + public void accountTerminatedSpamFetch() throws Exception { |
| 118 | + final ChannelExtractor extractor = |
| 119 | + YouTube.getChannelExtractor("https://www.youtube.com/channel/UCoaO4U_p7G7AwalqSbGCZOA"); |
| 120 | + try { |
| 121 | + extractor.fetchPage(); |
| 122 | + } catch (AccountTerminatedException e) { |
| 123 | + assertEquals(e.getMessage(), |
| 124 | + "This account has been terminated due to multiple or severe violations of YouTube's policy against spam, deceptive practices and misleading content or other Terms of Service violations."); |
| 125 | + assertEquals(e.getReason(), AccountTerminatedException.Reason.VIOLATION); |
| 126 | + throw e; |
| 127 | + } |
| 128 | + } |
| 129 | + |
83 | 130 | @Test(expected = AccountTerminatedException.class) |
84 | 131 | public void accountTerminatedCopyrightFetch() throws Exception { |
85 | 132 | final ChannelExtractor extractor = |
|
0 commit comments