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

Add a proper support of other delivery methods than progressive HTTP #663

Closed
wants to merge 71 commits into from

Conversation

AudricV
Copy link
Member

@AudricV AudricV commented Jun 20, 2021

  • I carefully read the contribution guidelines and agree to them.
  • I have tested the API against NewPipe.
  • I agree to create a pull request for NewPipe as soon as possible to make it compatible with the changed API.

This is the work made by @wb9688 (thank you for your work, I wouldn't have been able to do it myself) in #367 but rebased and with some changes:

Changes in Stream classes

  • Rename url (now deprecated) to content and add isUrl to indicate whether content contains the URL or the file itself (which is useful when we have to split DASH/HLS manifests);
  • Add id to identify a specific stream (there could be multiple Streams with the same ID if the same stream is offered through multiple delivery methods; in YouTube's case the ID would be the itag);
  • Add a baseUrl field, required for some players (like ExoPlayer) to play manifests.

Other changes:

  • Add DeliveryFormat enum with PROGRESSIVE_HTTP, DASH, HLS and TORRENT values;
  • Don't support SoundCloud HLS only-streams with the HLS delivery method, but with the current method which is progressive HTTP (so they are downloadable by NewPipe);
  • Extract the downloadable file of SoundCloud tracks (on tracks on which download is available);
  • Fix parsing of YouTube DASH manifests (not used now by the extractor);
  • Generate DASH manifests for YouTube OTF streams and post live streams, by using the data returned in the first sequence;
  • Format the ItagItem class;
  • Update DefaultStreamExtractorTest test with the changes made in Stream classes;
  • Update SoundcloudStreamExtractor test to test if streams returned by the extractor are progressive HTTP (test will fail if that's not the case);
  • Return the HLS URL of PeerTube streams and their HLS variant, if available;
  • Return PeerTube audio streams as audio streams (and not as video streams);
  • Add POST_LIVE_STREAM and POST_LIVE_AUDIO_STREAM to StreamType enum;
  • Return captions for YouTube age-restrcited videos (because we are now able to extract them, probably since the InnerTube migration for age-restricted contents).

Fixed issues

Closes #461, fixes #648

@AudricV AudricV added enhancement New feature or request multiservice Issues related to multiple services labels Jun 20, 2021
@AudricV AudricV marked this pull request as draft July 5, 2021 15:30
@AudricV AudricV marked this pull request as ready for review July 14, 2021 14:19
Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good to me, though this will require testing many videos

@Stypox
Copy link
Member

Stypox commented Jul 20, 2021

Oh, a question: the id field would be used by the client to only show one of the two equal options to the user?

@AudricV AudricV marked this pull request as draft August 7, 2021 15:47
Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, except for some (probably unavoidable) code duplication :-)

Copy link
Member

@TobiGr TobiGr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice structure!
I reviewed the first half of the files. I'll try to take a look at the others on the weekend.

@AudricV
Copy link
Member Author

AudricV commented Aug 9, 2021

Note that the CI is failing only because of the WhatIsPeerTube test (the issue is that some values about the channel were changed by Framasoft).

Copy link
Member

@TobiGr TobiGr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went through the remaining files and only found one minor thing.

@Stypox
Copy link
Member

Stypox commented Aug 25, 2021

Does it make a difference to use EMPTY_STRING instead of ""?

AudricV and others added 22 commits February 26, 2022 18:22
…improve YoutubeParsingHelper

The hardcoded client version used was outdated and buffering was present on a lot of streams so it seems we need to always get the most recent WEB client version; otherwise streams will be throttled.
The hardcoded clients version have been updated to their latest version.

In YoutubeParsingHelper:
- unused methods have been removed;
- documentations have been improved;
- a lot of warnings have been fixed;
- the extraction of the client version has been improved/fixed in terms of result and performance (the shortener version was returned even the standard client version was found).

A parameter has been added to streaming URLs from the WEB client: the cver param, which appends the client version to the streaming URL. This param is added by YouTube web players, so let's use it to spoof better the official web clients.
Some duplicated code (in YoutubeParsingHelper and YoutubeMusicSearchExtractor) has been merged into one common method named getYoutubeMusicHeaders, located in YoutubeParsingHelper.
…DASH manifests

Add the rn param to OTF and post live DVR streaming URLs (rn means request number).
This commit also improves documentation of YoutubeDashManifestCreator.
YoutubeDashManifestCreatorTest has been also updated with the changes made in YoutubeDashManifestCreator.
Trying to prevent more throttling when streaming ended livestreams or OTF streams by using first streams of the Android client.
…ive streams and massive improvements to YoutubeDashManifestCreator

Generate DASH manifests for YouTube progressive streams like Invidious does, fix some bugs, add documentation everywhere in the class.
Relevant test class has been updated.

For more detailed changes, look at code changes.
… DASH URLs extraction

Also improve a bit the code of the files changed with this PR.
… length

The value expected is a long so an implicit conversion was done and on bigger videos, the content length value is more than the capacity of an integer, which was making the extractor crash when trying to get video/audio streams. This issue is now fixed with this commit.
Apply opusforlife2's suggestions for comments and JavaDocs of YoutubeDashManifestCreator.
The boolean keyAndVersionExtracted in YoutubeParsingHelper was not set to false when resetting the client version and the key, which makes the extractor uses null on the next getting of the client version or the key if the clientVersion and the key were extracted before.
…reams on long video streams

Also apply suggested changes.

Co-authored-by: TobiGr <[email protected]>
Also make parameters in setters final.
…ove some code

In order to keep compability of the extractor for Android KitKat, we can't use StandardCharsets.UTF_8 but only the UTF_8 string.

Also improve some code: remove some duplication and fix some bugs.

For more detailed changes, check out code changes.
This field, made private, is recommended to be added by the Java serialization specification.
…hods and add documentation to the DeliveryMethod enum

It is named SS in the DeliveryMethod enum, because SmoothStreaming is a bit long word and we are already using abbreviations with DASH and HLS delivery methods.
Also add documentation of delivery methods of the enum constants and of the enum itself.
Documentation has been added for the enum constants and for the enum itself.
… resolution and isVideoOnly fields in VideoStream but deprecate their use

Getters should be used instead of the fields, like for the others.

Return a new constant (one for the AudioStream class, one for the VideoStream class, but they have the same value (because this method is not implemented in the Stream class)) for streams which don't have an itag instead of 0: ITAG_NOT_AVAILABLE_OR_NOT_APPLICABLE, which is equal to -1 (because an itag id should be not negative).
Also fix some small issues in the Stream class.
@AudricV
Copy link
Member Author

AudricV commented Mar 9, 2022

Closing in favor of #810.

@AudricV AudricV closed this Mar 9, 2022
@AudricV AudricV deleted the delivery-methods branch March 9, 2022 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request multiservice Issues related to multiple services
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use 0p as audio track [Request] Expose more variables to be able to create dash manifests
6 participants