Commit graph

612 commits

Author SHA1 Message Date
TiA4f8R
d55109258d
Fix YoutubeStreamExtractorAgeRestrictedTest 2021-08-01 12:39:03 +02:00
FireMasterK
2eeb0a3403
Rebase + some code improvements + fix extraction of age-restricted videos + update clients version
Here is now the requests which will be made by the `onFetchPage` method of `YoutubeStreamExtractor`:

- the desktop API is fetched.

If there is no streaming data, the desktop player API with the embed client screen will be fetched (and also the player code), then the Android mobile API.
- if there is no streaming data, a `ContentNotAvailableException` will be thrown by using the message provided in playability status

If the video is age restricted, a request to the next endpoint of the desktop player with the embed client screen will be sent.
Otherwise, the next endpoint will be fetched normally, if the content is available.

If the video is not age-restricted, a request to the player endpoint of the Android mobile API will be made.

We can get more streams by using the Android mobile API but some streams may be not available on this API, so the streaming data of the Android mobile API will be first used to get itags and then the streaming data of the desktop internal API will be used.
If the parsing of the Android mobile API went wrong, only the streams of the desktop API will be used.

Other code changes:

- `prepareJsonBuilder` in `YoutubeParsingHelper` was renamed to `prepareDesktopJsonBuilder`
- `prepareMobileJsonBuilder` in `YoutubeParsingHelper` was renamed to `prepareAndroidMobileJsonBuilder`
- two new methods in `YoutubeParsingHelper` were added: `prepareDesktopEmbedVideoJsonBuilder` and `prepareAndroidMobileEmbedVideoJsonBuilder`
- `createPlayerBodyWithSts` is now public and was moved to `YoutubeParsingHelper`
- a new method in `YoutubeJavaScriptExtractor` was added: `resetJavaScriptCode`, which was needed for the method `resetDebofuscationCode` of `YoutubeStreamExtractor`
- `areHardcodedClientVersionAndKeyValid` in `YoutubeParsingHelper` returns now a `boolean` instead of an `Optional<Boolean>`
- the `fetchVideoInfoPage` method of `YoutubeStreamExtractor` was removed because YouTube returns now 404 for every client with the `get_video_info` page
- some unused objects and some warnings in `YoutubeStreamExtractor` were removed and fixed

Co-authored-by: TiA4f8R <74829229+TiA4f8R@users.noreply.github.com>
2021-08-01 12:39:03 +02:00
TiA4f8R
7753556e66
Adress the last requested changes + update YoutubeCommentsExtractor mocks 2021-08-01 12:39:03 +02:00
TiA4f8R
2320aecb7c
Update mocks 2021-08-01 12:39:02 +02:00
TiA4f8R
629dcd63b2
Ignore some broken tests 2021-08-01 12:39:01 +02:00
TiA4f8R
27bd797f1e
Update mocks 2021-08-01 12:39:01 +02:00
TiA4f8R
609919db59
Adress again reviews, fix some rebase issues 2021-08-01 12:39:00 +02:00
TiA4f8R
4299d806a2
Adress changes 2021-08-01 12:38:59 +02:00
TiA4f8R
81013e5a8e
Add a static method to reset the YouTube deobfuscation code and use it in tests
This method is needed for YouTube stream tests, because when all YouTube tests are ran, the signatureTimestamp is known (the sts string) so a different body than the body present in the mocks is send by the extractor instance.
As a result, running all YouTube stream tests with the MockDownloader (like the CI does) will fail if this method is not called before fetching the page of a test.
2021-08-01 12:38:58 +02:00
TiA4f8R
632772d17f
Adress requested changes in YoutubeParsingHelper 2021-08-01 12:38:58 +02:00
TiA4f8R
657f165771
Update client version and mocks 2021-08-01 12:38:44 +02:00
TiA4f8R
6921e80ded
Try again to don't fetch at each time the JavaScript player 2021-08-01 12:38:42 +02:00
TiA4f8R
70927ddade
Update client version and mocks 2021-08-01 12:38:40 +02:00
TiA4f8R
7474049fd1
Update mocks 2021-08-01 12:38:39 +02:00
TiA4f8R
0f9e9b8b4b
Use the youtubei API for YouTube mixes + update the corresponding test + do some improvements
Use the youtubei API for YouTube mixes. The corresponding has been updated because the new API breaks the tests of YoutubeMixPlaylistExtractorTest.
Remove some deprecated code (the old search code with the pbj JSON) and do some other improvements.
2021-08-01 12:38:37 +02:00
TiA4f8R
3017dde67e
Fix some typos 2021-08-01 12:38:36 +02:00
TiA4f8R
effcdaa4f2
Update mocks, reenable a test and fix a test
This commit updates mocks and reenables the test invalidId of the NotAvailable class of the YoutubePlaylistExtractorTest class beacuse with the youtubei/innertube API, it returns "Not found" and doesn't redirect to the YouTube homepage.
The expectedMetaInfo test of the MetaInfoTest class of the YoutubeSearchExtractorTest class was broken because YouTube removes the vaccine progress link of the WHO from the meta info so this commit removes it and the test is now passing.
2021-08-01 12:38:04 +02:00
TiA4f8R
e075dd5a63
Update client version, fix some tests, update mocks and do some improvements
Add the origin and the referer headers with the https://www.youtube.com value for YouTube JSON POST requests.
Don't add the consent cookie header for the requests which use the youtubei/innertube API because it's uneeded.
Fix some tests and update YouTube mocks
2021-08-01 12:38:02 +02:00
TiA4f8R
991b2c7d73
Use lightweight requests when getting and checking YouTube API key and client version 2021-08-01 12:38:01 +02:00
TiA4f8R
9ab9c66ddf
Use the youtubei.googleapis.com domain for YouTube Music searches + change a check + update client version and mocks
Change the domain from music.youtube.com to youtubei.googleapis.com.
Use a lightweight request to check if the hardcoded YouTubeMusic keys are valid. Increase the length of the response to 500 because if the key is invalid, the length of the response returned is higher than 250 and the response when the key is valid is higher than 1500.
Format the YoutubeMusicSearchExtractor file.
Update YouTube web client version and mocks
2021-08-01 12:37:56 +02:00
TiA4f8R
77c031a88a
Use the youtubei API for YouTube trends 2021-08-01 12:36:28 +02:00
TiA4f8R
f461224b2b
Use the youtubei API for YouTube searches + update mocks
Add getSearchParameter, a new method in YoutubeSearchQueryHandlerFactory class which returns the params field for a search, or an empty string if there is no one.
Update mocks of YoutubeSearchExtractorTest.
2021-08-01 12:36:28 +02:00
TiA4f8R
a12c69da7d
Use the youtubei API for YouTube channels 2021-08-01 12:36:27 +02:00
Stypox
c97a19d719
Merge pull request #696 from XiangRongLin/decrypt_pattern
Expand regex to match n param decrypt function
2021-08-01 10:24:22 +02:00
FireMasterK
f4aad8b014
Fix tests again. 2021-07-31 14:40:51 +05:30
XiangRongLin
852a65ff18 Add tests for StringUtils 2021-07-30 19:56:57 +02:00
XiangRongLin
48d897e6ad Add final and adjust utils class name 2021-07-29 21:33:45 +02:00
XiangRongLin
1c78976900 [YouTube] Expand regex to match n param decrypt function
Temporary solution
2021-07-29 20:26:36 +02:00
TobiGr
79f2d74b04 Fix test
The decryption code changes over time. Only check whether the n parameter was changed in the URL
2021-07-28 16:45:31 +02:00
TiA4f8R
32055147e0 Do some code improvements
Use final where possible, annotate some methods and parameters as Nonnull and format new code to be in the 100 characters limit per line.
2021-07-27 17:24:27 +02:00
XiangRongLin
3a3d1d7f2b Make YoutubeJavaScriptExtractor and JavaScript methods static
Also address review and rewrite some comments
2021-07-20 20:48:11 +02:00
XiangRongLin
a02ee2e952 Rewrite youtube throttling solution and add tests 2021-07-17 19:10:09 +02:00
TobiGr
dbdc962a07 Update mocks 2021-07-03 13:30:26 +02:00
XiangRongLin
b9549ace25 [Youtube] Fix lofi girl test and ignore mix with id test 2021-06-29 21:12:20 +02:00
XiangRongLin
5982431ffb Remove IPv4 addresses from response during mock recording 2021-06-29 21:03:33 +02:00
c5e8bd368d Update Mocks 2021-06-23 12:21:57 +02:00
e9a992b0a9 [youtube] Fix extraction of age restricted videos 2021-06-23 12:06:02 +02:00
Tobi
d4186d100b
Merge pull request #580 from TeamNewPipe/accountTerminated
Add AccountTerminatedException for terminated channels
2021-06-08 09:55:58 +02:00
TobiGr
fa444c8298 Remove assertations of exception messages 2021-06-06 11:38:43 +02:00
XiangRongLin
faa503c7dd Fix PeertubeAccountExtractorTest 2021-06-03 19:54:42 +02:00
TiA4f8R
ac31f3a883
Specify UTF-8 file encoding in RecordingDownloader and MockDownloader
On Windows, mocks are recorded and read with the Cp1252 encoding so it breaks the mocks on non ASCII characters for Linux OS (and so the CI).
The project is in Java 8, so we can't use FileReader(File, Charset) and FileReader(File, Charset) because these methods require Java 11. Instead of changing the Java version of the extractor, use OutputStreamWriter and FileOutputStream instead of FileWriter and InputStreamReader and FileInputStream instead of FileReader.
2021-06-03 18:38:25 +02:00
ff11c2df2a
Merge pull request #628 from litetex/fix-broken-yt-liked-comments
Fix broken yt likes in comments
2021-05-29 11:04:11 +02:00
Tobi
519bba70b3
Merge pull request #630 from XiangRongLin/fix_tests
Fix MetaInfoTest.expectedMetaInfo
2021-05-28 14:16:53 +02:00
litetex
e81b0e2885 Tweaked code 2021-05-27 19:48:31 +02:00
litetex
8c96545e57 Merge branch 'TeamNewPipe:dev' into fix-broken-yt-liked-comments 2021-05-24 18:06:45 +02:00
litetex
12fb18c310 Updated mock data (only the affected) 2021-05-24 18:05:26 +02:00
litetex
020acfed71 Fixed tests and added new ones 2021-05-24 18:05:26 +02:00
litetex
86bb9efb5d Added likeCount back to tests 2021-05-24 18:05:25 +02:00
Tobi
636e27333b
Merge pull request #603 from TeamNewPipe/peertube_hls
Add PeerTube HLS streams
2021-05-23 11:49:40 +02:00
XiangRongLin
172394cd52 Update mocks 2021-05-22 20:33:20 +02:00
XiangRongLin
18c8cac40c Fix MetaInfoTest.expectedMetaInfo
Expected meta changed
2021-05-21 21:00:08 +02:00
litetex
10cf081145
Removed likeCount and added textualVoteCount 2021-05-20 20:10:14 +02:00
TobiGr
1acc53b8db [PeerTube] Add support for HLS streams 2021-05-15 12:39:23 +02:00
Tobi
3a3ade20f4
Merge pull request #620 from TeamNewPipe/bandcamp-comments
Add Bandcamp comments (first page)
2021-05-02 13:43:53 +02:00
Fynn Godau
85a4270bd9 [Bandcamp] Fix comments test 2021-05-02 13:07:24 +02:00
TobiGr
ec50570053 Add mocks 2021-05-01 17:50:19 +02:00
TobiGr
f4404b5cc8 Add tests for more reasons 2021-05-01 17:50:19 +02:00
TobiGr
fc998589dc Detect channels which have been terminated due to copyright infringement 2021-05-01 17:50:19 +02:00
TobiGr
bb3861ddce Add AccountTerminatedException for better error handling of terminated channels 2021-05-01 17:50:19 +02:00
Tobi
284362fc15
Merge pull request #608 from TeamNewPipe/youtube-fix-segment-test
[YouTube] fix tests
2021-05-01 17:24:41 +02:00
TobiGr
9c12dc5609 [SoundCloud] Fix SoundCloud ID extraction
resolveIdWithEmbedPlayer() does not work anymore because the JSON data has been extracted to an API call. For this reason, replace resolveIdWithEmbedPlayer() with resolveIdWithWidgetApi)( which performs the API call.
2021-04-26 17:58:34 +02:00
Fynn Godau
9dc7a1d5ee [Bandcamp] Add comments (first page) 2021-04-26 17:25:04 +02:00
Fynn Godau
90b5c00599 Extract related items #593 2021-04-13 17:56:19 +02:00
TobiGr
1fe645704f [YouTube] FIx testMoreRelatedItems in RandomQueryNoMorePages 2021-04-11 23:21:35 +02:00
TobiGr
9a2b814d8f Update mocks 2021-04-11 22:59:01 +02:00
TobiGr
50005ce937 [YouTube] Replace unavailable YouTube Stream Segments test
The stream is unavailable in many countries.
2021-04-11 22:58:48 +02:00
TobiGr
318cec7625 [Bandcamp] Add Radio stream segments 2021-04-11 21:19:44 +02:00
TobiGr
55e0f8e725 Merge branch 'master' into dev 2021-04-10 11:33:34 +02:00
TobiGr
b94b316558 Update mocks 2021-04-09 11:59:17 +02:00
TobiGr
4b8d4a84b6 Set the NumberGenerator for th remaining tests 2021-04-09 11:59:17 +02:00
XiangRongLin
db7ad9c27d Update Mocks 2021-04-08 16:37:29 +02:00
XiangRongLin
4833df60e5 Add method to inject Random into YoutubeParsingHelper and use in tests 2021-04-08 16:36:55 +02:00
TobiGr
682ec27737 Update mocks 2021-04-08 14:22:31 +02:00
TobiGr
4ee270fe01 Fix LiveStream Test 2021-04-07 14:11:41 +02:00
TobiGr
883f16e0ad [YouTube] Set CONSENT cookie 2021-04-07 14:11:37 +02:00
XiangRongLin
aee3838ed5 Ignore unreliable SoundcloudGoPlusTrack.testRelatedItems 2021-04-06 18:26:45 +02:00
XiangRongLin
7b06c696e2 Use Page.body for YoutubeChannelExtractor 2021-04-06 18:14:38 +02:00
XiangRongLin
eda1b6e199 Use Page.body for YoutubePlaylistExtractor 2021-04-06 18:14:38 +02:00
XiangRongLin
7b36469807 Fix SoundcloudGoPlusTrack
https://soundcloud.com/martinsolveig/places#t=0 has related streams
2021-04-04 09:39:26 +02:00
XiangRongLin
3d70b6d46a Fix a test and ignore rest 2021-04-03 11:03:10 +02:00
Fynn Godau
14f6f1b7c3 Generify related streams calls and rename method 2021-03-31 20:24:40 +02:00
Fynn Godau
dbcf61c6f7 [Bandcamp] Load more featured pages 2021-03-28 12:53:05 +02:00
Stypox
b4dee6d08f
Merge pull request #306 from B0pol/metadata
Extract metadata for youtube, soundcloud & mediaccc
2021-03-27 08:45:47 +01:00
TobiGr
b029779217 [media.cc.de] Disable unreliable tests for now 2021-03-25 19:44:44 +01:00
TiA4f8R
772de53a66
Increase the number of subscribers in PeertubeAccountExtractorTest 2021-03-25 17:49:20 +01:00
TiA4f8R
efe2b964f0
Extract real subscribers of a Peertube account
Apply fix provided in the PR and move all accounts/ strings to a constant, ACCOUNTS.
2021-03-25 17:47:44 +01:00
Tobi
12835bfae1
Merge pull request #551 from FireMasterK/ff-privacy
Change UA to privacy.resistFingerprinting.
2021-03-24 17:58:34 +01:00
XiangRongLin
9009f1e277
Merge pull request #517 from XiangRongLin/flaky_test
Add MockOnlyRule to allow skipping specific tests based on downloader
2021-03-20 18:04:14 +01:00
152221c7fb
ignore a test with encoding problems 2021-03-19 10:14:43 +01:00
8806fb4e6b
address reviews 2021-03-19 10:14:43 +01:00
c47cc54908
Extract metadata for YouTube, SoundCloud & MediaCCC 2021-03-19 10:14:43 +01:00
TiA4f8R
0e3e420a25
Fix tests 2021-03-14 17:54:21 +01:00
TiA4f8R
0438828e36
Add a test for the number of audioStreams in CreativeCommonsPlaysWellWithOthers test
It should be only two audio streams for track "Plays Well with Others, Ep 2: What Do an Army of Ants and an Online Encyclopedia Have in Common?" by Creative Commons (https://soundcloud.com/wearecc/plays-well-with-others-ep-2-what-do-an-army-of-ants-and-an-online-encyclopedia-have-in-common):
- one which is a progressive stream, in MP3 format with a bitrate of 128 kbps
- one which is an HLS stream, in OPUS format with a bitrate of 64 kbps.
2021-03-14 17:54:18 +01:00
Fynn Godau
2e57a8f24f [Bandcamp] Fix link handler acceptance behaviour
* Test for bandcamp footer instead of meta tag (which is not present on
  all pages)
* Accept links to /music, not just /releases
* Correctly handle uppercase URLs
2021-03-14 09:51:30 +01:00
TobiGr
70d9e389b9 [Bandcamp] Add tests for external bandcamp artists
Necessary, because the external pages tested before were converted to bandcamp.com pages. See f9d06252f2
2021-03-13 20:51:59 +01:00
TobiGr
f9d06252f2 [Bandcamp] Fix tests 2021-03-13 17:42:39 +01:00
Tobi
7e6f464407
Merge pull request #509 from TiA4f8R/soundcloud-improvements
Add new exceptions to be able to display different error messages in apps
2021-03-07 13:51:15 +01:00
Tobi
ac51134aed
Merge pull request #546 from XiangRongLin/unignore2
Unignore more tests
2021-03-07 13:15:24 +01:00
TobiGr
22fa131922 Merge branch 'dev' into bandcamp 2021-03-05 19:45:37 +01:00
TobiGr
22e6f33f0a
Ignore SoundCloudGeoRestrictedTest until HLS stream extraction is added
The ContentNotSupportedException is thrown because no supported audio streams where extracted. However, SoundCLoud does not check, whether there are any streams available. 
This commit should be reverted in #526
2021-03-05 16:38:47 +01:00