diff --git a/scripts/favicon.ts b/scripts/favicon.ts index 3875cfc..3eb4e05 100644 --- a/scripts/favicon.ts +++ b/scripts/favicon.ts @@ -1,4 +1,5 @@ import fs from "node:fs" + import { fileURLToPath } from "node:url" import { join } from "node:path" import { Buffer } from "node:buffer" @@ -27,7 +28,7 @@ async function main() { await Promise.all( Object.entries(originSources).map(async ([id, source]) => { try { - const icon = join(iconsDir, `${id.split("-")[0]}.png`) + const icon = join(iconsDir, `${id}.png`) if (fs.existsSync(icon)) { consola.info(`${id}: icon exists. skip.`) return diff --git a/server/sources/index.ts b/server/sources/index.ts index 597286d..f437177 100644 --- a/server/sources/index.ts +++ b/server/sources/index.ts @@ -6,6 +6,7 @@ import ithome from "./ithome" import zhihu from "./zhihu" import cankaoxiaoxi from "./cankaoxiaoxi" import coolapk from "./coolapk" +import sputniknewscn from "./sputniknewscn" export const sourcesFn = { weibo, @@ -15,10 +16,10 @@ export const sourcesFn = { zhihu, coolapk, cankaoxiaoxi, + sputniknewscn, "peopledaily": defineRSSSource("https://feedx.net/rss/people.xml", { hiddenDate: true, }), - "sputniknewscn": defineRSSHubSource("/sputniknews/news/chinese"), "douyin": defineFallbackSource("douyin"), "aljazeeracn": defineRSSSource("https://feedx.net/rss/aljazeera.xml"), "toutiao": defineFallbackSource("toutiao"), diff --git a/server/sources/sputniknewscn.ts b/server/sources/sputniknewscn.ts new file mode 100644 index 0000000..d1d84a2 --- /dev/null +++ b/server/sources/sputniknewscn.ts @@ -0,0 +1,28 @@ +import * as cheerio from "cheerio" +import type { NewsItem } from "@shared/types" +import { $fetch } from "ofetch" + +export default defineSource(async () => { + const response = await $fetch("https://sputniknews.cn/services/widget/lenta/") + const $ = cheerio.load(response) + const $items = $(".lenta__item") + const news: NewsItem[] = [] + $items.each((_, el) => { + const $el = $(el) + const $a = $el.find("a") + const url = $a.attr("href") + const title = $a.find(".lenta__item-text").text() + const date = $a.find(".lenta__item-date").attr("data-unixtime") + if (url && title && date) { + news.push({ + url, + title, + id: url, + extra: { + date: new Date(Number(`${date}000`)).getTime(), + }, + }) + } + }) + return news.slice(0, 20) +}) diff --git a/shared/sources.ts b/shared/sources.ts index 2d2c085..d786995 100644 --- a/shared/sources.ts +++ b/shared/sources.ts @@ -22,7 +22,6 @@ export const originSources = { }, "sputniknewscn": { name: "俄罗斯卫星通讯社", - interval: Time.half, home: "https://sputniknews.cn", }, "aljazeeracn": {