rsshub
Version:
Make RSS Great Again!
48 lines (46 loc) • 1.35 kB
JavaScript
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import { load } from "cheerio";
//#region lib/routes/plurk/utils.ts
const baseUrl = "https://www.plurk.com";
/**
*
* @param {objects} userIds Array of user ids
* @returns
*/
const fetchFriends = async (userIds) => {
const { data } = await got_default.post(`${baseUrl}/Users/fetchFriends`, { form: {
ids: JSON.stringify(userIds),
r: "gp"
} });
return data;
};
/**
*
* @param {string} plurkGuid plurk guid, should start with 'plurk:'
* @param {object} item plurk object
* @param {string} author author name, can be `null`
* @param {function} tryGet cache get function
* @returns {object} item object
*/
const getPlurk = (plurkGuid, item, author, tryGet) => tryGet(plurkGuid, () => {
const $ = load(item.content || item.rendered, null, false);
$("img").each((_, e) => {
e = $(e);
e.removeAttr("height").removeAttr("width");
if (e.attr("alt") && e.attr("alt").startsWith("http")) {
e.attr("src", e.attr("alt"));
e.removeAttr("alt");
}
});
return {
title: item.content_raw ?? ($.text() || plurkGuid),
description: $.html(),
guid: plurkGuid,
link: item.rendered ? item.link_url : null,
author,
pubDate: parseDate(item.posted)
};
});
//#endregion
export { fetchFriends as n, getPlurk as r, baseUrl as t };