add option to disable file metadata

closes #142
This commit is contained in:
dumbmoron 2023-08-24 08:31:39 +00:00
parent b56edfc193
commit 93aa1f4db4
8 changed files with 18 additions and 8 deletions

View file

@ -26,6 +26,7 @@ Response Body Type: ``application/json``
| isTTFullAudio | boolean | ``true / false`` | ``false`` | Enables download of original sound used in a TikTok video. | | isTTFullAudio | boolean | ``true / false`` | ``false`` | Enables download of original sound used in a TikTok video. |
| isAudioMuted | boolean | ``true / false`` | ``false`` | Disables audio track in video downloads. | | isAudioMuted | boolean | ``true / false`` | ``false`` | Disables audio track in video downloads. |
| dubLang | boolean | ``true / false`` | ``false`` | Backend uses Accept-Language for YouTube video audio tracks when ``true``. | | dubLang | boolean | ``true / false`` | ``false`` | Backend uses Accept-Language for YouTube video audio tracks when ``true``. |
| disableMetadata | boolean | ``true / false`` | ``false`` | Does not add metadata to the downloaded audio/video |
### Response Body Variables ### Response Body Variables
| key | type | variables | | key | type | variables |

View file

@ -18,7 +18,7 @@ const switchers = {
"vimeoDash": ["false", "true"], "vimeoDash": ["false", "true"],
"audioMode": ["false", "true"] "audioMode": ["false", "true"]
}; };
const checkboxes = ["disableTikTokWatermark", "fullTikTokAudio", "muteAudio", "reduceTransparency", "disableAnimations"]; const checkboxes = ["disableTikTokWatermark", "fullTikTokAudio", "muteAudio", "reduceTransparency", "disableAnimations", "disableMetadata"];
const exceptions = { // used for mobile devices const exceptions = { // used for mobile devices
"vQuality": "720" "vQuality": "720"
}; };
@ -377,6 +377,8 @@ async function download(url) {
if ((url.includes("tiktok.com/") || url.includes("douyin.com/")) && sGet("disableTikTokWatermark") === "true") req.isNoTTWatermark = true; if ((url.includes("tiktok.com/") || url.includes("douyin.com/")) && sGet("disableTikTokWatermark") === "true") req.isNoTTWatermark = true;
} }
if (sGet("disableMetadata") === "true") req.disableMetadata = true;
let j = await fetch(`${apiURL}/api/json`, { let j = await fetch(`${apiURL}/api/json`, {
method: "POST", method: "POST",
body: JSON.stringify(req), body: JSON.stringify(req),

View file

@ -43,6 +43,7 @@
"SettingsKeepDownloadButton": "keep >> visible", "SettingsKeepDownloadButton": "keep >> visible",
"AccessibilityKeepDownloadButton": "keep the download button always visible", "AccessibilityKeepDownloadButton": "keep the download button always visible",
"SettingsEnableDownloadPopup": "ask how to save", "SettingsEnableDownloadPopup": "ask how to save",
"SettingsDisableMetadata": "disable file metadata",
"AccessibilityEnableDownloadPopup": "ask what to do with downloads", "AccessibilityEnableDownloadPopup": "ask what to do with downloads",
"SettingsQualityDescription": "if selected quality isn't available, closest one is used instead.", "SettingsQualityDescription": "if selected quality isn't available, closest one is used instead.",
"LinkGitHubChanges": ">> see previous commits and contribute on github", "LinkGitHubChanges": ">> see previous commits and contribute on github",

View file

@ -43,6 +43,7 @@
"SettingsKeepDownloadButton": "всегда показывать >>", "SettingsKeepDownloadButton": "всегда показывать >>",
"AccessibilityKeepDownloadButton": "всегда показывать кнопку скачивания на экране", "AccessibilityKeepDownloadButton": "всегда показывать кнопку скачивания на экране",
"SettingsEnableDownloadPopup": "выбор метода скачивания", "SettingsEnableDownloadPopup": "выбор метода скачивания",
"SettingsDisableMetadata": "disable file metadata",
"AccessibilityEnableDownloadPopup": "спрашивать, что делать с загрузками", "AccessibilityEnableDownloadPopup": "спрашивать, что делать с загрузками",
"SettingsQualityDescription": "если выбранное качество недоступно, то выбирается ближайшее к нему.", "SettingsQualityDescription": "если выбранное качество недоступно, то выбирается ближайшее к нему.",
"LinkGitHubChanges": ">> смотри предыдущие изменения на github", "LinkGitHubChanges": ">> смотри предыдущие изменения на github",

View file

@ -447,6 +447,10 @@ export default function(obj) {
name: t("SettingsEnableDownloadPopup"), name: t("SettingsEnableDownloadPopup"),
padding: "no-margin", padding: "no-margin",
aria: t("AccessibilityEnableDownloadPopup") aria: t("AccessibilityEnableDownloadPopup")
}, {
action: "disableMetadata",
name: t("SettingsDisableMetadata"),
padding: "no-margin"
}]) }])
}) })
}], }],

View file

@ -22,7 +22,7 @@ import streamable from "./services/streamable.js";
export default async function (host, patternMatch, url, lang, obj) { export default async function (host, patternMatch, url, lang, obj) {
try { try {
let r, isAudioOnly = !!obj.isAudioOnly; let r, isAudioOnly = !!obj.isAudioOnly, disableMetadata = !!obj.disableMetadata;
if (!testers[host]) return apiJSON(0, { t: errorUnsupported(lang) }); if (!testers[host]) return apiJSON(0, { t: errorUnsupported(lang) });
if (!(testers[host](patternMatch))) return apiJSON(0, { t: brokenLink(lang, host) }); if (!(testers[host](patternMatch))) return apiJSON(0, { t: brokenLink(lang, host) });
@ -131,7 +131,7 @@ export default async function (host, patternMatch, url, lang, obj) {
if (r.error) return apiJSON(0, { t: Array.isArray(r.error) ? loc(lang, r.error[0], r.error[1]) : loc(lang, r.error) }); if (r.error) return apiJSON(0, { t: Array.isArray(r.error) ? loc(lang, r.error[0], r.error[1]) : loc(lang, r.error) });
return matchActionDecider(r, host, obj.aFormat, isAudioOnly, lang, isAudioMuted); return matchActionDecider(r, host, obj.aFormat, isAudioOnly, lang, isAudioMuted, disableMetadata);
} catch (e) { } catch (e) {
return apiJSON(0, { t: genericError(lang, host) }) return apiJSON(0, { t: genericError(lang, host) })
} }

View file

@ -2,14 +2,14 @@ import { audioIgnore, services, supportedAudio } from "../config.js";
import { apiJSON } from "../sub/utils.js"; import { apiJSON } from "../sub/utils.js";
import loc from "../../localization/manager.js"; import loc from "../../localization/manager.js";
export default function(r, host, audioFormat, isAudioOnly, lang, isAudioMuted) { export default function(r, host, audioFormat, isAudioOnly, lang, isAudioMuted, disableMetadata) {
let action, let action,
responseType = 2, responseType = 2,
defaultParams = { defaultParams = {
u: r.urls, u: r.urls,
service: host, service: host,
filename: r.filename, filename: r.filename,
fileMetadata: r.fileMetadata ? r.fileMetadata : false fileMetadata: !disableMetadata ? r.fileMetadata : false
}, },
params = {} params = {}

View file

@ -6,7 +6,7 @@ const apiVar = {
vQuality: ["max", "4320", "2160", "1440", "1080", "720", "480", "360", "240", "144"], vQuality: ["max", "4320", "2160", "1440", "1080", "720", "480", "360", "240", "144"],
aFormat: ["best", "mp3", "ogg", "wav", "opus"] aFormat: ["best", "mp3", "ogg", "wav", "opus"]
}, },
booleanOnly: ["isAudioOnly", "isNoTTWatermark", "isTTFullAudio", "isAudioMuted", "dubLang", "vimeoDash"] booleanOnly: ["isAudioOnly", "isNoTTWatermark", "isTTFullAudio", "isAudioMuted", "dubLang", "vimeoDash", "disableMetadata"]
} }
const forbiddenChars = ['}', '{', '(', ')', '\\', '%', '>', '<', '^', '*', '!', '~', ';', ':', ',', '`', '[', ']', '#', '$', '"', "'", "@", '==']; const forbiddenChars = ['}', '{', '(', ')', '\\', '%', '>', '<', '^', '*', '!', '~', ';', ':', ',', '`', '[', ']', '#', '$', '"', "'", "@", '=='];
const forbiddenCharsString = ['}', '{', '%', '>', '<', '^', ';', '`', '$', '"', "@", '=']; const forbiddenCharsString = ['}', '{', '%', '>', '<', '^', ';', '`', '$', '"', "@", '='];
@ -101,13 +101,14 @@ export function checkJSONPost(obj) {
isNoTTWatermark: false, isNoTTWatermark: false,
isTTFullAudio: false, isTTFullAudio: false,
isAudioMuted: false, isAudioMuted: false,
disableMetadata: false,
dubLang: false, dubLang: false,
vimeoDash: false vimeoDash: false
} }
try { try {
let objKeys = Object.keys(obj); let objKeys = Object.keys(obj);
if (!(objKeys.length <= 9 && obj.url)) return false;
let defKeys = Object.keys(def); let defKeys = Object.keys(def);
if (objKeys.length > defKeys.length + 1 || !obj.url) return false;
for (let i in objKeys) { for (let i in objKeys) {
if (String(objKeys[i]) !== "url" && defKeys.includes(objKeys[i])) { if (String(objKeys[i]) !== "url" && defKeys.includes(objKeys[i])) {