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: a bot check's refusal in plain words, and long errors read whole (part of #317) (#498)

Ahmed Nefzaouie34268a734db
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 220cd7e7..54da2672 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@ Each release's notes on GitHub come from its section here (`## [X.Y.Z]`, see
### Fixed
+- **Download video**: when a site's bot check (Cloudflare) turns yt-dlp away, the message says so and what to try, instead of yt-dlp's cut-off words ([#317](https://github.com/anefzaoui/misterdownloadmanager/issues/317)).
- The **Download video** window remembers the folder you save into, per **Options → Save to**'s "Change folder for this category on last selected", as **Download File Info** does: it no longer goes back to the Video category's folder each time ([#475](https://github.com/anefzaoui/misterdownloadmanager/issues/475)).
- X (Twitter) videos sent from the browser's media list are named after the tab, not the random name of their file on X's video server ([#493](https://github.com/anefzaoui/misterdownloadmanager/issues/493)).
- Windows: **Open folder** on a download opens the folder with the file manager set up to open folders (Directory Opus, for example), instead of always starting Windows Explorer. With Explorer it still selects the file ([#446](https://github.com/anefzaoui/misterdownloadmanager/issues/446)).
diff --git a/ROADMAP.md b/ROADMAP.md
index ee16f695..fbe53cd2 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -530,6 +530,8 @@ These ship in a later version, when they're ready.
([#447](https://github.com/anefzaoui/misterdownloadmanager/issues/447)): fix in review
- 🔄 A file renamed to avoid a clash still showing and opening under its old name
([#442](https://github.com/anefzaoui/misterdownloadmanager/issues/442)): fix in review
+- 🔄 Download video's message when a site's bot check (Cloudflare) refuses yt-dlp
+ ([#317](https://github.com/anefzaoui/misterdownloadmanager/issues/317)): fix in review
- 🔄 RSS feeds: the rule boxes losing the keyboard after each key
([#353](https://github.com/anefzaoui/misterdownloadmanager/issues/353)): fix in review
- 🔄 Video progress at 100 % while still downloading, and long encoded strings as file names
diff --git a/crates/app/src/videodlg.rs b/crates/app/src/videodlg.rs
index bc1d670e..a7e3dd63 100644
--- a/crates/app/src/videodlg.rs
+++ b/crates/app/src/videodlg.rs
@@ -680,7 +680,14 @@ impl VideoDialog {
{
self.install(tool, dir, rt, ui.ctx());
}
- if let Some(e) = &self.error {
+ // An error too long for its line, with no choices below it: read whole in their place.
+ let error_in_list = self.video.is_none()
+ && self.list.is_none()
+ && self
+ .error
+ .as_ref()
+ .is_some_and(|e| winui::text_width(&p, e) > 478.0);
+ if let Some(e) = self.error.as_ref().filter(|_| !error_in_list) {
let (rect, cut) =
winui::text_fit(&p, o.x + 11.0, o.y + 86.0, e, winui::ERROR(), o.x + 489.0);
if cut {
@@ -770,6 +777,18 @@ impl VideoDialog {
self.chosen = i;
self.name_from_choice();
}
+ // Wrapped in the empty list (#317).
+ if let Some(e) = self.error.as_ref().filter(|_| error_in_list) {
+ winui::paragraph(
+ &p.with_clip_rect(list),
+ list.left() + 8.0,
+ list.top() + 18.0,
+ e,
+ winui::ERROR(),
+ list.right() - 8.0,
+ 16.0,
+ );
+ }
}
// The labels before the boxes: a column as wide as the longest of them in this
@@ -1169,7 +1188,22 @@ fn lookup_error(e: &str, sent: bool, store: Option<&mdm_tools::proc::BrowserCook
)
};
}
- let plain = if lower.contains("drm") {
+ // A site's bot check turned yt-dlp away (#317).
+ let plain = if lower.contains("anti-bot") {
+ if store.is_some() {
+ // i18n: the Download video window: the site's bot check (Cloudflare) turned yt-dlp away though it had the cookies of the browser chosen in Options; {browser} = its name
+ return named(
+ "The site's bot check (Cloudflare) refused yt-dlp, even with {browser}'s cookies. Use the Download video button over the video in {browser}, or try the page again later.",
+ );
+ }
+ if sent {
+ // i18n: the Download video window: the site's bot check (Cloudflare) turned yt-dlp away though the browser's extension passed the page's cookies
+ "The site's bot check (Cloudflare) refused yt-dlp, even with your browser's cookies for this page. Try again later, or from another browser."
+ } else {
+ // i18n: the Download video window: the site's bot check (Cloudflare) turned yt-dlp away and no browser cookies were used
+ "The site's bot check (Cloudflare) refused yt-dlp. If the page opens in your browser, choose that browser in Options → Sites Logins → Cookies for video sites and look the page up again, or use the Download video button over the video."
+ }
+ } else if lower.contains("drm") {
// i18n: the Download video window: the page's video is copy-protected
"This video is protected (DRM): no tool can save it."
} else if lower.contains("unsupported url") {
@@ -1222,6 +1256,27 @@ pub(crate) fn choice_label(label: &str) -> String {
mod tests {
use super::*;
+ /// #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() {
+ let check = "yt-dlp failed: [generic] Got HTTP Error 403 caused by Cloudflare anti-bot challenge; try again with --extractor-args \"generic:impersonate\"";
+ let none = lookup_error(check, false, None);
+ assert!(none.contains("bot check"), "{none}");
+ assert!(none.contains("Cookies for video sites"), "{none}");
+ let sent = lookup_error(check, true, None);
+ assert!(sent.contains("even with your browser's cookies"), "{sent}");
+ let firefox = mdm_tools::proc::BrowserCookies::new("firefox", "").unwrap();
+ let chrome_had = lookup_error(check, false, Some(&firefox));
+ assert!(
+ chrome_had.contains("even with Firefox's cookies"),
+ "{chrome_had}"
+ );
+ assert_eq!(
+ lookup_error("yt-dlp failed: Video unavailable", false, None),
+ "yt-dlp failed: Video unavailable"
+ );
+ }
+
/// #229: yt-dlp's refusals and its trouble with a browser's cookies, in MDM's words, saying
/// which cookies it had.
#[test]
diff --git a/i18n/en.tsv b/i18n/en.tsv
index 9ca7d236..3e0c9d1e 100644
--- a/i18n/en.tsv
+++ b/i18n/en.tsv
@@ -3288,6 +3288,15 @@
#. text in the Download video window
#. the Download video window: the site asked for a sign-in although yt-dlp had the cookies of the browser chosen in Options; {browser} = its name
The site wants you signed in, even with {browser}'s cookies. Sign in to it in {browser}, then look the page up again. The site wants you signed in, even with {browser}'s cookies. Sign in to it in {browser}, then look the page up again.
+#. text in the Download video window
+#. the Download video window: the site's bot check (Cloudflare) turned yt-dlp away though the browser's extension passed the page's cookies
+ The site's bot check (Cloudflare) refused yt-dlp, even with your browser's cookies for this page. Try again later, or from another browser. The site's bot check (Cloudflare) refused yt-dlp, even with your browser's cookies for this page. Try again later, or from another browser.
+#. text in the Download video window
+#. the Download video window: the site's bot check (Cloudflare) turned yt-dlp away though it had the cookies of the browser chosen in Options; {browser} = its name
+ The site's bot check (Cloudflare) refused yt-dlp, even with {browser}'s cookies. Use the Download video button over the video in {browser}, or try the page again later. The site's bot check (Cloudflare) refused yt-dlp, even with {browser}'s cookies. Use the Download video button over the video in {browser}, or try the page again later.
+#. text in the Download video window
+#. the Download video window: the site's bot check (Cloudflare) turned yt-dlp away and no browser cookies were used
+ The site's bot check (Cloudflare) refused yt-dlp. If the page opens in your browser, choose that browser in Options → Sites Logins → Cookies for video sites and look the page up again, or use the Download video button over the video. The site's bot check (Cloudflare) refused yt-dlp. If the page opens in your browser, choose that browser in Options → Sites Logins → Cookies for video sites and look the page up again, or use the Download video button over the video.
#. text in crashui.rs
#. crash report window: the symbols couldn't be downloaded; the report still works
The symbols couldn't be fetched: some lines of the report show addresses instead of names (the developers can still read them). The symbols couldn't be fetched: some lines of the report show addresses instead of names (the developers can still read them).