UNPKG

blogger-feeds

Version:
158 lines (157 loc) 5.52 kB
import { s as u, m as I, a as r, b as x, i as q, c as b } from "./core-6805d14a.js"; const d = (t) => { const e = {}; return Object.assign(e, j(t ?? "")), (t = u(t)) && (Object.assign(e, Object.fromEntries(t.searchParams)), typeof (e == null ? void 0 : e.q) == "string" && Object.assign(e, S(e.q))), e; }, h = (...t) => { try { const e = {}; for (let s of t) (s instanceof URL || typeof s == "string") && (s = d(s)), Object.assign(e, s); return I(e); } catch (e) { return console.error(e, ...t), null; } }, S = (t) => { var n, c; let e = r(t) ?? "", s = (n = t.replace(e ?? "", "")) == null ? void 0 : n.trim(), o = { labels: "", terms: "" }; return e = (c = e == null ? void 0 : e.split("|")) == null ? void 0 : c.map((g) => g.includes(",") ? g.split(",") : g), Object.assign(o, { terms: s, labels: e }); }, j = (t) => { var o; const e = {}, s = x(t); if (e.blog = q(t = ((o = u(t)) == null ? void 0 : o.origin) ?? "") ? "blogger" : t, s) for (const n of s) e.blog === "blogger" && !e.blogId ? e.blogId = n : e.postId = n; return e; }, $ = /(http.*(?:blogger|blogspot|googleusercontent).*)(?:(\/.*\/)(.*\..*$)|(=s\d+.+?$))/, P = (t, e = 0) => { const s = (t = t + "").match(new RegExp($)), o = s == null ? void 0 : s.at(4); return s && (t = o ? t.replace(o ?? "", `=s${e}`) : t.replace(new RegExp($), `$1/s${e}/$3`)), t; }, O = [ "youtube-nocookie", // privacy embeds "img.youtube.com", // thumbnails "ytimg.com", // short thumbs "youtu.be" // share links ], R = (t) => { var e, s; if ((t = u(t) ?? "") instanceof URL) { if (t.href.includes("youtube.com/watch")) return t.searchParams.get("v") ?? ""; for (const o of O) if (t.href.includes(o)) return ((s = (e = t.pathname.split(/\/|\?/)) == null ? void 0 : e.filter((n) => n !== "embed" && n !== "vi")) == null ? void 0 : s.at(1)) ?? ""; } return ""; }, l = { origin: { norm: "https://img.youtube.com", // default short: "https://i.ytimg.com" // shortened }, quality: /* @__PURE__ */ new Set([ "", // default "mq", // medium "hq", // guaranteed "sd", // standard "maxres" // unscaled ]), thumbs: /* @__PURE__ */ new Set([ "default", // video bg "1", // start "2", // middle "3" // end ]) }, y = (t = "", { thumb: e = "default", quality: s = "hq", short: o = !0, all: n = !1, id: c } = {}) => { if (!(c ?? (c = R(t)))) return t; const g = l.origin[o ? "short" : "norm"]; if (l.quality.has(s) || (s = "hq"), l.thumbs.has(e) || (e = "default"), !n) return g + "/vi/" + c + "/" + s + e + ".jpg"; const f = {}; for (const p of l.thumbs) for (const m of l.quality) (f[p] ?? (f[p] = {}))[m] = y("", { quality: m, thumb: p, id: c }); return f; }, i = (t, e) => { var s, o; return ((o = (s = t == null ? void 0 : t.link) == null ? void 0 : s.find(({ rel: n }) => n === e)) == null ? void 0 : o.href) ?? ""; }, k = (/* @__PURE__ */ new Map()).set("blog", (t) => { var e; return (e = u(i(t, "alternate"))) == null ? void 0 : e.origin; }).set("blogId", (t) => d(i(t, "self")).blogId).set("postId", (t) => d(i(t, "self")).postId).set("updated", (t) => { var e; return b((e = t == null ? void 0 : t.updated) == null ? void 0 : e.$t); }).set("etag", (t) => t == null ? void 0 : t.gd$etag).set("total", (t) => { var e; return Number((e = t == null ? void 0 : t.openSearch$totalResults) == null ? void 0 : e.$t); }).set("start-index", (t) => { var e; return Number((e = t == null ? void 0 : t.openSearch$startIndex) == null ? void 0 : e.$t); }).set("max-results", (t) => { var e; return Number((e = t == null ? void 0 : t.openSearch$itemsPerPage) == null ? void 0 : e.$t); }).set("self", (t, e) => h(i(t, "self"), e) + "").set("href", (t, e) => e.postId && i(t, "alternate")).set( "next", (t, e) => !e.postId && (t = i(t, "next")) && h(t, e.blog) + "" ), L = (/* @__PURE__ */ new Map()).set("postId", (t, e) => { var s, o; return (e == null ? void 0 : e.postId) || ((o = d((s = t == null ? void 0 : t.id) == null ? void 0 : s.$t)) == null ? void 0 : o.postId); }).set("title", (t) => { var e; return (e = t == null ? void 0 : t.title) == null ? void 0 : e.$t; }).set( "self", (t, e) => (e == null ? void 0 : e.postId) && (e == null ? void 0 : e.self) || h(i(t, "self"), { blog: e.blog }) + "" ).set( "href", (t, e) => e.postId ? e.href : i(t, "alternate") ).set("authors", (t) => { var e; return ((e = t == null ? void 0 : t.author) == null ? void 0 : e.map((s) => { var o; return (o = s == null ? void 0 : s.name) == null ? void 0 : o.$t; })) ?? []; }).set("published", (t) => { var e; return b((e = t == null ? void 0 : t.published) == null ? void 0 : e.$t); }).set("updated", (t) => { var e; return b((e = t == null ? void 0 : t.updated) == null ? void 0 : e.$t); }).set("etag", (t) => t == null ? void 0 : t.gd$etag).set("image", (t) => { var e; return y(P((e = t == null ? void 0 : t.media$thumbnail) == null ? void 0 : e.url)); }).set("type", (t) => { var e; return (e = t == null ? void 0 : t.content) == null ? void 0 : e.type; }).set("body", (t) => { var e; return (e = t == null ? void 0 : t.content) == null ? void 0 : e.$t; }).set("categories", (t) => { var e; return ((e = t == null ? void 0 : t.category) == null ? void 0 : e.map((s) => s == null ? void 0 : s.term)) ?? []; }); export { k as M, L as P, h as m, P as t, y };