|
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; |
6 | 3 | import org.junit.BeforeClass; |
7 | 4 | import org.junit.Test; |
8 | 5 | import org.schabi.newpipe.downloader.DownloaderFactory; |
9 | 6 | import org.schabi.newpipe.downloader.DownloaderTestImpl; |
10 | | -import org.schabi.newpipe.extractor.Extractor; |
11 | 7 | import org.schabi.newpipe.extractor.NewPipe; |
12 | 8 | import org.schabi.newpipe.extractor.channel.ChannelExtractor; |
13 | 9 | import org.schabi.newpipe.extractor.exceptions.AccountTerminatedException; |
|
16 | 12 | import org.schabi.newpipe.extractor.exceptions.ParsingException; |
17 | 13 | import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest; |
18 | 14 | import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeChannelExtractor; |
19 | | -import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeChannelLinkHandlerFactory; |
20 | 15 |
|
21 | 16 | import java.io.IOException; |
22 | 17 | import java.util.Random; |
@@ -59,83 +54,82 @@ public void nonExistentFetch() throws Exception { |
59 | 54 |
|
60 | 55 | @Test(expected = AccountTerminatedException.class) |
61 | 56 | public void accountTerminatedTOSFetch() throws Exception { |
| 57 | + // "This account has been terminated for a violation of YouTube's Terms of Service." |
62 | 58 | final ChannelExtractor extractor = |
63 | 59 | YouTube.getChannelExtractor("https://www.youtube.com/channel/UCTGjY2I-ZUGnwVoWAGRd7XQ"); |
64 | 60 | try { |
65 | 61 | extractor.fetchPage(); |
66 | 62 | } catch (AccountTerminatedException e) { |
67 | | - assertEquals(e.getMessage(), |
68 | | - "This account has been terminated for a violation of YouTube's Terms of Service."); |
69 | 63 | assertEquals(e.getReason(), AccountTerminatedException.Reason.VIOLATION); |
70 | 64 | throw e; |
71 | 65 | } |
72 | 66 | } |
73 | 67 |
|
74 | 68 | @Test(expected = AccountTerminatedException.class) |
75 | 69 | public void accountTerminatedCommunityFetch() throws Exception { |
| 70 | + // "This account has been terminated for violating YouTube's Community Guidelines." |
76 | 71 | final ChannelExtractor extractor = |
77 | 72 | YouTube.getChannelExtractor("https://www.youtube.com/channel/UC0AuOxCr9TZ0TtEgL1zpIgA"); |
78 | 73 | try { |
79 | 74 | extractor.fetchPage(); |
80 | 75 | } catch (AccountTerminatedException e) { |
81 | | - assertEquals(e.getMessage(), |
82 | | - "This account has been terminated for violating YouTube's Community Guidelines."); |
83 | 76 | assertEquals(e.getReason(), AccountTerminatedException.Reason.VIOLATION); |
84 | 77 | throw e; |
85 | 78 | } |
86 | 79 | } |
87 | 80 |
|
88 | 81 | @Test(expected = AccountTerminatedException.class) |
89 | 82 | public void accountTerminatedHateFetch() throws Exception { |
| 83 | + // "This account has been terminated due to multiple or severe violations |
| 84 | + // of YouTube's policy prohibiting hate speech." |
90 | 85 | final ChannelExtractor extractor = |
91 | 86 | YouTube.getChannelExtractor("https://www.youtube.com/channel/UCPWXIOPK-9myzek6jHR5yrg"); |
92 | 87 | try { |
93 | 88 | extractor.fetchPage(); |
94 | 89 | } 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 | 90 | assertEquals(e.getReason(), AccountTerminatedException.Reason.VIOLATION); |
98 | 91 | throw e; |
99 | 92 | } |
100 | 93 | } |
101 | 94 |
|
102 | 95 | @Test(expected = AccountTerminatedException.class) |
103 | 96 | public void accountTerminatedBullyFetch() throws Exception { |
| 97 | + // "This account has been terminated due to multiple or severe violations |
| 98 | + // of YouTube's policy prohibiting content designed to harass, bully or threaten." |
104 | 99 | final ChannelExtractor extractor = |
105 | 100 | YouTube.getChannelExtractor("https://youtube.com/channel/UCB1o7_gbFp2PLsamWxFenBg"); |
106 | 101 | try { |
107 | 102 | extractor.fetchPage(); |
108 | 103 | } 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 | 104 | assertEquals(e.getReason(), AccountTerminatedException.Reason.VIOLATION); |
112 | 105 | throw e; |
113 | 106 | } |
114 | 107 | } |
115 | 108 |
|
116 | 109 | @Test(expected = AccountTerminatedException.class) |
117 | 110 | public void accountTerminatedSpamFetch() throws Exception { |
| 111 | + // "This account has been terminated due to multiple or severe violations |
| 112 | + // of YouTube's policy against spam, deceptive practices and misleading content |
| 113 | + // or other Terms of Service violations." |
118 | 114 | final ChannelExtractor extractor = |
119 | 115 | YouTube.getChannelExtractor("https://www.youtube.com/channel/UCoaO4U_p7G7AwalqSbGCZOA"); |
120 | 116 | try { |
121 | 117 | extractor.fetchPage(); |
122 | 118 | } 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 | 119 | assertEquals(e.getReason(), AccountTerminatedException.Reason.VIOLATION); |
126 | 120 | throw e; |
127 | 121 | } |
128 | 122 | } |
129 | 123 |
|
130 | 124 | @Test(expected = AccountTerminatedException.class) |
131 | 125 | public void accountTerminatedCopyrightFetch() throws Exception { |
| 126 | + // "This account has been terminated because we received multiple third-party claims |
| 127 | + // of copyright infringement regarding material that the user posted." |
132 | 128 | final ChannelExtractor extractor = |
133 | 129 | YouTube.getChannelExtractor("https://www.youtube.com/channel/UCpExuV8qJMfCaSQNL1YG6bQ"); |
134 | 130 | try { |
135 | 131 | extractor.fetchPage(); |
136 | 132 | } catch (AccountTerminatedException e) { |
137 | | - assertEquals(e.getMessage(), |
138 | | - "This account has been terminated because we received multiple third-party claims of copyright infringement regarding material that the user posted."); |
139 | 133 | assertEquals(e.getReason(), AccountTerminatedException.Reason.VIOLATION); |
140 | 134 | throw e; |
141 | 135 | } |
|
0 commit comments