Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.
Rust downloadmanagerguihacktoberfesthomebrewlightweightlinuxlinux-distributionlocal-firstmacosmacos-packagemedia-toolboxopen-sourcerustsveltetauritrendingtrending-repositorieswindowswindows-desktopytdlp
feat: add support for HLS segment detection and remove .ts from media extensions
Tonho994b270f90e6
diff --git a/browser-extension/chrome/src/media-sniffer.js b/browser-extension/chrome/src/media-sniffer.jsindex 9b17b474..5134fab8 100644--- a/browser-extension/chrome/src/media-sniffer.js+++ b/browser-extension/chrome/src/media-sniffer.js@@ -12,7 +12,7 @@ const MEDIA_CONTENT_TYPES = [];const MEDIA_EXTENSIONS = [- ".mp4", ".webm", ".m3u8", ".mpd", ".ts",+ ".mp4", ".webm", ".m3u8", ".mpd",".flv", ".ogg", ".mp3", ".m4a", ".m4v",".mkv", ".avi", ".mov",];@@ -89,6 +89,23 @@ function formatSize(bytes) {return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;}+function isHlsSegment(url, contentType) {+ const ct = contentType.toLowerCase();+ if (ct.includes("mp2t") || ct.includes("mpeg2-ts") || ct.includes("mpeg-ts")) {+ return true;+ }+ try {+ const path = new URL(url).pathname.toLowerCase();+ if (path.endsWith(".ts") || path.match(/\.ts\?/)) {+ return true;+ }+ if (/\/video\d+\.ts/.test(path)) {+ return true;+ }+ } catch {}+ return false;+}+export function registerSnifferListeners(onMediaDetected) {chrome.webRequest.onSendHeaders.addListener((details) => {@@ -121,6 +138,11 @@ export function registerSnifferListeners(onMediaDetected) {return;}+ if (isHlsSegment(url, contentType)) {+ pendingRequests.delete(details.requestId);+ return;+ }+if (contentLength > 0 && contentLength < MIN_CONTENT_LENGTH) {if (!url.includes(".m3u8") && !contentType.includes("mpegurl")) {pendingRequests.delete(details.requestId);