Skip to content

Conversation

@oSumAtrIX
Copy link
Member

@oSumAtrIX oSumAtrIX commented Nov 22, 2025

It is intended to spoof the video streams to the web client. For this NewPipeExtractor is used with a PoTokenProvider implementation from NewPipe which uses a background WebView to pass BotGuard. It is assumed, that issues like playback, audio tracks and co would go away. However, NewPipe is not authenticating against YouTube, so some changes may be necessary.

The PR is not ready yet:

  • Refactor
  • Maybe don't rely on Kotlin (or at least not on its stdlib)
  • Implement authentication
  • Actually check if the streams do work and if it fixes stuff like the audio tracks missing
  • Add the po_token.html asset file via a patch
  • Implement this in YT Music as well, not sure if it works there though

Continuation of #5912

@Figim
Copy link

Figim commented Nov 23, 2025

@oSumAtrIX Thank you very much for your work. But as I mentioned in other PR, the following is related to pr.

We can also create a fork of Extractor.

Ytdlp-ejs solution. Revanced can use Quick.js (recommended). Otherwise it will be http 403

Beginning very soon, you'll need to have the JavaScript runtime Deno or quickJS installed to keep YouTube downloads working as normal. You can pass "JavaScript runtime" outside of NewPipeExtractor like ytdlandroid. (works very well)

yausername/youtubedl-android#338
https://github.com/yt-dlp/ejs
https://github.com/yt-dlp/yt-dlp/wiki/EJS

Potoken can be created with or without auth.

Some clients, such as web_creator (requires cookies) , will only work with authentication. Not all clients support authentication via cookies. MicroG cookies may not work with web clients

New potoken improvement (Beta)

YouTube switched to using content-bound poToken, i.e. the poToken is generated for each video using the video's ID. Video ID is used instead of standard Vistordata for Potoken. If not done, it will be http 403 . Does not require any special changes to the Extractor. We need to do this for ReVanced

libre-tube/LibreTube#7835

Caption Potoken. For web clients

**Potoken support could also be implemented for "Caption". Newpipe has not done it yet. But if a Potoken is created in the application using Webview, can you do it in ReVanced? Ytdlnis has done this. However, ytdlnis uses yt-dlp, but Potoken is created in the application (manually)

FreeTubeApp/FreeTube#7484

Web client can request SABR. Newpipe does not implement this yet. Ytdlp and FreeTube did it.**

YTdlp pr; yt-dlp/yt-dlp#13515 Other: etwoo/youtube-unthrottle@76b48d0

Freetube: FreeTubeApp/FreeTube#7145

Libretube implements this but will modify it in Extractor and then release it

libre-tube/LibreTube#7689

@oSumAtrIX
Copy link
Member Author

A background webview runtime is all that's needed technically speaking and it would also be future proof since runtimes can break. I don't know about SABR much and I wouldn't know how to replace urls. The question is how the YouTube app can work with web urls for now

@Figim
Copy link

Figim commented Nov 23, 2025

A background webview runtime is all that's needed technically speaking and it would also be future proof since runtimes can break. I don't know about SABR much and I wouldn't know how to replace urls. The question is how the YouTube app can work with web urls for now

LibreTube is working on SABR and you can't wait for their integration.

@oSumAtrIX
Copy link
Member Author

oSumAtrIX commented Nov 23, 2025

YouTube already can handle sabr. The point is how we can "patch" the app. Before SABR, we basically just have to replace an array of playable URLs. I dont know anything about sabr but i believe its not just URLs. Maybe it is, dunno. If the patch side is figured out, its as simple as leaving the heavy lifting to efforts like libretube, ytdlp, newpipe (thankfully)

@Figim
Copy link

Figim commented Nov 23, 2025

YouTube already can handle sabr. The point is how we can "patch" the app. Before SABR, we basically just have to replace an array of playable URLs. I dont know anything about sabr but i believe its not just URLs. Maybe it is, dunno. If the patch side is figured out, its as simple as leaving the heavy lifting to efforts like libretube, ytdlp, newpipe (thankfully)

libre-tube/LibreTube@66bb46d
Yes I mentioned ytdlp above. They will release a PR soon

@oSumAtrIX
Copy link
Member Author

from what i saw SABR is more than just a playback URL. The server sends some kind of client specific config and "streams" video bytes. It could require us to either:

  • Write this part in a patch where once the client makes a call, and the server responds, we have to "emulate" this behavior for the android client OR
  • We are able to MITM the server response and swap some parts that are missing, e.g. the video bytes

@Figim
Copy link

Figim commented Nov 23, 2025

from what i saw SABR is more than just a playback URL. The server sends some kind of client specific config and "streams" video bytes. It could require us to either:

  • Write this part in a patch where once the client makes a call, and the server responds, we have to "emulate" this behavior for the android client OR
  • We are able to MITM the server response and swap some parts that are missing, e.g. the video bytes

If you apply the Libretube "SABR streams" PR on ReVanced, you can use a custom NewPipe Extractor fork for this. You will need to manually build this. It does url extraction and more. The author has kept it as a test and they don't think it's necessary to release it yet. Later, the Official Extractor will support it.

https://github.com/FineFindus/NewPipeExtractor/tree/feat/sabr

@oSumAtrIX
Copy link
Member Author

For now I will use whatever NewPipe uses. It's more stable

@Figim
Copy link

Figim commented Nov 23, 2025

It may be useful for SABR:

https://github.com/yuliskov/SmartTube/tree/master/exoplayer-amzn-2.10.6/library/sabr/src/main/java/com/google/android/exoplayer2/source/sabr

Server-Based Smart Adaptive Bit Rate (SABR) Streaming With Statistical Multiplexing👇

https://ieeexplore.ieee.org/document/8551520

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants