-
Notifications
You must be signed in to change notification settings - Fork 431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing up tests and the bugs they exposed #871
Changes from all commits
daaae54
f0ed685
68dee91
0039ee8
590ab6b
0b0f59b
f009705
a1b6d9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.DISABLE_PRETTY_PRINT_PARAMETER; | ||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.YOUTUBEI_V1_URL; | ||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.addClientInfoHeaders; | ||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.addYouTubeHeaders; | ||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.extractCookieValue; | ||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.extractPlaylistTypeFromPlaylistId; | ||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getKey; | ||
|
@@ -89,7 +89,7 @@ public void onFetchPage(@Nonnull final Downloader downloader) | |
final byte[] body = JsonWriter.string(jsonBody.done()).getBytes(StandardCharsets.UTF_8); | ||
|
||
final Map<String, List<String>> headers = new HashMap<>(); | ||
addClientInfoHeaders(headers); | ||
addYouTubeHeaders(headers); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above. |
||
|
||
final Response response = getDownloader().post(YOUTUBEI_V1_URL + "next?key=" + getKey() | ||
+ DISABLE_PRETTY_PRINT_PARAMETER, headers, body, localization); | ||
|
@@ -212,7 +212,7 @@ public InfoItemsPage<StreamInfoItem> getPage(final Page page) throws IOException | |
|
||
final StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId()); | ||
final Map<String, List<String>> headers = new HashMap<>(); | ||
addClientInfoHeaders(headers); | ||
addYouTubeHeaders(headers); | ||
|
||
final Response response = getDownloader().post(page.getUrl(), headers, page.getBody(), | ||
getExtractorLocalization()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -407,14 +407,6 @@ public static void setUp() throws Exception { | |
@Nullable @Override public String expectedTextualUploadDate() { return "2019-06-12"; } | ||
@Override public long expectedLikeCountAtLeast() { return 70000; } | ||
@Override public long expectedDislikeCountAtLeast() { return -1; } | ||
@Override public List<MetaInfo> expectedMetaInfo() throws MalformedURLException { | ||
return Collections.singletonList(new MetaInfo( | ||
EMPTY_STRING, | ||
new Description("Funk is a German public broadcast service.", Description.PLAIN_TEXT), | ||
Collections.singletonList(new URL("https://de.wikipedia.org/wiki/Funk_(Medienangebot)?wprov=yicw1")), | ||
Collections.singletonList("Wikipedia (German)") | ||
)); | ||
} | ||
Comment on lines
-410
to
-417
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As the goal of this test is to test if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No other tests in this file seem to be overriding |
||
@Override public boolean expectedUploaderVerified() { return true; } | ||
@Override public String expectedLicence() { return YOUTUBE_LICENCE; } | ||
@Override public String expectedCategory() { return "Education"; } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
|
||
public class YoutubeStreamExtractorLivestreamTest extends DefaultStreamExtractorTest { | ||
private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/youtube/extractor/stream/"; | ||
private static final String ID = "5qap5aO4i9A"; | ||
private static final String ID = "jfKfPfyJRdk"; | ||
private static final int TIMESTAMP = 1737; | ||
private static final String URL = YoutubeStreamExtractorDefaultTest.BASE_URL + ID + "&t=" + TIMESTAMP; | ||
private static StreamExtractor extractor; | ||
|
@@ -57,9 +57,9 @@ public void testUploaderName() throws Exception { | |
@Override public long expectedLength() { return 0; } | ||
@Override public long expectedTimestamp() { return TIMESTAMP; } | ||
@Override public long expectedViewCountAtLeast() { return 0; } | ||
@Nullable @Override public String expectedUploadDate() { return "2020-02-22 00:00:00.000"; } | ||
@Nullable @Override public String expectedTextualUploadDate() { return "2020-02-22"; } | ||
@Override public long expectedLikeCountAtLeast() { return 825000; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They've replaced the stream that was referenced by the test previously. Tests against live streams seem rather fragile -- do we have a better approach to this? Just testing against mocks? |
||
@Nullable @Override public String expectedUploadDate() { return "2020-07-12 00:00:00.000"; } | ||
@Nullable @Override public String expectedTextualUploadDate() { return "2020-07-12"; } | ||
@Override public long expectedLikeCountAtLeast() { return 280_000; } | ||
@Override public long expectedDislikeCountAtLeast() { return -1; } | ||
@Override public boolean expectedHasSubtitles() { return false; } | ||
@Nullable @Override public String expectedDashMpdUrlContains() { return "https://manifest.googlevideo.com/api/manifest/dash/"; } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to address #820
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, do not change this at all. By using
YES+
, you allow Google to track usage of users and so to establish profiles based on what they search, they browse and they watch, using the YouTube requests made by the extractor. The NewPipe projects aim to protect as much as possible users' privacy, so we will not accept this change globally.Instead, allow only the ability to set the
YES+
cookie inYoutubeMixPlaylistExtractor
, but disable it by default. That's I wanted to do in a future PR (because I wanted #863 to be merged first, but I have some changes to do in it first). Based on the changes of this PR inYoutubeMixPlaylistExtractor
, you can find what I did here: https://github.com/AudricV/NewPipeExtractor/commits/consent-cookie-yes%2B-for-yt-mixes-option.If you want to apply them, you can reuse (partially or not) my changes, but do not add the
Content-Length
header in the requests like I did (see #863 (comment) to know why I say this).Then enable usage of this cookie value in test classes of
YoutubeMixPlaylistExtractorTest
, for each test (like I did).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to apply these changes, although if we only use the
YES+
cookie in tests, would that mean the mix extractor won't work for users in the EU?Btw, any clue how I can test this extractor in NewPipe app? 😅
I've tried searching for playlists, but none of them seem to be youtube mixes.