forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(route): duplicate-object-key (DIYgod#15494)
* fix(route): duplicate-object-key * fix: split routes * fix: split routes * fix: typo
- Loading branch information
Showing
41 changed files
with
495 additions
and
420 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Route } from '@/types'; | ||
import { handler } from './common'; | ||
|
||
export const route: Route = { | ||
name: '分类', | ||
path: ['/category/:id'], | ||
example: '/cnbeta/category/movie', | ||
maintainers: ['nczitzk'], | ||
parameters: { | ||
id: '分类 id,可在对应分类页的 URL 中找到', | ||
}, | ||
radar: [ | ||
{ | ||
source: ['cnbeta.com.tw/category/:id'], | ||
target: (params) => `/cnbeta/category/${params.id.replace('.htm', '')}`, | ||
}, | ||
], | ||
handler, | ||
url: 'cnbeta.com.tw', | ||
description: `| 影视 | 音乐 | 游戏 | 动漫 | 趣闻 | 科学 | 软件 | | ||
| ----- | ----- | ---- | ----- | ----- | ------- | ---- | | ||
| movie | music | game | comic | funny | science | soft |`, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Route } from '@/types'; | ||
import { handler } from './common'; | ||
|
||
export const route: Route = { | ||
name: '头条资讯', | ||
path: ['/'], | ||
example: '/cnbeta', | ||
radar: [ | ||
{ | ||
source: ['cnbeta.com.tw/'], | ||
}, | ||
], | ||
maintainers: ['kt286', 'HaitianLiu', 'nczitzk'], | ||
handler, | ||
url: 'cnbeta.com.tw', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Route } from '@/types'; | ||
import { handler } from './common'; | ||
|
||
export const route: Route = { | ||
name: '主题', | ||
path: ['/topics/:id'], | ||
example: '/cnbeta/topics/453', | ||
maintainers: ['cczhong11', 'nczitzk'], | ||
parameters: { | ||
id: '主题 id,可在对应主题页的 URL 中找到', | ||
}, | ||
radar: [ | ||
{ | ||
source: ['cnbeta.com.tw/topics/:id'], | ||
target: (params) => `/cnbeta/topics/${params.id.replace('.htm', '')}`, | ||
}, | ||
], | ||
handler, | ||
url: 'cnbeta.com.tw', | ||
description: `::: tip | ||
完整的主题列表参见 [主题列表](https://www.cnbeta.com.tw/topics.htm) | ||
:::`, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,4 @@ const ProcessItem = async (item) => { | |
return item; | ||
}; | ||
|
||
export default { ProcessItem }; | ||
export { ProcessItem }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,105 +0,0 @@ | ||
import { Route } from '@/types'; | ||
import cache from '@/utils/cache'; | ||
import got from '@/utils/got'; | ||
import { load } from 'cheerio'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
import timezone from '@/utils/timezone'; | ||
import logger from '@/utils/logger'; | ||
|
||
export const route: Route = { | ||
path: ['/:category', '/topic/:topic'], | ||
categories: ['traditional-media'], | ||
example: '/dnaindia/headlines', | ||
parameters: { category: 'Find it in the URL, or tables below' }, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
radar: [ | ||
{ | ||
source: ['dnaindia.com/:category'], | ||
}, | ||
], | ||
name: 'News', | ||
maintainers: ['Rjnishant530'], | ||
handler, | ||
description: `Topics: | ||
| DNA verified | | ||
| ------------ | | ||
| dna-verified | | ||
:::tip Topic | ||
The URL of the form \`https://www.dnaindia.com/topic/dna-verified\` demonstrates the utilization of the subdomain \`topic\` | ||
:::`, | ||
description: `Categories: | ||
| Headlines | Explainer | India | Entertainment | Sports | Viral | Lifestyle | Education | Business | World | | ||
| --------- | --------- | ----- | ------------- | ------ | ----- | --------- | --------- | -------- | ----- | | ||
| headlines | explainer | india | entertainment | sports | viral | lifestyle | education | business | world |`, | ||
}; | ||
|
||
async function handler(ctx) { | ||
const { category, topic } = ctx.req.param(); | ||
const baseUrl = 'https://www.dnaindia.com'; | ||
let route; | ||
if (category) { | ||
route = `/${category}`; | ||
} else if (topic) { | ||
route = `/topic/${topic}`; | ||
} else { | ||
logger.error('Invalid URL'); | ||
} | ||
const { data: response } = await got(`${baseUrl}${route}`); | ||
const $ = load(response); | ||
|
||
const listItems = $('div.col-lg-6 div.list-news') | ||
.toArray() | ||
.map((item) => { | ||
item = $(item); | ||
const a = item.find('div.explainer-subtext a'); | ||
return { | ||
title: a.text(), | ||
link: `${baseUrl}${a.attr('href')}`, | ||
}; | ||
}); | ||
|
||
const items = await Promise.all( | ||
listItems.map((item) => | ||
cache.tryGet(item.link, async () => { | ||
const { data: response } = await got(item.link); | ||
const $ = load(response); | ||
item.itunes_item_image = $('div.article-img img').attr('src'); | ||
item.category = $('div.tags ul li') | ||
.toArray() | ||
.map((item) => $(item).find('a').text()); | ||
const time = $('p.dna-update').text().split('Updated:')[1]; | ||
item.pubDate = timezone(parseDate(time, 'MMMDD,YYYY,hh:mmA'), +5.5); | ||
item.author = 'DNA Web Team'; | ||
item.description = $('div.article-description') | ||
.clone() | ||
.children('div') | ||
.remove() | ||
.end() | ||
.toArray() | ||
.map((element) => $(element).html()) | ||
.join(''); | ||
return item; | ||
}) | ||
) | ||
); | ||
|
||
return { | ||
title: 'DNA India', | ||
link: baseUrl, | ||
item: items, | ||
description: 'Latest News on dnaIndia.com', | ||
logo: 'https://cdn.dnaindia.com/sites/all/themes/dnaindia/favicon-1016.ico', | ||
icon: 'https://cdn.dnaindia.com/sites/all/themes/dnaindia/favicon-1016.ico', | ||
language: 'en-us', | ||
}; | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import cache from '@/utils/cache'; | ||
import got from '@/utils/got'; | ||
import { load } from 'cheerio'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
import timezone from '@/utils/timezone'; | ||
import logger from '@/utils/logger'; | ||
|
||
export async function handler(ctx) { | ||
const { category, topic } = ctx.req.param(); | ||
const baseUrl = 'https://www.dnaindia.com'; | ||
let route; | ||
if (category) { | ||
route = `/${category}`; | ||
} else if (topic) { | ||
route = `/topic/${topic}`; | ||
} else { | ||
logger.error('Invalid URL'); | ||
} | ||
const link = `${baseUrl}${route}`; | ||
const { data: response } = await got(link); | ||
const $ = load(response); | ||
|
||
const listItems = $('div.col-lg-6 div.list-news') | ||
.toArray() | ||
.map((item) => { | ||
item = $(item); | ||
const a = item.find('div.explainer-subtext a'); | ||
return { | ||
title: a.text(), | ||
link: `${baseUrl}${a.attr('href')}`, | ||
}; | ||
}); | ||
|
||
const items = await Promise.all( | ||
listItems.map((item) => | ||
cache.tryGet(item.link, async () => { | ||
const { data: response } = await got(item.link); | ||
const $ = load(response); | ||
item.itunes_item_image = $('div.article-img img').attr('src'); | ||
item.category = $('div.tags ul li') | ||
.toArray() | ||
.map((item) => $(item).find('a').text()); | ||
const time = $('p.dna-update').text().split('Updated:')[1]; | ||
item.pubDate = timezone(parseDate(time, 'MMMDD,YYYY,hh:mmA'), +5.5); | ||
item.author = 'DNA Web Team'; | ||
item.description = $('div.article-description') | ||
.clone() | ||
.children('div') | ||
.remove() | ||
.end() | ||
.toArray() | ||
.map((element) => $(element).html()) | ||
.join(''); | ||
return item; | ||
}) | ||
) | ||
); | ||
|
||
return { | ||
title: 'DNA India', | ||
link, | ||
item: items, | ||
description: 'Latest News on dnaIndia.com', | ||
logo: 'https://cdn.dnaindia.com/sites/all/themes/dnaindia/favicon-1016.ico', | ||
icon: 'https://cdn.dnaindia.com/sites/all/themes/dnaindia/favicon-1016.ico', | ||
language: 'en-us', | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Route } from '@/types'; | ||
import { handler } from './common'; | ||
|
||
export const route: Route = { | ||
name: 'News', | ||
maintainers: ['Rjnishant530'], | ||
path: ['/:category'], | ||
example: '/dnaindia/headlines', | ||
parameters: { | ||
category: 'Find it in the URL, or tables below', | ||
}, | ||
radar: [ | ||
{ | ||
source: ['www.dnaindia.com/:category'], | ||
}, | ||
], | ||
handler, | ||
url: 'www.dnaindia.com', | ||
description: `Categories: | ||
| Headlines | Explainer | India | Entertainment | Sports | Viral | Lifestyle | Education | Business | World | | ||
| --------- | --------- | ----- | ------------- | ------ | ----- | --------- | --------- | -------- | ----- | | ||
| headlines | explainer | india | entertainment | sports | viral | lifestyle | education | business | world |`, | ||
}; |
Oops, something went wrong.