Skip to content
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

[YouTube] Use the new internal API in NewPipe Extractor #604

Merged
merged 55 commits into from
Aug 3, 2021

Commits on Aug 1, 2021

  1. Configuration menu
    Copy the full SHA
    5794eb2 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a12c69d View commit details
    Browse the repository at this point in the history
  3. 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.
    AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    f461224 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    77c031a View commit details
    Browse the repository at this point in the history
  5. Use the youtubei.googleapis.com domain for YouTube Music searches + c…

    …hange 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
    AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    9ab9c66 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    991b2c7 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    58ce9b0 View commit details
    Browse the repository at this point in the history
  8. Do some improvements to YoutubeStreamExtractor

    Get the real name of the uploader (for autogenerated channels and music artist channels), like before the migration to the JSON pbj.
    Do some other improvements, especially reformatting some code to be in the 100 characters line limit and use final where possible.
    AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    b49ae54 View commit details
    Browse the repository at this point in the history
  9. Update client version, fix some tests, update mocks and do some impro…

    …vements
    
    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
    AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    e075dd5 View commit details
    Browse the repository at this point in the history
  10. Adress reviews and do some improvements

    Adress changes requested in reviews.
    Do some improvements, remove unused imports and format some code to be in the 100 characters line limit.
    AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    f46cfb0 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    4d68283 View commit details
    Browse the repository at this point in the history
  12. 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.
    AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    effcdaa View commit details
    Browse the repository at this point in the history
  13. Don't use the youtubei.googleapis.com but the websites domains + upda…

    …te client version of the desktop internal API
    
    Use again www.youtube.com and music.youtube.com domains instead of youtubei.googleapis.com domain because it spoofs more a web client of YouTube or YouTube Music and may reduce Google's detection of NewPipe Extractor users.
    AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    f73c923 View commit details
    Browse the repository at this point in the history
  14. Use the youtubei API for YouTube videos + update client version

    Update the hardcoded client version to 2.20210520.09.00
    Use the player and next endpoints of the Innertube API for YouTube videos
    AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    e7d589e View commit details
    Browse the repository at this point in the history
  15. Use the Android mobile API when there are OTF streams or the content …

    …is protected by signatureCiphers
    
    Use the Android mobile API to get the itag 22 (720p with audio), removed when the content is protected by signatureCiphers.
    Also use this API when they are OTF streams, to get the itag 17 and 36, low 3GPP quality streams but also the itag 139.
    Update the web client version.
    AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    013b902 View commit details
    Browse the repository at this point in the history
  16. Fix some typos

    AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    3017dde View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    14569c4 View commit details
    Browse the repository at this point in the history
  18. Use the youtubei API for YouTube mixes + update the corresponding tes…

    …t + 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.
    AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    0f9e9b8 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    ae5abc0 View commit details
    Browse the repository at this point in the history
  20. Fix the fetch of the playerCode at each time getStsFromPlayerJs is ca…

    …lled
    
    storePlayerJs was called even if sts was not empty in the getStsFromPlayerJs method. This commit fixes it.
    AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    b52732a View commit details
    Browse the repository at this point in the history
  21. Try to don't fetch again the first page when requesting a channel con…

    …tinuation
    
    Try to don't fetch again the first page of a YouTube channel when requesting a continuation of it by trying to store the channel name and the channel id into the next page using the ids field of the Page class.
    AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    c32bc6e View commit details
    Browse the repository at this point in the history
  22. Update mocks

    AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    7474049 View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    947baec View commit details
    Browse the repository at this point in the history
  24. Readd the deleted code of views because watching count of livestreams…

    … was broken
    
    The number shown was the total number of views that a livestream has. In order to fix this bug, the previous code is readded.
    AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    318bc46 View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    70927dd View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    6921e80 View commit details
    Browse the repository at this point in the history
  27. Catch every exception instead of only IOException and ExtractionExcep…

    …tion and add a Javadoc
    
    Catch every exception instead of only IOException and ExtractionException.
    Add JavaDoc for fetchAndroidMobileJsonPlayer method of YoutubeStreamExtractor
    AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    a59c2a3 View commit details
    Browse the repository at this point in the history
  28. Configuration menu
    Copy the full SHA
    54d4551 View commit details
    Browse the repository at this point in the history
  29. Adress requested changes

    AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    34a9ccb View commit details
    Browse the repository at this point in the history
  30. Configuration menu
    Copy the full SHA
    e97a685 View commit details
    Browse the repository at this point in the history
  31. Real fix of the fetch of the JS player at each the signatureTimestamp…

    … is required
    
    The strings playerJsUrl, sts and playerCode are now static in order to don't fetch again the JavaScript player at each time the signatureTimestamp is needed.
    AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    8c1c728 View commit details
    Browse the repository at this point in the history
  32. Configuration menu
    Copy the full SHA
    657f165 View commit details
    Browse the repository at this point in the history
  33. Configuration menu
    Copy the full SHA
    632772d View commit details
    Browse the repository at this point in the history
  34. Configuration menu
    Copy the full SHA
    accd5dd View commit details
    Browse the repository at this point in the history
  35. Configuration menu
    Copy the full SHA
    cc79852 View commit details
    Browse the repository at this point in the history
  36. Add a static method to reset the YouTube deobfuscation code and use i…

    …t 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.
    AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    81013e5 View commit details
    Browse the repository at this point in the history
  37. Revert the use of Collections.singletonList instead of Arrays.asList …

    …in addCookieHeader of YoutubeParsingHelper
    AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    a6a2c6e View commit details
    Browse the repository at this point in the history
  38. Configuration menu
    Copy the full SHA
    d8177b5 View commit details
    Browse the repository at this point in the history
  39. Configuration menu
    Copy the full SHA
    1a6b8da View commit details
    Browse the repository at this point in the history
  40. Adress changes

    AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    4299d80 View commit details
    Browse the repository at this point in the history
  41. Configuration menu
    Copy the full SHA
    609919d View commit details
    Browse the repository at this point in the history
  42. Update mocks

    AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    27bd797 View commit details
    Browse the repository at this point in the history
  43. Update clients version

    AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    8aa60d7 View commit details
    Browse the repository at this point in the history
  44. Configuration menu
    Copy the full SHA
    3adac6a View commit details
    Browse the repository at this point in the history
  45. Ignore some broken tests

    AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    629dcd6 View commit details
    Browse the repository at this point in the history
  46. Update mocks

    AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    2320aec View commit details
    Browse the repository at this point in the history
  47. Configuration menu
    Copy the full SHA
    7753556 View commit details
    Browse the repository at this point in the history
  48. Rebase + some code improvements + fix extraction of age-restricted vi…

    …deos + 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>
    FireMasterK and AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    2eeb0a3 View commit details
    Browse the repository at this point in the history
  49. Configuration menu
    Copy the full SHA
    d551092 View commit details
    Browse the repository at this point in the history
  50. Configuration menu
    Copy the full SHA
    693f654 View commit details
    Browse the repository at this point in the history
  51. Configuration menu
    Copy the full SHA
    286d839 View commit details
    Browse the repository at this point in the history
  52. Use the youtubei API for YouTube comments

    Migrate YouTube comments to the desktop version by using the `next` endpoint of the InnerTube internal API.
    With the desktop version, we are able to get the exact like count of YouTube comments (by parsing the accessibility data) (the current extraction is used as a fallback). We are also now able to get if the uploader of the comment is verified or not.
    
    Co-authored-by: TiA4f8R <74829229+TiA4f8R@users.noreply.github.com>
    FireMasterK and AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    f3e4c9d View commit details
    Browse the repository at this point in the history
  53. Configuration menu
    Copy the full SHA
    f8197da View commit details
    Browse the repository at this point in the history
  54. Reformat some code and don't use the clickTrackingParams in continuat…

    …ions of YouTube Music search results
    
    The clickTrackingParams of YouTube Music search results are not needed to get continuations. This commit removes their use, which may improve privacy.
    AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    b74a39c View commit details
    Browse the repository at this point in the history
  55. Fix tests of YoutubePlaylistExtractorTest and YoutubeMixPlaylistExtra…

    …ctorTest
    
    Without removing RunWith and SuiteClasses annotations (and the corresponding imports) in YoutubePlaylistExtractorTest and YoutubeMixPlaylistExtractorTest, some mocks cannot be generated, so the CI fails because of the missing mocks. Mocks of workings tests have been also updated.
    AudricV committed Aug 1, 2021
    Configuration menu
    Copy the full SHA
    79cc5c8 View commit details
    Browse the repository at this point in the history