Merge pull request #1160 from TeamNewPipe/fix/tests

Fix some failing unit tests and detect new account termination messages for YouTube
This commit is contained in:
Tobi 2024-03-20 15:17:55 +01:00 committed by GitHub
commit adcc1f17ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 73 additions and 135 deletions

View File

@ -1620,8 +1620,10 @@ public final class YoutubeParsingHelper {
final String alertText = getTextFromObject(alertRenderer.getObject("text")); final String alertText = getTextFromObject(alertRenderer.getObject("text"));
final String alertType = alertRenderer.getString("type", ""); final String alertType = alertRenderer.getString("type", "");
if (alertType.equalsIgnoreCase("ERROR")) { if (alertType.equalsIgnoreCase("ERROR")) {
if (alertText != null && alertText.contains("This account has been terminated")) { if (alertText != null
if (alertText.contains("violation") || alertText.contains("violating") && (alertText.contains("This account has been terminated")
|| alertText.contains("This channel was removed"))) {
if (alertText.matches(".*violat(ed|ion|ing).*")
|| alertText.contains("infringement")) { || alertText.contains("infringement")) {
// Possible error messages: // Possible error messages:
// "This account has been terminated for a violation of YouTube's Terms of // "This account has been terminated for a violation of YouTube's Terms of
@ -1643,6 +1645,7 @@ public final class YoutubeParsingHelper {
// the user posted." // the user posted."
// "This account has been terminated because it is linked to an account that // "This account has been terminated because it is linked to an account that
// received multiple third-party claims of copyright infringement." // received multiple third-party claims of copyright infringement."
// "This channel was removed because it violated our Community Guidelines."
throw new AccountTerminatedException(alertText, throw new AccountTerminatedException(alertText,
AccountTerminatedException.Reason.VIOLATION); AccountTerminatedException.Reason.VIOLATION);
} else { } else {

View File

@ -48,7 +48,7 @@ public class PeertubeCommentsExtractorTest {
@Test @Test
void testGetCommentsFromCommentsInfo() throws IOException, ExtractionException { 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 = final CommentsInfo commentsInfo =
CommentsInfo.getInfo("https://framatube.org/w/kkGMgK9ZtnKfYAgnEtQxbv"); CommentsInfo.getInfo("https://framatube.org/w/kkGMgK9ZtnKfYAgnEtQxbv");

View File

@ -86,7 +86,7 @@ public abstract class PeertubeStreamExtractorTest extends DefaultStreamExtractor
@Override public long expectedViewCountAtLeast() { return 38600; } @Override public long expectedViewCountAtLeast() { return 38600; }
@Nullable @Override public String expectedUploadDate() { return "2018-10-01 10:52:46.396"; } @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"; } @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 long expectedDislikeCountAtLeast() { return 0; }
@Override public String expectedHost() { return "framatube.org"; } @Override public String expectedHost() { return "framatube.org"; }
@Override public String expectedCategory() { return "Science & Technology"; } @Override public String expectedCategory() { return "Science & Technology"; }

View File

@ -186,7 +186,7 @@ public class SoundcloudSearchExtractorTest {
public static class NoNextPage extends DefaultSearchExtractorTest { public static class NoNextPage extends DefaultSearchExtractorTest {
private static SearchExtractor extractor; private static SearchExtractor extractor;
private static final String QUERY = "Dan at hor#berlgbd"; private static final String QUERY = "wpghüä";
@BeforeAll @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {

View File

@ -41,10 +41,10 @@
"same-origin; report-to\u003d\"youtube_main\"" "same-origin; report-to\u003d\"youtube_main\""
], ],
"date": [ "date": [
"Fri, 08 Dec 2023 19:37:57 GMT" "Wed, 20 Mar 2024 13:58:42 GMT"
], ],
"expires": [ "expires": [
"Fri, 08 Dec 2023 19:37:57 GMT" "Wed, 20 Mar 2024 13:58:42 GMT"
], ],
"origin-trial": [ "origin-trial": [
"AvC9UlR6RDk2crliDsFl66RWLnTbHrDbp+DiY6AYz/PNQ4G4tdUTjrHYr2sghbkhGQAVxb7jaPTHpEVBz0uzQwkAAAB4eyJvcmlnaW4iOiJodHRwczovL3lvdXR1YmUuY29tOjQ0MyIsImZlYXR1cmUiOiJXZWJWaWV3WFJlcXVlc3RlZFdpdGhEZXByZWNhdGlvbiIsImV4cGlyeSI6MTcxOTUzMjc5OSwiaXNTdWJkb21haW4iOnRydWV9" "AvC9UlR6RDk2crliDsFl66RWLnTbHrDbp+DiY6AYz/PNQ4G4tdUTjrHYr2sghbkhGQAVxb7jaPTHpEVBz0uzQwkAAAB4eyJvcmlnaW4iOiJodHRwczovL3lvdXR1YmUuY29tOjQ0MyIsImZlYXR1cmUiOiJXZWJWaWV3WFJlcXVlc3RlZFdpdGhEZXByZWNhdGlvbiIsImV4cGlyeSI6MTcxOTUzMjc5OSwiaXNTdWJkb21haW4iOnRydWV9"
@ -62,9 +62,8 @@
"ESF" "ESF"
], ],
"set-cookie": [ "set-cookie": [
"YSC\u003d45cg5Fq7qO4; Domain\u003d.youtube.com; Path\u003d/; Secure; HttpOnly; SameSite\u003dnone", "YSC\u003dLzBi9veM9G4; 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", "VISITOR_INFO1_LIVE\u003d; Domain\u003d.youtube.com; Expires\u003dThu, 24-Jun-2021 13:58:42 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"
], ],
"strict-transport-security": [ "strict-transport-security": [
"max-age\u003d31536000" "max-age\u003d31536000"

View File

@ -13,7 +13,7 @@
"SOCS\u003dCAE\u003d" "SOCS\u003dCAE\u003d"
], ],
"X-YouTube-Client-Version": [ "X-YouTube-Client-Version": [
"2.20231208.01.00" "2.20240313.05.00"
], ],
"X-YouTube-Client-Name": [ "X-YouTube-Client-Name": [
"1" "1"
@ -254,14 +254,14 @@
50, 50,
48, 48,
50, 50,
52,
48,
51, 51,
49, 49,
50, 51,
48,
56,
46, 46,
48, 48,
49, 53,
46, 46,
48, 48,
48, 48,
@ -376,7 +376,7 @@
"application/json; charset\u003dUTF-8" "application/json; charset\u003dUTF-8"
], ],
"date": [ "date": [
"Fri, 08 Dec 2023 19:37:58 GMT" "Wed, 20 Mar 2024 13:58:43 GMT"
], ],
"server": [ "server": [
"scaffolding on HTTPServer2" "scaffolding on HTTPServer2"