UNPKG

rsshub

Version:
65 lines (63 loc) 2.79 kB
import { n as init_esm_shims, t as __dirname } from "./esm-shims-CzJ_djXG.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as art } from "./render-BQo6B4tL.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import path from "node:path"; import { load } from "cheerio"; //#region lib/routes/javlibrary/utils.ts init_esm_shims(); const rootUrl = "https://www.javlibrary.com"; const defaultMode = "1"; const defaultGenre = "amjq"; const defaultMaker = "arlq"; const defaultLanguage = "ja"; const ProcessItems = async (language, currentUrl, tryGet) => { const $ = load((await got_default({ method: "get", url: currentUrl })).data); $(".toolbar, .info, .videoinfo").remove(); let items = $(".videotextlist, #video_comments").find("a").toArray().filter((i) => $(i).parent().hasClass("video") || $(i).parent().get(0).tagName === "strong").map((item) => { item = $(item); const table = item.parentsUntil("table"); const link = `${rootUrl}/${language}/${item.attr("href").replace(/^\.\//, "")}`; return { link, url: link.replace(/video.*\.php/, ""), title: item.text(), description: table.find("textarea").text(), pubDate: parseDate(table.find(".date").text()) }; }); items = await Promise.all(items.map((item) => tryGet(item.url, async () => { const detailResponse = await got_default({ method: "get", url: item.url }); const content = load(detailResponse.data); content(".icn_edit, .btn_videoplayer, a[rel=\"bookmark\"]").remove(); content("span").each(function() { if (content(this).attr("class")?.startsWith("icn_")) content(this).remove(); }); item.author = content(".star").toArray().map((star) => content(star).text()).filter((star) => star !== "").join(","); item.category = content("a[rel]").toArray().map((tag) => content(tag).text()).filter((tag) => tag !== ""); item.description = art(path.join(__dirname, "templates/description-bc841822.art"), { cover: content("#video_jacket_img").attr("src"), info: content("#video_info").html().replaceAll("span><span", "span>,&nbsp;<span"), comment: item.description?.replaceAll("[img]", "<img src=\"")?.replaceAll("[/img]", "\"/>"), thumbs: content(".previewthumbs img").toArray().map((img) => content(img).attr("src").replaceAll("-", "jp-")), videos: [...new Set(detailResponse.data.match(/(http[^"[\]]+\.mp4)/g))] }); item.pubDate = item.pubDate.toString() === "Invalid Date" ? parseDate(content("#video_date").find(".text").text()) : item.pubDate; delete item.url; return item; }))); return { title: $("title").text(), link: currentUrl, item: items, allowEmpty: true }; }; //#endregion export { defaultMode as a, defaultMaker as i, defaultGenre as n, rootUrl as o, defaultLanguage as r, ProcessItems as t };