Detect channels which have been terminated due to copyright infringement

This commit is contained in:
TobiGr 2021-03-23 00:15:21 +01:00
parent bb3861ddce
commit fc998589dc
2 changed files with 42 additions and 4 deletions

View File

@ -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);

View File

@ -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 {