diff --git a/docs/en/traditional-media.md b/docs/en/traditional-media.md index f4dc0a7218..52c5402acf 100644 --- a/docs/en/traditional-media.md +++ b/docs/en/traditional-media.md @@ -238,6 +238,60 @@ This route adds the missing photo and Link element. (Offical RSS doesn't have Li +## SBS + +### Chinese + + + +::: tip Tip + +When subscribing to podcasts, fill `category` with **podcast**. For example, URL to [SBS 普通话电台](https://www.sbs.com.au/chinese/mandarin/zh-hans/podcast/sbs-mandarin) is , with **sbs-mandarin** as `id`, **mandarin** as `dialect`, `language` as **zh-hans**, and the route is [`/sbs/chinese/podcast/sbs-mandarin/mandarin/zh-hans`](https://rsshub.app/sbs/chinese/podcast/sbs-mandarin/mandarin/zh-hans). + +::: + +| 新闻 | 澳大利亚新闻 | 国际新闻 | ​商业与财经 | +| ---- | --------------- | ------------------ | ---------------- | +| news | australian-news | international-news | business-finance | + +| 澳中关系 | ​移民与签证 | Stories in English | +| ------------------------- | ----------- | ------------------ | +| australia-china-relations | immigration | english | + +| COVID-19 专题报道 | 澳大利亚华人 | 澳大利亚生活 | 教育 | +| ----------------- | ------------------ | ----------------- | --------- | +| coronavirus | australian-chinese | life-in-australia | education | + +| 健康 | 吃喝玩乐 | 艺术人文 | 澳洲定居指南 | +| ------ | ------------------------- | --------------- | ---------------- | +| health | food-travel-entertainment | cultural-events | settlement-guide | + +SBS Mandarin Programs: + +| SBS 普通话播客 | 解读澳洲 | 疫苗快报 | +| -------------- | ------------------- | -------------------------- | +| sbs-mandarin | australia-explained | covid-vaccine-daily-update | + +SBS Cantonese Programs: + +| SBS 廣東話節目 Podcast | 疫苗快報 | 美食速遞 | 我不是名人 | +| ---------------------- | ------------------- | --------------- | ------------------- | +| sbs-cantonese | covid-vaccine-daily | gourmet-express | my-australian-story | + +| 健康快樂人 | 園藝趣談 | 寰宇金融 | 文化 360 | 科技世界 | +| ------------------ | -------------- | -------------- | ----------- | ---------------- | +| healthy-happy-life | gardening-tips | global-finance | culture-360 | technology-world | + +::: tip Tip + +Mostly, you can omit `language`, for the reason that **madarin** is with **zh-hans** and **cantonese** is with **zh-hant** by default. For example, the route of [SBS 普通话电台](https://www.sbs.com.au/chinese/mandarin/zh-hans/podcast/sbs-mandarin) is [`/sbs/chinese/podcast/sbs-mandarin/mandarin/zh-hans`](https://rsshub.app/sbs/chinese/podcast/sbs-mandarin/mandarin/zh-hans), which can also be [`/sbs/chinese/podcast/sbs-mandarin/mandarin`](https://rsshub.app/sbs/chinese/podcast/sbs-mandarin/mandarin). + +You still can customize `language`, however, it is important to note that not all pages are available in bilingual versions. + +::: + + + ## SCMP ### News diff --git a/docs/traditional-media.md b/docs/traditional-media.md index 68666ab5cc..5906899482 100644 --- a/docs/traditional-media.md +++ b/docs/traditional-media.md @@ -242,6 +242,60 @@ pageClass: routes +## SBS + +### 中文 + + + +::: tip 提示 + +当订阅播客时,请为 `category` 填入 **podcast**。如 [SBS 普通话电台](https://www.sbs.com.au/chinese/mandarin/zh-hans/podcast/sbs-mandarin) 的 URL 为 ,其中 `id` 为 **sbs-mandarin**,`dialect` 为 **mandarin**,`language` 为 **zh-hans**,其路由即为 [`/sbs/chinese/podcast/sbs-mandarin/mandarin/zh-hans`](https://rsshub.app/sbs/chinese/podcast/sbs-mandarin/mandarin/zh-hans)。 + +::: + +| 新闻 | 澳大利亚新闻 | 国际新闻 | ​商业与财经 | +| ---- | --------------- | ------------------ | ---------------- | +| news | australian-news | international-news | business-finance | + +| 澳中关系 | ​移民与签证 | Stories in English | +| ------------------------- | ----------- | ------------------ | +| australia-china-relations | immigration | english | + +| COVID-19 专题报道 | 澳大利亚华人 | 澳大利亚生活 | 教育 | +| ----------------- | ------------------ | ----------------- | --------- | +| coronavirus | australian-chinese | life-in-australia | education | + +| 健康 | 吃喝玩乐 | 艺术人文 | 澳洲定居指南 | +| ------ | ------------------------- | --------------- | ---------------- | +| health | food-travel-entertainment | cultural-events | settlement-guide | + +SBS 普通话节目: + +| SBS 普通话播客 | 解读澳洲 | 疫苗快报 | +| -------------- | ------------------- | -------------------------- | +| sbs-mandarin | australia-explained | covid-vaccine-daily-update | + +SBS 廣東話節目: + +| SBS 廣東話節目 Podcast | 疫苗快報 | 美食速遞 | 我不是名人 | +| ---------------------- | ------------------- | --------------- | ------------------- | +| sbs-cantonese | covid-vaccine-daily | gourmet-express | my-australian-story | + +| 健康快樂人 | 園藝趣談 | 寰宇金融 | 文化 360 | 科技世界 | +| ------------------ | -------------- | -------------- | ----------- | ---------------- | +| healthy-happy-life | gardening-tips | global-finance | culture-360 | technology-world | + +::: tip 提示 + +大部分时候你可以省略 `language` 字段,因为默认搭配 madarin 为 zh-hans,cantonese 为 zh-hant。如 [SBS 普通话电台](https://www.sbs.com.au/chinese/mandarin/zh-hans/podcast/sbs-mandarin) 路由为 [`/sbs/chinese/podcast/sbs-mandarin/mandarin/zh-hans`](https://rsshub.app/sbs/chinese/podcast/sbs-mandarin/mandarin/zh-hans),你可以省略为 [`/sbs/chinese/podcast/sbs-mandarin/mandarin`](https://rsshub.app/sbs/chinese/podcast/sbs-mandarin/mandarin)。 + +你仍可以自定义 `language`,但需要注意的是,并非所有页面都有对应的双语版本。 + +::: + + + ## Solidot ### 最新消息 diff --git a/lib/router.js b/lib/router.js index 40dabfbf79..13b4effb04 100644 --- a/lib/router.js +++ b/lib/router.js @@ -4234,6 +4234,9 @@ router.get('/now/news/rank', lazyloadRouteHandler('./routes/now/rank')); // s-hentai router.get('/s-hentai/:id?', lazyloadRouteHandler('./routes/s-hentai')); +// SBS +router.get('/sbs/chinese/:category?/:id?/:dialect?/:language?', lazyloadRouteHandler('./routes/sbs/chinese')); + // Asian to lick router.get('/asiantolick/:category?/:keyword?', lazyloadRouteHandler('./routes/asiantolick')); diff --git a/lib/routes/sbs/chinese.js b/lib/routes/sbs/chinese.js new file mode 100644 index 0000000000..db236b2c73 --- /dev/null +++ b/lib/routes/sbs/chinese.js @@ -0,0 +1,70 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const id = ctx.params.id ?? 'news'; + const dialect = ctx.params.dialect ?? 'mandarin'; + const category = ctx.params.category ?? 'news'; + const language = ctx.params.language ?? dialect === 'mandarin' ? 'zh-hans' : 'zh-hant'; + + const rootUrl = 'https://www.sbs.com.au'; + const currentUrl = `${rootUrl}/language/${dialect}/${category === 'podcast' ? `${language}/podcast/${id}` : `${id}/${language}`}`; + + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + const list = $('.headline, .audio-playlist__item-more') + .find('a') + .map((_, item) => { + item = $(item); + + return { + link: `${rootUrl}${item.attr('href')}`, + }; + }) + .get(); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + + const content = cheerio.load(detailResponse.data); + + content('.block__container').remove(); + + const audio = content('a[download]')?.attr('href') ?? ''; + const image = content('meta[itemprop="image"]')?.attr('content').split('/crop/')[0] ?? ''; + + item.title = content('meta[property="og:title"]').attr('content'); + item.author = content('.article__meta-author').text().trim().replace('By', ''); + item.pubDate = parseDate(content('meta[itemprop="datePublished"]').attr('content')); + item.description = `${image ? `
` : ''}${audio ? `
` : ''}${content('.text-body').html()}`; + + if (audio) { + item.itunes_item_image = image; + item.enclosure_url = audio; + item.enclosure_type = 'audio/mpeg'; + } + + return item; + }) + ) + ); + + ctx.state.data = { + title: `${$('meta[property="og:title"]').attr('content')} - SBS中文`, + link: currentUrl, + item: items, + itunes_author: 'SBS中文', + image: `${rootUrl}/language/img/logos/in-language/logo_chinese.svg`, + }; +};