From 3965da8765b3c05b9840408260e73be36f1b15d7 Mon Sep 17 00:00:00 2001 From: Ethan Shen Date: Fri, 11 Mar 2022 00:17:13 +0800 Subject: [PATCH] feat(route): add Sputnik News (#9294) --- docs/en/traditional-media.md | 55 ++++++++++++++++++++++++++++++++ docs/traditional-media.md | 45 +++++++++++++++++++++++++- lib/v2/sputniknews/index.js | 40 +++++++++++++++++++++-- lib/v2/sputniknews/maintainer.js | 2 +- lib/v2/sputniknews/radar.js | 2 +- lib/v2/sputniknews/router.js | 2 +- 6 files changed, 139 insertions(+), 7 deletions(-) diff --git a/docs/en/traditional-media.md b/docs/en/traditional-media.md index 823076f4d..c352e0f6b 100644 --- a/docs/en/traditional-media.md +++ b/docs/en/traditional-media.md @@ -334,6 +334,61 @@ See the [official RSS page](https://www.scmp.com/rss) to get the ID of each cate +## Sputnik News + +### Category + + + +Categories for International site: + +| WORLD | COVID-19 | BUSINESS | SPORT | TECH | OPINION | +| ----- | -------- | -------- | ----- | ---- | ------- | +| world | covid-19 | business | sport | tech | opinion | + +Categories for Chinese site: + +| 新闻 | 中国 | 俄罗斯 | 国际 | 俄中关系 | 评论 | +| ---- | ----- | ------ | -------------- | ---------------------- | ------- | +| news | china | russia | category_guoji | russia_china_relations | opinion | + +Language + +| Language | Id | +| ----------- | ----------- | +| English | english | +| Spanish | spanish | +| German | german | +| French | french | +| Greek | greek | +| Italian | italian | +| Czech | czech | +| Polish | polish | +| Serbian | serbian | +| Latvian | latvian | +| Lithuanian | lithuanian | +| Moldavian | moldavian | +| Belarusian | belarusian | +| Armenian | armenian | +| Abkhaz | abkhaz | +| Ssetian | ssetian | +| Georgian | georgian | +| Azerbaijani | azerbaijani | +| Arabic | arabic | +| Turkish | turkish | +| Persian | persian | +| Dari | dari | +| Kazakh | kazakh | +| Kyrgyz | kyrgyz | +| Uzbek | uzbek | +| Tajik | tajik | +| Vietnamese | vietnamese | +| Japanese | japanese | +| Chinese | chinese | +| Portuguese | portuguese | + + + ## The Economist ### Category diff --git a/docs/traditional-media.md b/docs/traditional-media.md index 0ffa3bf1f..47e1eae35 100644 --- a/docs/traditional-media.md +++ b/docs/traditional-media.md @@ -770,12 +770,55 @@ Type 栏目: ### 分类 - + + +以下为国际站的部分分类: + +| WORLD | COVID-19 | BUSINESS | SPORT | TECH | OPINION | +| ----- | -------- | -------- | ----- | ---- | ------- | +| world | covid-19 | business | sport | tech | opinion | + +以下为中国站的部分分类: | 新闻 | 中国 | 俄罗斯 | 国际 | 俄中关系 | 评论 | | ---- | ----- | ------ | -------------- | ---------------------- | ------- | | news | china | russia | category_guoji | russia_china_relations | opinion | +语言 + +| 语言 | 编号 | +| ----------- | ----------- | +| English | english | +| Spanish | spanish | +| German | german | +| French | french | +| Greek | greek | +| Italian | italian | +| Czech | czech | +| Polish | polish | +| Serbian | serbian | +| Latvian | latvian | +| Lithuanian | lithuanian | +| Moldavian | moldavian | +| Belarusian | belarusian | +| Armenian | armenian | +| Abkhaz | abkhaz | +| Ssetian | ssetian | +| Georgian | georgian | +| Azerbaijani | azerbaijani | +| Arabic | arabic | +| Turkish | turkish | +| Persian | persian | +| Dari | dari | +| Kazakh | kazakh | +| Kyrgyz | kyrgyz | +| Uzbek | uzbek | +| Tajik | tajik | +| Vietnamese | vietnamese | +| Japanese | japanese | +| Chinese | chinese | +| Portuguese | portuguese | + ## 公視新聞網 diff --git a/lib/v2/sputniknews/index.js b/lib/v2/sputniknews/index.js index 362d89099..3de266fff 100644 --- a/lib/v2/sputniknews/index.js +++ b/lib/v2/sputniknews/index.js @@ -2,10 +2,44 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); const { parseDate } = require('@/utils/parse-date'); +const languages = { + english: 'https://sputniknews.com', + spanish: 'https://mundo.sputniknews.com', + german: 'https://snanews.de', + french: 'https://fr.sputniknews.com', + greek: 'https://sputniknews.gr', + italian: 'https://it.sputniknews.com', + czech: 'https://cz.sputniknews.com', + polish: 'https://pl.sputniknews.com', + serbian: 'https://rs.sputniknews.com', + latvian: 'https://sputniknewslv.com', + lithuanian: 'https://lt.sputniknews.com', + moldavian: 'https://md.sputniknews.com', + belarusian: 'https://bel.sputnik.by', + armenian: 'https://armeniasputnik.am', + abkhaz: 'https://sputnik-abkhazia.info', + ssetian: 'https://sputnik-ossetia.com', + georgian: 'https://sputnik-georgia.com', + azerbaijani: 'https://sputnik.az', + arabic: 'https://arabic.sputniknews.com', + turkish: 'https://tr.sputniknews.com', + persian: 'https://ir.sputniknews.com', + dari: 'https://af.sputniknews.com', + kazakh: 'https://sputniknews.kz', + kyrgyz: 'https://kg.sputniknews.com', + uzbek: 'https://oz.sputniknews-uz.com', + tajik: 'https://sputnik-tj.com', + vietnamese: 'https://vn.sputniknews.com', + japanese: 'https://jp.sputniknews.com', + chinese: 'http://sputniknews.cn', + portuguese: 'https://br.sputniknews.com', +}; + module.exports = async (ctx) => { const category = ctx.params.category ?? 'news'; + const language = ctx.params.language ?? 'english'; - const rootUrl = 'https://sputniknews.cn'; + const rootUrl = languages[language]; const currentUrl = `${rootUrl}/services/${category}/more.html`; const response = await got({ @@ -40,7 +74,7 @@ module.exports = async (ctx) => { .toArray() .map((tag) => content(tag).text()); - content('.article__meta, .article__title, .article__info, .article__quote-bg, .article__footer, .m-buy, .photoview__ext-link').remove(); + content('.article__meta, .article__title, .article__info, .article__quote-bg, .article__google-news, .article__footer, .m-buy, .photoview__ext-link').remove(); content('div[data-type="article"]').remove(); item.description = content('.article').html(); @@ -52,7 +86,7 @@ module.exports = async (ctx) => { ); ctx.state.data = { - title: `${category} - 俄罗斯卫星通讯社`, + title: `${category} - Sputnik News`, link: `${rootUrl}/${category}`, item: items, }; diff --git a/lib/v2/sputniknews/maintainer.js b/lib/v2/sputniknews/maintainer.js index 81eb78d73..a30a88e09 100644 --- a/lib/v2/sputniknews/maintainer.js +++ b/lib/v2/sputniknews/maintainer.js @@ -1,3 +1,3 @@ module.exports = { - '/:category?': ['nczitzk'], + '/:category?/:language?': ['nczitzk'], }; diff --git a/lib/v2/sputniknews/radar.js b/lib/v2/sputniknews/radar.js index c3bae5fed..44a1dbf92 100644 --- a/lib/v2/sputniknews/radar.js +++ b/lib/v2/sputniknews/radar.js @@ -6,7 +6,7 @@ module.exports = { title: '分类', docs: 'https://docs.rsshub.app/traditional-media.html#e-luo-si-wei-xing-tong-xun-she-fen-lei', source: ['/:category', '/'], - target: '/sputniknews/:category', + target: '/sputniknews/:category/:language', }, ], }, diff --git a/lib/v2/sputniknews/router.js b/lib/v2/sputniknews/router.js index cf781366f..46e97aff8 100644 --- a/lib/v2/sputniknews/router.js +++ b/lib/v2/sputniknews/router.js @@ -1,3 +1,3 @@ module.exports = function (router) { - router.get('/:category?', require('./index')); + router.get('/:category?/:language?', require('./index')); };