Skip to content

[tiktok] First draft of a challenge resolver#8850

Merged
mikf merged 10 commits intomikf:masterfrom
CasualYT31:tiktok-challenge-resolution
Jan 26, 2026
Merged

[tiktok] First draft of a challenge resolver#8850
mikf merged 10 commits intomikf:masterfrom
CasualYT31:tiktok-challenge-resolution

Conversation

@CasualYT31
Copy link
Contributor

@CasualYT31 CasualYT31 commented Jan 9, 2026

Full disclosure, I largely copied/translated the JavaScript code to resolve the challenge ourselves. There are potentially a couple of problems with this:

  1. I refuse to believe that this solution will work for long. I am sure that part of the challenge process involves slightly changing this code every so often. I don't know that for sure, but surely there is no way they will use the same code every time. I have seen two slightly different versions of this code already (i.e. sometimes rci/rs don't exist and aren't used at all), and that was within the past couple of weeks.
  2. I am not sure if I/we are even allowed to copy/adapt the code like this? If you'd rather not risk introducing this code, we'll need to figure out a different solution.

I am currently in the processing of performing thorough testing on this PR (as well as all of my others), I will report soon whether or not this approach works.

Closes #8772.

@CasualYT31
Copy link
Contributor Author

CasualYT31 commented Jan 9, 2026

I'm noticing that after challenges are "resolved," I begin to encounter a few 403 responses. The solution needs a bit of tweaking. Maybe a small sleep after resolving the challenge is required? Or maybe there's a piece of the puzzle I'm missing.

Edit: on second thoughts, the 403 responses may be from the better quality URLs (I'm currently testing with the old PR that doesn't provide fallbacks). To verify this I'll make sure to start testing with the latest fallback changes soon.

Edit 2 (11 Jan): I have now began testing with all of my latest changes, I'll see if I keep running into the 403 responses.

@CasualYT31
Copy link
Contributor Author

CasualYT31 commented Jan 16, 2026

I do still run into the 403 errors, but much less frquently. Manual testing locally (as opposed to testing my PRs on a dedicated server overnight) allows me to get a clearer understanding of what happens when we do encounter a challenge response, and the resolver has worked every time I've encountered said response, with no 403 responses. So I am guessing that the 403s are due to excessive requests being made by the server.

Edit to say that I have ended up seeing 403 responses a couple of times locally, too, but re-running the download commands always worked for me.

@CasualYT31
Copy link
Contributor Author

CasualYT31 commented Jan 23, 2026

If this PR ends up being unsuitable, then apparently the approach in this yt-dlp PR also fixes the issue, but it's a bit more work.

@mikf
Copy link
Owner

mikf commented Jan 25, 2026

I've done a bit of cleanup.
Do you think it is OK to merge like this?

I can't get a challenge myself, but it runs without exceptions on synthetic data.
(cs = "eyJ2IjogeyJjIjogImFzZD0iLCAiYSI6ICJhc2Q9In19")

@CasualYT31
Copy link
Contributor Author

I will test again tonight, but looks good to me! I do still run into it occasionally so I'll let you know once everything works correctly.

@CasualYT31
Copy link
Contributor Author

CasualYT31 commented Jan 25, 2026

❗ The changes to range predicates have broken account extraction, btw (specifically around line 1191). I'll need to bring up another PR for that: #8931.

@mikf mikf merged commit 7028146 into mikf:master Jan 26, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TikTok videos can't be downloaded

2 participants