Skip to content

v1.2.9 — Fix mp4upload 403 Forbidden (wrong Referer)

Choose a tag to compare

@sundeepyt2 sundeepyt2 released this 03 Jul 08:03

Root cause (from user's actual mpv logs)

[ffmpeg] https: HTTP error 403 Forbidden
Failed to open https://a4.mp4upload.com:183/d/.../video.mp4

SNI was scraping the mp4upload embed page successfully, but when setting up the playback stream it was sending:

Referer: https://youtu-chan.com   <- WRONG

mp4upload's CDN checks the Referer header and only allows requests from its own embed page. With the wrong Referer, it returns 403 Forbidden.

The fix

_scrape_embed() now uses the effective embed URL (after redirects) as the Referer when building the playback Stream. So for an mp4upload stream, mpv now sends:

Referer: https://www.mp4upload.com/embed-bxsct3uxo8tg.html   <- CORRECT
Origin:  https://www.mp4upload.com

Added _origin_for() helper to derive the Origin header from the embed URL (scheme + host), since that also needs to match the embed site.

This same fix applies to filemoon, vidnest, vizcloud, mycloud — all the sources that go through _scrape_embed. They all check the Referer header and would have had the same 403 issue.

Verified

Mocked test with realistic mp4upload embed response:

Stream URL: https://a4.mp4upload.com:183/d/.../video.mp4
Referer: https://www.mp4upload.com/embed-bxsct3uxo8tg.html  ✅
Origin:  https://www.mp4upload.com  ✅

mpv will now successfully play mp4upload streams (no more 403 Forbidden).

  • ruff check sni/ → All checks passed
  • pytest -q → 44 passed (3.29s)
  • python -m build → sdist + wheel both pass twine check

Install

pip install --upgrade sni-cli
sni play "Tsue to Tsurugi no Wistoria"

Full changelog: v1.2.8...v1.2.9