Skip to content

[YouTube] Speed up n parameter presence check#1330

Merged
TobiGr merged 2 commits intoTeamNewPipe:devfrom
litetex:speed-up-n-parameter-extraction
Jul 12, 2025
Merged

[YouTube] Speed up n parameter presence check#1330
TobiGr merged 2 commits intoTeamNewPipe:devfrom
litetex:speed-up-n-parameter-extraction

Conversation

@litetex
Copy link
Copy Markdown
Member

@litetex litetex commented Jul 10, 2025

This code does a quick check if the n parameter is even present before running the extraction regex.

The time required to extract an url that does not contain the n-parameter got down from:

  • 51200ns to 600ns → ~85x faster

Example: Timings of getThrottlingParameterFromStreamingUrl in ns when running YoutubeStreamExtractorRelatedMixTest:
Before:

[RATE-LIMIT] Waited 0.0s for https://www.youtube.com/youtubei/v1/next?prettyPrint=false
>>101900
>>79800
>>60000
>>58800
>>61200
>>87500
>>61300
>>56000
>>65700
>>71900
>>54700
>>53400
>>67300
>>70700
>>63100
>>70100
>>63800
>>69400
>>60400
>>57800
>>79400
>>85100
>>59000

After:

[RATE-LIMIT] Waited 0.0s for https://www.youtube.com/youtubei/v1/next?prettyPrint=false
>>4200
>>700
>>700
>>600
>>600
>>700
>>600
>>1200
>>900
>>700
>>800
>>800
>>500
>>500
>>600
>>700
>>1100
>>700
>>600
>>600
>>300
>>600
>>800
  • 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.

@litetex litetex added the YouTube Service, https://www.youtube.com/ label Jul 10, 2025
@litetex litetex force-pushed the speed-up-n-parameter-extraction branch from 7727521 to 5184231 Compare July 10, 2025 21:37
@TobiGr
Copy link
Copy Markdown
Contributor

TobiGr commented Jul 11, 2025

Good catch! You might want to add a comment to THROTTLING_PARAM_PATTERN that this check needs to be modified in case the pattern changes.

@ShareASmile ShareASmile added the enhancement New feature or request label Jul 11, 2025
@litetex
Copy link
Copy Markdown
Member Author

litetex commented Jul 11, 2025

@TobiGr done :)

@TobiGr TobiGr merged commit c0ff21a into TeamNewPipe:dev Jul 12, 2025
3 of 4 checks passed
@litetex litetex deleted the speed-up-n-parameter-extraction branch July 12, 2025 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request YouTube Service, https://www.youtube.com/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants