Skip to content

misterdownloadmanager: The ultimate open-source, clean-room download manager written from scratch in pure Rust for Windows, Mac, and Linux

Download video: an embedded Dailymotion player is looked up without the embedding site's Referer (part of #359) (#509)

Ahmed Nefzaoui85aa9423587d
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c88e4b44..fe176d9e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@ Each release's notes on GitHub come from its section here (`## [X.Y.Z]`, see
### Fixed
+- **Download video** from Dailymotion's player embedded in another site: the look-up no longer sends that site as the Referer, which Dailymotion refused with 403, so its formats are found as with the video's own address ([#359](https://github.com/anefzaoui/misterdownloadmanager/issues/359)).
- The video button fades again after a click on the player, in fullscreen too, and stays while you use the keyboard ([#480](https://github.com/anefzaoui/misterdownloadmanager/issues/480)).
- The window no longer freezes when a video or a gallery finishes: marking its files as downloaded from the web, which can wait on the disk and the antivirus for a while with a big video, now happens beside the window ([#510](https://github.com/anefzaoui/misterdownloadmanager/issues/510)).
- Linux: **View → Dark Mode support** turns dark on window managers such as Hyprland and sway when only GNOME's setting says so (`gsettings set org.gnome.desktop.interface color-scheme prefer-dark`), as it did when a desktop portal answered ([#324](https://github.com/anefzaoui/misterdownloadmanager/issues/324)).
diff --git a/ROADMAP.md b/ROADMAP.md
index c30b0f26..559498ee 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -520,6 +520,8 @@ These ship in a later version, when they're ready.
### Bugs being looked into
+- 🔄 Dailymotion's embedded player from the browser's button: no formats, the embedding site's
+ Referer refused ([#359](https://github.com/anefzaoui/misterdownloadmanager/issues/359)): fix in review
- 🔄 The video button staying on screen after a click on the player, in fullscreen too\n ([#480](https://github.com/anefzaoui/misterdownloadmanager/issues/480)): fix in review
- 🔄 A freeze when a video finishes, while its file is marked as downloaded from the web
([#510](https://github.com/anefzaoui/misterdownloadmanager/issues/510)): fix in review
diff --git a/crates/app/src/videodlg.rs b/crates/app/src/videodlg.rs
index da53f7b1..ce3d72ef 100644
--- a/crates/app/src/videodlg.rs
+++ b/crates/app/src/videodlg.rs
@@ -168,8 +168,14 @@ impl VideoDialog {
/// Opened for `page` (Add URL was given a video's page, or the browser's button was
/// clicked with `context`): looks it up at once.
- pub fn for_page(folder: PathBuf, page: &str, context: mdm_ipc::Command) -> Self {
- let page = mdm_tools::pages::video_address(page);
+ pub fn for_page(folder: PathBuf, page: &str, mut context: mdm_ipc::Command) -> Self {
+ let own = mdm_tools::pages::video_address(page);
+ // An embedded player taken to the video's own page (#359): the site that embedded it
+ // isn't that page's referer, and Dailymotion refuses its own page asked with one (403).
+ if own != page {
+ context.referer = None;
+ }
+ let page = own;
VideoDialog {
page: page.clone(),
from_browser: page,
@@ -1256,6 +1262,27 @@ pub(crate) fn choice_label(label: &str) -> String {
mod tests {
use super::*;
+ /// #359: a Dailymotion player embedded in another site is looked up at the video's own page,
+ /// without that site as its Referer (Dailymotion answers 403); any other page keeps it.
+ #[test]
+ fn an_embedded_player_taken_to_its_page_drops_the_embedding_sites_referer() {
+ let from = |page: &str| {
+ let context = mdm_ipc::Command {
+ referer: Some("https://news.test/article".into()),
+ ..Default::default()
+ };
+ VideoDialog::for_page(PathBuf::from("v"), page, context)
+ };
+ let embed = from("https://geo.dailymotion.com/player/x1abc.html?video=x9xyz12");
+ assert_eq!(embed.page, "https://www.dailymotion.com/video/x9xyz12");
+ assert_eq!(embed.context().referer, None);
+ let plain = from("https://player.vimeo.test/video/1");
+ assert_eq!(
+ plain.context().referer.as_deref(),
+ Some("https://news.test/article")
+ );
+ }
+
/// #317: Cloudflare's check in plain words, saying what to try for each kind of cookies had.
#[test]
fn a_bot_check_says_what_to_try() {