decord/source/modules/media/FileExtensionUtils.tsx

115 lines
3.1 KiB
TypeScript
Raw Normal View History

2026-09-02 09:53:35 +00:00
// Module ID: 5587
// Function ID: 5588
2026-08-24 06:08:38 +00:00
// Name: getExtensionFromContentType
2026-09-02 09:53:35 +00:00
// Dependencies: [1485, 2]
2026-08-24 06:08:38 +00:00
// Exports: decideFileExtension, getExtensionFromContentType
2026-09-02 09:53:35 +00:00
// Module 5587 (getExtensionFromContentType)
2026-08-24 06:08:38 +00:00
import set from "set" /* 2 */;
2026-09-02 09:53:35 +00:00
import isDiscordProxiedAssetUrlDefault from "isDiscordProxiedAssetUrl" /* 1485 */;
2026-07-20 16:05:17 +00:00
2026-07-23 10:11:24 +00:00
let closure_2 = { "image/avif": "avif", "image/gif": "gif", "image/heic": "heic", "image/jpeg": "jpg", "image/png": "png", "image/webp": "webp", "video/mp4": "mp4", "video/quicktime": "mov", "video/webm": "webm" };
2026-08-24 06:08:38 +00:00
const result = set.fileFinishedImporting("modules/media/FileExtensionUtils.tsx");
2026-07-20 16:05:17 +00:00
2026-08-24 06:08:38 +00:00
export const getExtensionFromContentType = function getExtensionFromContentType(str) {
if (null != str) {
str = str.toLowerCase();
if (obj.test(str)) {
if (null != dependencyMap[str]) {
return tmp2;
} else {
const tmp3 = str.split("/")[1];
let str3 = "jpg";
if ("jpeg" !== tmp3) {
let tmp4;
if (null != tmp3) {
tmp4 = tmp3;
}
str3 = tmp4;
}
return str3;
}
}
obj = /^(image|video)\//;
}
};
export const decideFileExtension = function decideFileExtension(closure_1_0, closure_1_1, arg2) {
2026-07-20 16:05:17 +00:00
let flag = arg2;
if (arg2 === undefined) {
flag = false;
}
let tmp;
if (flag) {
2026-08-24 06:08:38 +00:00
const toURLSafeResult = isDiscordProxiedAssetUrlDefault.toURLSafe(closure_1_0);
2026-07-20 16:05:17 +00:00
let formatted;
2026-07-29 08:29:29 +00:00
if (toURLSafeResult != null) {
2026-07-20 16:05:17 +00:00
const searchParams = toURLSafeResult.searchParams;
const str2 = searchParams.get("format");
2026-07-29 08:29:29 +00:00
if (str2 != null) {
2026-07-20 16:05:17 +00:00
formatted = str2.toLowerCase();
}
}
let tmp7;
if (null != formatted) {
if ("" !== formatted) {
let str4 = "jpg";
if ("jpeg" !== formatted) {
str4 = formatted;
}
tmp7 = str4;
}
}
tmp = tmp7;
2026-08-24 06:08:38 +00:00
const obj = isDiscordProxiedAssetUrlDefault;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (tmp == null) {
let tmp9;
2026-08-24 06:08:38 +00:00
if (null != closure_1_1) {
const str6 = closure_1_1.toLowerCase();
2026-07-21 22:01:30 +00:00
if (obj2.test(str6)) {
2026-08-24 06:08:38 +00:00
tmp9 = dependencyMap[str6];
2026-07-29 08:29:29 +00:00
if (null == tmp9) {
const tmp11 = str6.split("/")[1];
2026-07-21 22:01:30 +00:00
let str8 = "jpg";
2026-07-29 08:29:29 +00:00
if ("jpeg" !== tmp11) {
let tmp12;
if (null != tmp11) {
tmp12 = tmp11;
2026-07-21 22:01:30 +00:00
}
2026-07-29 08:29:29 +00:00
str8 = tmp12;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp9 = str8;
2026-07-20 16:05:17 +00:00
}
}
2026-07-23 10:11:24 +00:00
obj2 = /^(image|video)\//;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp = tmp9;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (tmp == null) {
2026-08-24 06:08:38 +00:00
const toURLSafeResult1 = isDiscordProxiedAssetUrlDefault.toURLSafe(closure_1_0);
2026-07-29 08:29:29 +00:00
let tmp15;
2026-07-20 16:05:17 +00:00
if (null != toURLSafeResult1) {
2026-07-21 22:01:30 +00:00
let formatted1;
2026-07-29 08:29:29 +00:00
if (toURLSafeResult1.pathname != null) {
2026-07-20 16:05:17 +00:00
const parts = str10.split(".");
2026-07-29 08:29:29 +00:00
if (parts != null) {
2026-07-20 16:05:17 +00:00
const str12 = parts.pop();
2026-07-29 08:29:29 +00:00
if (str12 != null) {
2026-07-21 22:01:30 +00:00
formatted1 = str12.toLowerCase();
2026-07-20 16:05:17 +00:00
}
}
}
2026-07-29 08:29:29 +00:00
let tmp14;
2026-07-21 22:01:30 +00:00
if (null != formatted1) {
if (formatted1.length <= 5) {
2026-07-29 08:29:29 +00:00
tmp14 = formatted1;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
tmp15 = tmp14;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp = tmp15;
2026-08-24 06:08:38 +00:00
const obj3 = isDiscordProxiedAssetUrlDefault;
2026-07-20 16:05:17 +00:00
}
return tmp;
};