UNPKG

rsshub

Version:
31 lines (29 loc) 1.23 kB
import { n as init_esm_shims, t as __dirname } from "./esm-shims-CzJ_djXG.mjs"; import path from "node:path"; //#region lib/routes/douyin/utils.ts init_esm_shims(); const templates = { desc: path.join(__dirname, "templates/desc-d19ed12d.art"), cover: path.join(__dirname, "templates/cover-9f673a73.art"), embed: path.join(__dirname, "templates/embed-64d86e10.art"), iframe: path.join(__dirname, "templates/iframe-a1eaec56.art") }; const resolveUrl = (url, tls = true, forceResolve = false) => { if (!url) return ""; if (url.startsWith("//")) return (tls ? "https:" : "http:") + url; if (forceResolve && !/^https?:\/\//.test(url)) return (tls ? "https://" : "http://") + url; return url; }; const proxyVideo = (url, proxy) => { if (!(url && proxy)) return url + ""; if (proxy.includes("?")) { if (!proxy.endsWith("=")) proxy += "="; return proxy + encodeURIComponent(url); } else { if (!proxy.endsWith("/")) proxy += "/"; return proxy + url; } }; const getOriginAvatar = (url) => resolveUrl(url).replace(/^(.*\.douyinpic\.com\/).*(\/aweme-avatar\/)([^?]*)(\?.*)?$/, "$1origin$2$3").replaceAll(/~\w+_\d+x\d+/g, ""); //#endregion export { templates as i, proxyVideo as n, resolveUrl as r, getOriginAvatar as t };