Skip to content

fix(douyin): normalize modal_id URLs to direct video format before yt-dlp#40

Merged
vanloctech merged 2 commits intovanloctech:mainfrom
TTAWDTT:fix/douyin-url-normalization
Mar 4, 2026
Merged

fix(douyin): normalize modal_id URLs to direct video format before yt-dlp#40
vanloctech merged 2 commits intovanloctech:mainfrom
TTAWDTT:fix/douyin-url-normalization

Conversation

@TTAWDTT
Copy link
Contributor

@TTAWDTT TTAWDTT commented Mar 4, 2026

Summary

  • Douyin's web interface uses modal overlay URLs (e.g. /user/…?modal_id=123, /jingxuan?modal_id=123, /jingxuan/music?modal_id=123) when viewing videos from profile pages, search results, and curated feeds. yt-dlp does not recognize these URL variants and fails with ERROR: Unsupported URL.
  • Add normalize_url() in security.rs to transform any douyin.com URL containing a numeric modal_id query parameter into the canonical /video/{id} format that yt-dlp expects.
  • Applied to all 8 yt-dlp invocation points in the backend (download.rs, video.rs, metadata.rs, channels.rs) and the frontend deep-link normalizer (external-link.ts).

Affected URL patterns

Before (unsupported) After (supported)
douyin.com/user/self?modal_id=123… douyin.com/video/123…
douyin.com/jingxuan?modal_id=123… douyin.com/video/123…
douyin.com/jingxuan/search/…?modal_id=123… douyin.com/video/123…
douyin.com/jingxuan/music?modal_id=123… douyin.com/video/123…
douyin.com/user/MS4wLjA…?modal_id=123… douyin.com/video/123…

URLs already in /video/{id} format are left unchanged.

Test plan

  • 13 unit tests covering all Douyin URL variants, edge cases (missing/empty/non-numeric modal_id), and non-Douyin URLs
  • cargo check passes
  • cargo test passes
  • tsc -b passes

TTAWDTT added 2 commits March 3, 2026 10:20
…ess theme integration

On Windows, the native title bar color followed the system theme and clashed
with the app's own theme. This removes native decorations and renders custom
minimize/maximize/close buttons in the frontend, matching the approach used
by macOS overlay title bar. Adds required Tauri v2 window permissions.
…-dlp

Douyin's web interface uses modal overlay URLs (e.g. /user/…?modal_id=123,
/jingxuan?modal_id=123) when viewing videos from profile pages, search
results, and curated feeds. yt-dlp does not recognize these URL variants
and fails with "Unsupported URL".

Add normalize_url() to transform any douyin.com URL containing a numeric
modal_id query parameter into the canonical /video/{id} format that yt-dlp
expects. Applied to all 8 yt-dlp invocation points in the backend and the
frontend deep-link normalizer. Includes 13 unit tests.
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f774af3e2d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}

// Must be a douyin.com host
if !lower_base.contains("douyin.com/") {

Choose a reason for hiding this comment

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

P2 Badge Match Douyin hostname exactly before URL rewrite

normalize_douyin treats any base string containing "douyin.com/" as a Douyin URL, so inputs like https://notdouyin.com/watch?modal_id=123 are incorrectly rewritten to https://www.douyin.com/video/123. That silently changes non-Douyin user input into a different target and can download the wrong content; this should parse and validate the hostname (e.g. exact douyin.com/www.douyin.com) instead of using substring matching.

Useful? React with 👍 / 👎.

@vanloctech vanloctech merged commit 0899f20 into vanloctech:main Mar 4, 2026
3 checks passed
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.

2 participants