Skip to content

Commit fc99858

Browse files
committed
Detect channels which have been terminated due to copyright infringement
1 parent bb3861d commit fc99858

2 files changed

Lines changed: 42 additions & 4 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,10 +760,12 @@ public static void defaultAlertsCheck(final JsonObject initialData) throws Parsi
760760
final String alertType = alertRenderer.getString("type", EMPTY_STRING);
761761
if (alertType.equalsIgnoreCase("ERROR")) {
762762
if (alertText != null && alertText.contains("This account has been terminated")) {
763-
if (alertText.contains("violation") || alertText.contains("violating")) {
763+
if (alertText.contains("violation") || alertText.contains("violating")
764+
|| alertText.contains("infringement")) {
764765
// possible error messages:
765-
// "This account has been terminated for violating YouTube's Community Guidelines."
766766
// "This account has been terminated for a violation of YouTube's Terms of Service."
767+
// "This account has been terminated for violating YouTube's Community Guidelines."
768+
// "This account has been terminated because we received multiple third-party claims of copyright infringement regarding material that the user posted."
767769
throw new AccountTerminatedException(alertText, AccountTerminatedException.Reason.VIOLATION);
768770
} else {
769771
throw new AccountTerminatedException(alertText);

extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,47 @@ public void nonExistentFetch() throws Exception {
5353
}
5454

5555
@Test(expected = AccountTerminatedException.class)
56-
public void accountTerminatedFetch() throws Exception {
56+
public void accountTerminatedTOSFetch() throws Exception {
57+
final ChannelExtractor extractor =
58+
YouTube.getChannelExtractor("https://www.youtube.com/channel/UCTGjY2I-ZUGnwVoWAGRd7XQ");
59+
try {
60+
extractor.fetchPage();
61+
} catch (AccountTerminatedException e) {
62+
assertEquals(e.getMessage(),
63+
"This account has been terminated for a violation of YouTube's Terms of Service.");
64+
assertEquals(e.getReason(), AccountTerminatedException.Reason.VIOLATION);
65+
throw e;
66+
}
67+
}
68+
69+
@Test(expected = AccountTerminatedException.class)
70+
public void accountTerminatedCommunityFetch() throws Exception {
5771
final ChannelExtractor extractor =
5872
YouTube.getChannelExtractor("https://www.youtube.com/channel/UC0AuOxCr9TZ0TtEgL1zpIgA");
59-
extractor.fetchPage();
73+
try {
74+
extractor.fetchPage();
75+
} catch (AccountTerminatedException e) {
76+
assertEquals(e.getMessage(),
77+
"This account has been terminated for violating YouTube's Community Guidelines.");
78+
assertEquals(e.getReason(), AccountTerminatedException.Reason.VIOLATION);
79+
throw e;
80+
}
81+
}
82+
83+
@Test(expected = AccountTerminatedException.class)
84+
public void accountTerminatedCopyrightFetch() throws Exception {
85+
final ChannelExtractor extractor =
86+
YouTube.getChannelExtractor("https://www.youtube.com/channel/UCpExuV8qJMfCaSQNL1YG6bQ");
87+
try {
88+
extractor.fetchPage();
89+
} catch (AccountTerminatedException e) {
90+
assertEquals(e.getMessage(),
91+
"This account has been terminated because we received multiple third-party claims of copyright infringement regarding material that the user posted.");
92+
assertEquals(e.getReason(), AccountTerminatedException.Reason.VIOLATION);
93+
throw e;
94+
}
6095
}
96+
6197
}
6298

6399
public static class NotSupported {

0 commit comments

Comments
 (0)