Skip to content

Commit

Permalink
Merge pull request #1160 from TeamNewPipe/fix/tests
Browse files Browse the repository at this point in the history
Fix some failing unit tests and detect new account termination messages for YouTube
  • Loading branch information
TobiGr authored Mar 20, 2024
2 parents 896a55e + 51ddacc commit adcc1f1
Show file tree
Hide file tree
Showing 14 changed files with 73 additions and 135 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1620,8 +1620,10 @@ public static void defaultAlertsCheck(@Nonnull final JsonObject initialData)
final String alertText = getTextFromObject(alertRenderer.getObject("text"));
final String alertType = alertRenderer.getString("type", "");
if (alertType.equalsIgnoreCase("ERROR")) {
if (alertText != null && alertText.contains("This account has been terminated")) {
if (alertText.contains("violation") || alertText.contains("violating")
if (alertText != null
&& (alertText.contains("This account has been terminated")
|| alertText.contains("This channel was removed"))) {
if (alertText.matches(".*violat(ed|ion|ing).*")
|| alertText.contains("infringement")) {
// Possible error messages:
// "This account has been terminated for a violation of YouTube's Terms of
Expand All @@ -1643,6 +1645,7 @@ public static void defaultAlertsCheck(@Nonnull final JsonObject initialData)
// the user posted."
// "This account has been terminated because it is linked to an account that
// received multiple third-party claims of copyright infringement."
// "This channel was removed because it violated our Community Guidelines."
throw new AccountTerminatedException(alertText,
AccountTerminatedException.Reason.VIOLATION);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void testGetComments() throws IOException, ExtractionException {

@Test
void testGetCommentsFromCommentsInfo() throws IOException, ExtractionException {
final String comment = "Thanks for creating such an informative video";
final String comment = "Thanks for this nice video explanation of Peertube!";

final CommentsInfo commentsInfo =
CommentsInfo.getInfo("https://framatube.org/w/kkGMgK9ZtnKfYAgnEtQxbv");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void testGetLanguageInformation() throws ParsingException {
@Override public long expectedViewCountAtLeast() { return 38600; }
@Nullable @Override public String expectedUploadDate() { return "2018-10-01 10:52:46.396"; }
@Nullable @Override public String expectedTextualUploadDate() { return "2018-10-01T10:52:46.396Z"; }
@Override public long expectedLikeCountAtLeast() { return 50; }
@Override public long expectedLikeCountAtLeast() { return 20; }
@Override public long expectedDislikeCountAtLeast() { return 0; }
@Override public String expectedHost() { return "framatube.org"; }
@Override public String expectedCategory() { return "Science & Technology"; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ void testIsVerified() throws IOException, ExtractionException {
public static class NoNextPage extends DefaultSearchExtractorTest {

private static SearchExtractor extractor;
private static final String QUERY = "Dan at hor#berlgbd";
private static final String QUERY = "wpghüä";

@BeforeAll
public static void setUp() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
"same-origin; report-to\u003d\"youtube_main\""
],
"date": [
"Fri, 08 Dec 2023 19:37:57 GMT"
"Wed, 20 Mar 2024 13:58:42 GMT"
],
"expires": [
"Fri, 08 Dec 2023 19:37:57 GMT"
"Wed, 20 Mar 2024 13:58:42 GMT"
],
"origin-trial": [
"AvC9UlR6RDk2crliDsFl66RWLnTbHrDbp+DiY6AYz/PNQ4G4tdUTjrHYr2sghbkhGQAVxb7jaPTHpEVBz0uzQwkAAAB4eyJvcmlnaW4iOiJodHRwczovL3lvdXR1YmUuY29tOjQ0MyIsImZlYXR1cmUiOiJXZWJWaWV3WFJlcXVlc3RlZFdpdGhEZXByZWNhdGlvbiIsImV4cGlyeSI6MTcxOTUzMjc5OSwiaXNTdWJkb21haW4iOnRydWV9"
Expand All @@ -62,9 +62,8 @@
"ESF"
],
"set-cookie": [
"YSC\u003d45cg5Fq7qO4; Domain\u003d.youtube.com; Path\u003d/; Secure; HttpOnly; SameSite\u003dnone",
"VISITOR_INFO1_LIVE\u003d; Domain\u003d.youtube.com; Expires\u003dSat, 13-Mar-2021 19:37:57 GMT; Path\u003d/; Secure; HttpOnly; SameSite\u003dnone",
"CONSENT\u003dPENDING+095; expires\u003dSun, 07-Dec-2025 19:37:57 GMT; path\u003d/; domain\u003d.youtube.com; Secure"
"YSC\u003dLzBi9veM9G4; Domain\u003d.youtube.com; Path\u003d/; Secure; HttpOnly; SameSite\u003dnone",
"VISITOR_INFO1_LIVE\u003d; Domain\u003d.youtube.com; Expires\u003dThu, 24-Jun-2021 13:58:42 GMT; Path\u003d/; Secure; HttpOnly; SameSite\u003dnone"
],
"strict-transport-security": [
"max-age\u003d31536000"
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading

0 comments on commit adcc1f1

Please sign in to comment.