Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

fix(courses): route Hotmart/Udemy URLs to the Courses page and fix auth window

Antonio Leandro358aac371176
diff --git a/src-tauri/src/commands/auth_webview.rs b/src-tauri/src/commands/auth_webview.rs
index 1ac6b376..858c92f8 100644
--- a/src-tauri/src/commands/auth_webview.rs
+++ b/src-tauri/src/commands/auth_webview.rs
@@ -87,16 +87,31 @@ pub async fn open_auth_webview(
let mut is_success = false;
if let Some(ref pattern) = success_pattern {
- if url_str.contains(pattern) {
+ // An explicit success pattern from the plugin config is
+ // authoritative: never fall back to the fuzzy heuristic.
+ // Match against host + path only, so encoded redirect params in
+ // the login URL itself (e.g. sso.hotmart.com/login?redirect=
+ // https%3A%2F%2Fconsumer.hotmart.com) can't trigger a false
+ // success.
+ if let Ok(nav_url) = url::Url::parse(&url_str) {
+ let host_and_path =
+ format!("{}{}", nav_url.host_str().unwrap_or(""), nav_url.path());
+ if host_and_path.contains(pattern) {
+ is_success = true;
+ }
+ } else if url_str.contains(pattern) {
is_success = true;
}
- }
-
- if !is_success && !login_host.is_empty() {
+ } else if !login_host.is_empty() {
if let Ok(nav_url) = url::Url::parse(&url_str) {
let nav_host = nav_url.host_str().unwrap_or("");
let nav_path = nav_url.path();
- if nav_host.contains(&login_host) || login_host.contains(nav_host) {
+ // Same host, or a subdomain of the login host. The old
+ // bidirectional substring check treated unrelated hosts
+ // (e.g. hotmart.com vs sso.hotmart.com) as a match.
+ let same_host = nav_host == login_host
+ || nav_host.ends_with(&format!(".{login_host}"));
+ if same_host {
if nav_path != login_path
&& !nav_path.contains("login")
&& !nav_path.contains("signin")
diff --git a/src-tauri/src/commands/downloads.rs b/src-tauri/src/commands/downloads.rs
index d3f2983a..9211d30f 100644
--- a/src-tauri/src/commands/downloads.rs
+++ b/src-tauri/src/commands/downloads.rs
@@ -866,6 +866,10 @@ pub async fn download_from_url(
let _timer_start = std::time::Instant::now();
let platform = Platform::from_url(&url);
+ if matches!(platform, Some(Platform::Hotmart) | Some(Platform::Udemy)) {
+ return Err("Course platforms can't be downloaded from a URL. Open the Courses page (requires the Courses plugin and a logged-in account).".to_string());
+ }
+
let custom_ytdlp_args = match time_range.as_deref().map(str::trim) {
Some(r) if !r.is_empty() && is_valid_time_range(r) => {
Some(vec!["--download-sections".to_string(), format!("*{}", r)])
diff --git a/src-tauri/src/external_url.rs b/src-tauri/src/external_url.rs
index 66ecf3be..060df68f 100644
--- a/src-tauri/src/external_url.rs
+++ b/src-tauri/src/external_url.rs
@@ -106,12 +106,16 @@ pub async fn queue_url_with_defaults(
}
}
+ let platform = Platform::from_url(&url);
+
+ if matches!(platform, Some(Platform::Hotmart) | Some(Platform::Udemy)) {
+ return Err("Course platforms can't be downloaded from a URL. Open the Courses page (requires the Courses plugin and a logged-in account).".to_string());
+ }
+
let downloader = state
.registry
.find_platform(&url)
.ok_or_else(|| "No downloader available for this URL".to_string())?;
-
- let platform = Platform::from_url(&url);
let platform_name = platform
.map(|p| p.to_string())
.unwrap_or_else(|| "generic".to_string());
diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte
index bf50a489..b5e3b1b3 100644
--- a/src/routes/+page.svelte
+++ b/src/routes/+page.svelte
@@ -60,6 +60,9 @@
format_note: string | null;
};
+ // Platforms whose content is downloaded via the Courses page (courses
+ // plugin + logged-in account), not from a pasted URL.
+ const COURSE_PLATFORMS = new Set(["hotmart", "udemy"]);
let url = $state(getOmniboxDraftUrl());
let homeInputMode = $state<HomeInputMode>("url");
@@ -142,7 +145,7 @@
if (!pendingAutoDownload) return;
if (omniState.kind === "detected") {
const info = omniState.info;
- if (info.platform === "hotmart" || info.platform === "p2p") {
+ if (COURSE_PLATFORMS.has(info.platform) || info.platform === "p2p") {
pendingAutoDownload = false;
return;
}
@@ -398,7 +401,9 @@
const result = await invoke<PlatformInfo>("detect_platform", { url: value });
if (result.supported) {
omniState = { kind: "detected", info: result };
- invoke("prefetch_media_info", { url: value }).catch(() => {});
+ if (!COURSE_PLATFORMS.has(result.platform)) {
+ invoke("prefetch_media_info", { url: value }).catch(() => {});
+ }
loadCookieAccounts(value);
if (result.content_type === "playlist") {
loadPlaylistEntries(value);
@@ -623,8 +628,8 @@
if (omniState.kind !== "detected") return;
const info = omniState.info;
- if (info.platform === "hotmart") {
- goto(`/courses?platform=${encodeURIComponent(info.platform)}`);
+ if (COURSE_PLATFORMS.has(info.platform)) {
+ goto(`/courses/${encodeURIComponent(info.platform)}`);
return;
}
@@ -1056,8 +1061,8 @@
<button type="button" class="cookie-hint-link" onclick={() => goto("/settings?tab=cookies")}>{$t("omnibox.cookie_hint_action")}</button>
</p>
{/if}
- {#if omniState.info.platform === "hotmart"}
- <button class="button action-btn" onclick={handleAction}>{$t('omnibox.go_to_hotmart')}</button>
+ {#if COURSE_PLATFORMS.has(omniState.info.platform)}
+ <button class="button action-btn" onclick={handleAction}>{$t(omniState.info.platform === "udemy" ? 'omnibox.go_to_udemy' : 'omnibox.go_to_hotmart')}</button>
{:else}
{@const playlistBlocked = omniState.info.content_type === "playlist" && playlistEntries.length > 0 && selectedPlaylistItems.size === 0}
{@const torrentBlocked = torrentEntries.length > 0 && selectedTorrentFiles.size === 0}