diff --git a/docs/new-media.md b/docs/new-media.md index e061e16fe486b1..a693406444ae61 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -2540,6 +2540,10 @@ others = 热点新闻 + 滚动新闻 +### 播客 + + + ## 加美财经 diff --git a/lib/v2/gcores/maintainer.js b/lib/v2/gcores/maintainer.js index f1842790b2ae95..59e6ee7038aacd 100644 --- a/lib/v2/gcores/maintainer.js +++ b/lib/v2/gcores/maintainer.js @@ -1,4 +1,5 @@ module.exports = { '/category/:category': ['MoguCloud', 'StevenRCE0'], + '/radios/:category?': ['eternasuno'], '/tag/:tag/:category?': ['StevenRCE0'], }; diff --git a/lib/v2/gcores/radar.js b/lib/v2/gcores/radar.js index 40bfcdb5294e3c..b05708148de6b4 100644 --- a/lib/v2/gcores/radar.js +++ b/lib/v2/gcores/radar.js @@ -14,6 +14,18 @@ module.exports = { source: ['/categories/:tag', '/'], target: '/gcores/tag/:tag', }, + { + title: '播客', + docs: 'https://docs.rsshub.app/new-media.html#ji-he-wang-bo-ke', + source: ['/radios'], + target: '/gcores/radios', + }, + { + title: '播客-分类', + docs: 'https://docs.rsshub.app/new-media.html#ji-he-wang-bo-ke', + source: ['/categories/:category'], + target: '/gcores/radios/:category', + }, ], }, }; diff --git a/lib/v2/gcores/radio.js b/lib/v2/gcores/radio.js new file mode 100644 index 00000000000000..ed921dc52032ba --- /dev/null +++ b/lib/v2/gcores/radio.js @@ -0,0 +1,90 @@ +const { art } = require('@/utils/render'); +const { parseDate } = require('@/utils/parse-date'); +const cheerio = require('cheerio'); +const got = require('@/utils/got'); +const md5 = require('@/utils/md5'); +const path = require('path'); + +module.exports = async (ctx) => { + const category = ctx.params.category || 'all'; + const limit = parseInt(ctx.query.limit) || 12; + + const link = getLink(category); + const $ = cheerio.load(await get(link)); + const title = $('head>title').text(); + const description = $('head>meta[name="description"]').attr('content'); + const image = $('head>link[rel="apple-touch-icon"]').attr('href'); + + const api = getApi(category); + api.searchParams.set('include', 'media'); + api.searchParams.set('page[limit]', limit); + api.searchParams.set('sort', '-published-at'); + api.searchParams.set('filter[list-all]', '0'); + api.searchParams.set('fields[radios]', 'title,cover,published-at,duration,content,media'); + const { data, included } = await get(api); + + const audios = included.reduce((result, media) => { + result[media.id] = media.attributes.audio; + return result; + }, {}); + + const item = data.map((radio) => { + const { id, attributes, relationships } = radio; + + const link = `https://www.gcores.com/radios/${id}`; + const itunes_item_image = `https://image.gcores.com/${attributes.cover}`; + const media_id = relationships.media.data.id; + const enclosure_url = new URL(audios[media_id], 'https://alioss.gcores.com/uploads/audio/').toString(); + const description = art(path.join(__dirname, 'templates/content.art'), { + content: JSON.parse(attributes.content), + }); + + return { + title: attributes.title, + author: '机核 GCORES', + description, + pubDate: parseDate(attributes['published-at']), + guid: md5(link), + link, + itunes_item_image, + itunes_duration: attributes.duration, + enclosure_url, + enclosure_type: 'audio/mpeg', + }; + }); + + ctx.state.data = { + title, + link, + description, + language: 'zh-cn', + itunes_author: '机核 GCORES', + image: `https://www.gcores.com/${image}`, + item, + }; +}; + +const get = async (url) => { + const response = await got({ + method: 'get', + url: new URL(url, 'https://www.gcores.com'), + }); + + return response.data; +}; + +const getLink = (category) => { + if (category === 'all') { + return 'https://www.gcores.com/radios'; + } else { + return `https://www.gcores.com/categories/${category}`; + } +}; + +const getApi = (category) => { + if (category === 'all') { + return new URL('https://www.gcores.com/gapi/v1/radios'); + } else { + return new URL(`https://www.gcores.com/gapi/v1/categories/${category}/radios`); + } +}; diff --git a/lib/v2/gcores/router.js b/lib/v2/gcores/router.js index 4cf4aa275106c8..cf555d2e520ed8 100644 --- a/lib/v2/gcores/router.js +++ b/lib/v2/gcores/router.js @@ -1,4 +1,5 @@ module.exports = function (router) { router.get('/category/:category', require('./category')); + router.get('/radios/:category?', require('./radio')); router.get('/tag/:tag/:category?', require('./tag')); }; diff --git a/lib/v2/gcores/templates/content.art b/lib/v2/gcores/templates/content.art new file mode 100644 index 00000000000000..5cce07e6ba687e --- /dev/null +++ b/lib/v2/gcores/templates/content.art @@ -0,0 +1,16 @@ +{{if content}} + {{each content.blocks line}} + {{if line.type === 'unstyled'}} +

{{line.text}}

+ {{/if}} + {{/each}} + + {{each content.entityMap ent}} + {{if ent.type === 'WIDGET'}} +

{{ent.data.title}}

+ {{/if}} + {{/each}} +{{else}} +

机核从2010年开始一直致力于分享游戏玩家的生活,以及深入探讨游戏相关的文化。我们开发原创的播客以及视频节目,一直在不断寻找民间高质量的内容创作者。

+

我们坚信游戏不止是游戏,游戏中包含的科学,文化,历史等各个层面的知识和故事,它们同时也会辐射到二次元甚至电影的领域,这些内容非常值得分享给热爱游戏的您。

+{{/if}} diff --git a/package.json b/package.json index f2f1b951b0e344..d9a35f55fbe4ba 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "@vuepress/shared-utils": "1.9.9", "cross-env": "7.0.3", "eslint": "8.36.0", - "eslint-config-prettier": "8.7.0", + "eslint-config-prettier": "8.8.0", "eslint-plugin-prettier": "4.2.1", "eslint-plugin-yml": "1.5.0", "fs-extra": "11.1.1", @@ -68,7 +68,7 @@ "mockdate": "3.0.5", "nock": "13.3.0", "nodemon": "2.0.21", - "prettier": "2.8.5", + "prettier": "2.8.6", "prettier-check": "2.0.0", "pretty-quick": "3.1.3", "remark": "13.0.0", @@ -92,7 +92,7 @@ "dependencies": { "@koa/router": "12.0.0", "@postlight/parser": "2.2.3", - "@sentry/node": "7.43.0", + "@sentry/node": "7.44.2", "aes-js": "3.1.2", "art-template": "4.13.2", "bbcodejs": "0.0.4", diff --git a/yarn.lock b/yarn.lock index c5cedfd2d470fe..640887c6a2381c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1590,39 +1590,39 @@ domhandler "^5.0.3" selderee "^0.10.0" -"@sentry/core@7.43.0": - version "7.43.0" - resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.43.0.tgz#c78e79399172738c96e3b388244258153c49215f" - integrity sha512-zvMZgEi7ptLBwDnd+xR/u4zdSe5UzS4S3ZhoemdQrn1PxsaVySD/ptyzLoGSZEABqlRxGHnQrZ78MU1hUDvKuQ== +"@sentry/core@7.44.2": + version "7.44.2" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.44.2.tgz#e33b2880e83cc4aaaa3d1b8a160588484d0e2624" + integrity sha512-m2nOHP4YX+kmWFQTzgBEsdblCuNFSB7017oLaR6/VH0a0mVWdrW7Q1gHMpw4/08uWRiA+oC2dXqCH7A1FwfGIQ== dependencies: - "@sentry/types" "7.43.0" - "@sentry/utils" "7.43.0" + "@sentry/types" "7.44.2" + "@sentry/utils" "7.44.2" tslib "^1.9.3" -"@sentry/node@7.43.0": - version "7.43.0" - resolved "https://registry.yarnpkg.com/@sentry/node/-/node-7.43.0.tgz#bcb553486ffe3f1413063e9125fd34f9d84277d2" - integrity sha512-oXaTBq6Bk8Qwsd46hhRU2MLEnjYqWI41nPJmXyAWkDSYQTP7sUe1qM8bCUdsRpPwQh955Vq9qCRfgMbN4lEoAQ== +"@sentry/node@7.44.2": + version "7.44.2" + resolved "https://registry.yarnpkg.com/@sentry/node/-/node-7.44.2.tgz#e37864790d95b91d1a2610ee59af36eda6807ac2" + integrity sha512-tEMcT+di7q7OYZt8Lg9kIpXoSO1YQNhnfMyffpzC82TMyJGNclBllNTF/UUnPqEiRW8WeewNgWuJAMLpPzjmfw== dependencies: - "@sentry/core" "7.43.0" - "@sentry/types" "7.43.0" - "@sentry/utils" "7.43.0" + "@sentry/core" "7.44.2" + "@sentry/types" "7.44.2" + "@sentry/utils" "7.44.2" cookie "^0.4.1" https-proxy-agent "^5.0.0" lru_map "^0.3.3" tslib "^1.9.3" -"@sentry/types@7.43.0": - version "7.43.0" - resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.43.0.tgz#e621257601e9db2a39cdd3bd75e67fe338ed51eb" - integrity sha512-5XxCWqYWJNoS+P6Ie2ZpUDxLRCt7FTEzmlQkCdjW6MFWOX26hAbF/wEuOTYAFKZXMIXOz0Egofik1e8v1Cg6/A== +"@sentry/types@7.44.2": + version "7.44.2" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.44.2.tgz#c8acdd884f4daf03f3e813935e9e16da71473247" + integrity sha512-vdGb2BAelXRitgKWRBF1cCAoisLsbugUaJzrGCQoIoS3lYpZ8d8r2zELE7cNoVObVoQbUHF/WFhXVv8cumj+RA== -"@sentry/utils@7.43.0": - version "7.43.0" - resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.43.0.tgz#ad16efb86b94ffe6dca2ed2b299d5230ba6d815b" - integrity sha512-f78YfMLcgNU7+suyWFCuQhQlneXXMS+egb0EFZh7iU7kANUPRX5T4b+0C+fwaPm5gA6XfGYskr4ZnzQJLOlSqg== +"@sentry/utils@7.44.2": + version "7.44.2" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.44.2.tgz#a2f77713fec4471076e79e050c75561c21ad8abb" + integrity sha512-PzL4Z0fhIHfQacfWvgiAs+drcm4Nc45Tc8PW1RdOZtHxzhGAYZYAPniDGML586Mnlu19QM6kGHiDu+CBgnnXAQ== dependencies: - "@sentry/types" "7.43.0" + "@sentry/types" "7.44.2" tslib "^1.9.3" "@sinclair/typebox@^0.25.16": @@ -5620,10 +5620,10 @@ escodegen@^2.0.0: optionalDependencies: source-map "~0.6.1" -eslint-config-prettier@8.7.0: - version "8.7.0" - resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.7.0.tgz#f1cc58a8afebc50980bd53475451df146c13182d" - integrity sha512-HHVXLSlVUhMSmyW4ZzEuvjpwqamgmlfkutD53cYXLikh4pt/modINRcCIApJ84czDxM4GZInwUrromsDdTImTA== +eslint-config-prettier@8.8.0: + version "8.8.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.8.0.tgz#bfda738d412adc917fd7b038857110efe98c9348" + integrity sha512-wLbQiFre3tdGgpDv67NQKnJuTlcUVYHas3k+DZCc2U2BadthoEY4B7hLPvAxaqdyOGCzuLfii2fqGph10va7oA== eslint-plugin-prettier@4.2.1: version "4.2.1" @@ -11148,10 +11148,10 @@ prettier-linter-helpers@^1.0.0: dependencies: fast-diff "^1.1.2" -prettier@2.8.5, "prettier@^1.18.2 || ^2.0.0": - version "2.8.5" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.5.tgz#3dd8ae1ebddc4f6aa419c9b64d8c8319a7e0d982" - integrity sha512-3gzuxrHbKUePRBB4ZeU08VNkUcqEHaUaouNt0m7LGP4Hti/NuB07C7PPTM/LkWqXoJYJn2McEo5+kxPNrtQkLQ== +prettier@2.8.6, "prettier@^1.18.2 || ^2.0.0": + version "2.8.6" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.6.tgz#5c174b29befd507f14b83e3c19f83fdc0e974b71" + integrity sha512-mtuzdiBbHwPEgl7NxWlqOkithPyp4VN93V7VeHVWBF+ad3I5avc0RVDT4oImXQy9H/AqxA2NSQH8pSxHW6FYbQ== pretty-bytes@^5.1.0: version "5.6.0"