diff --git a/docs/government.md b/docs/government.md index 9b3e168660..44b19698e2 100644 --- a/docs/government.md +++ b/docs/government.md @@ -266,11 +266,23 @@ pageClass: routes ### 分类 - + | 总局要闻 | 公告公示 | 工作动态 | 其他 | -| :------: | :------: | :------: | :--: | -| 112 | 113 | 114 | | +| -------- | -------- | -------- | ---- | +| 112 | 113 | 114 | | + + + +### 电视剧政务平台 + + + +| 备案公示 | 发行许可通告 | 重大题材立项 | 重大题材摄制 | 变更通报 | +| -------- | ------------ | ---------------- | --------------- | -------- | +| note | announce | importantLixiang | importantShezhi | changing | + + ## 国家税务总局 diff --git a/lib/v2/gov/maintainer.js b/lib/v2/gov/maintainer.js index 2e6c8a5cef..7a77226ab6 100644 --- a/lib/v2/gov/maintainer.js +++ b/lib/v2/gov/maintainer.js @@ -36,6 +36,7 @@ module.exports = { '/nmpa/:path+': ['TonyRL'], '/nopss/:path+': ['nczitzk'], '/nrta/news/:category?': ['yuxinliu-alex'], + '/nrta/dsj/:category?': ['nczitzk'], '/nsfc/news/:type?': ['Derekmini', 'nczitzk'], '/pbc/goutongjiaoliu': ['nczitzk'], '/pbc/gzlw': ['Fatpandac'], diff --git a/lib/v2/gov/nrta/dsj.js b/lib/v2/gov/nrta/dsj.js new file mode 100644 index 0000000000..f150a98052 --- /dev/null +++ b/lib/v2/gov/nrta/dsj.js @@ -0,0 +1,59 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const asyncPool = require('tiny-async-pool'); + +module.exports = async (ctx) => { + const { category = 'note' } = ctx.params; + const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 15; + + const rootUrl = 'https://dsj.nrta.gov.cn'; + const currentUrl = new URL(`tims/site/views/applications.shanty?appName=${category}`, rootUrl).href; + + const { data: response } = await got(currentUrl); + + const $ = cheerio.load(response); + + const items = $('img[src="/site/styles/default/images/icon_arrow_r.gif"]') + .slice(0, limit) + .toArray() + .map((item) => { + item = $(item).next(); + + const pubDateMatches = item.text().match(/(\d+年\d+月)/); + + return { + title: item.text(), + link: new URL(item.prop('href'), rootUrl).href, + pubDate: pubDateMatches ? parseDate(pubDateMatches[1], ['YYYY年MM月', 'YYYY年M月']) : undefined, + }; + }); + + const results = []; + + for await (const item of asyncPool(5, items, (item) => + ctx.cache.tryGet(item.link, async () => { + const { data: detailResponse } = await got(item.link); + + const content = cheerio.load(detailResponse); + + content('table').last().remove(); + + item.description = content('td.newstext').html() || content('table').last().parent().parent().html(); + + return item; + }) + )) { + results.push(item); + } + + ctx.state.data = { + item: results, + title: `${$('title').text()}-${$('div.headbottom_menu_selected').text()}`, + link: currentUrl, + description: $('td').last().text(), + language: 'zh-cn', + image: $('img').first().prop('src'), + author: '国家广播电影电视总局电视剧管理司', + }; +}; diff --git a/lib/v2/gov/radar.js b/lib/v2/gov/radar.js index 9742d261f4..a332eb628e 100644 --- a/lib/v2/gov/radar.js +++ b/lib/v2/gov/radar.js @@ -828,6 +828,19 @@ module.exports = { target: (params) => `/gov/nrta/news/${params.category.replace('col', '').replace('/index.html', '')}`, }, ], + dsj: [ + { + title: '电视剧政务平台', + docs: 'https://docs.rsshub.app/government.html#guo-jia-guang-bo-dian-shi-zong-ju', + source: ['/tims/site/views/applications.shanty', '/'], + target: (params, url) => { + url = new URL(url); + const category = url.searchParams.get('appName'); + + return `/gov/nrta/dsj/${category}`; + }, + }, + ], }, 'nsfc.gov.cn': { _name: '国家自然科学基金委员会', diff --git a/lib/v2/gov/router.js b/lib/v2/gov/router.js index 7f0469e88b..51b1da7a5e 100644 --- a/lib/v2/gov/router.js +++ b/lib/v2/gov/router.js @@ -28,6 +28,7 @@ module.exports = function (router) { router.get(/\/nmpa\/([\w][\w/]+)?/, require('./nmpa/generic')); router.get(/nopss(\/[\w/-]+)?/, require('./nopss')); router.get('/nrta/news/:category?', require('./nrta/news')); + router.get('/nrta/dsj/:category?', require('./nrta/dsj')); router.get('/nsfc/news/:type?', require('./nsfc')); router.get('/pbc/goutongjiaoliu', require('./pbc/goutongjiaoliu')); router.get('/pbc/gzlw', require('./pbc/gzlw'));