rsshub
Version:
Make RSS Great Again!
46 lines (45 loc) • 1.29 kB
JavaScript
import { t as parseDate } from "./parse-date-Cr0wQjV_.mjs";
import { t as got_default } from "./got-BTowW50G.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`
* @returns {object} item object
*/
const getPlurk = (plurkGuid, item, author) => {
const $ = load(item.content || item.rendered, null, false);
$("img").each((_, e) => {
const $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 };