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.
Merge pull request #2518 from DIYgod/master
[pull] master from diygod:master
- Loading branch information
Showing
37 changed files
with
742 additions
and
144 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
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,41 @@ | ||
import { Route } from '@/types'; | ||
import parser from '@/utils/rss-parser'; | ||
import { fetchArticle } from './utils'; | ||
const HOME_PAGE = 'https://apnews.com'; | ||
|
||
export const route: Route = { | ||
path: '/rss/:rss?', | ||
categories: ['traditional-media'], | ||
example: '/apnews/rss/business', | ||
parameters: { rss: 'Route name from the first segment of the corresponding site, or `index` for the front page(default).' }, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
radar: [ | ||
{ | ||
source: ['apnews.com/:rss'], | ||
target: '/rss/:rss', | ||
}, | ||
], | ||
name: 'RSS', | ||
maintainers: ['zoenglinghou', 'mjysci', 'TonyRL'], | ||
handler, | ||
}; | ||
|
||
async function handler(ctx) { | ||
const { rss = 'index' } = ctx.req.param(); | ||
const url = `${HOME_PAGE}/${rss}.rss`; | ||
const res = await parser.parseURL(url); | ||
|
||
const items = await Promise.all(res.items.map((item) => fetchArticle(item))); | ||
|
||
return { | ||
...rss, | ||
item: items, | ||
}; | ||
} |
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,20 @@ | ||
import cache from '@/utils/cache'; | ||
import ofetch from '@/utils/ofetch'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
import timezone from '@/utils/timezone'; | ||
import { load } from 'cheerio'; | ||
|
||
export function fetchArticle(item) { | ||
return cache.tryGet(item.link, async () => { | ||
const data = await ofetch(item.link); | ||
const $ = load(data); | ||
$('div.Enhancement').remove(); | ||
return Object.assign(item, { | ||
pubDate: timezone(parseDate($("meta[property='article:published_time']").attr('content')), 0), | ||
updated: timezone(parseDate($("meta[property='article:modified_time']").attr('content')), 0), | ||
description: $('div.RichTextStoryBody').html(), | ||
category: $("meta[property='article:section']").attr('content'), | ||
guid: $("meta[name='brightspot.contentId']").attr('content'), | ||
}); | ||
}); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: 'GQ', | ||
url: 'gq.com', | ||
}; |
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,59 @@ | ||
import { Route } from '@/types'; | ||
import cache from '@/utils/cache'; | ||
import parser from '@/utils/rss-parser'; | ||
import { load } from 'cheerio'; | ||
import { ofetch } from 'ofetch'; | ||
const host = 'https://www.gq.com'; | ||
export const route: Route = { | ||
path: '/news', | ||
categories: ['traditional-media'], | ||
example: '/gq/news', | ||
parameters: {}, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
radar: [ | ||
{ | ||
source: ['gq.com/'], | ||
}, | ||
], | ||
name: 'News', | ||
maintainers: ['EthanWng97'], | ||
handler, | ||
}; | ||
|
||
async function handler() { | ||
const rssUrl = `${host}/feed/rss`; | ||
const feed = await parser.parseURL(rssUrl); | ||
const items = await Promise.all( | ||
feed.items.map((item) => | ||
cache.tryGet(item.link, async () => { | ||
const data = await ofetch(item.link); | ||
const $ = load(data); | ||
const description = $('#main-content'); | ||
description.find('.article-body__footer').remove(); | ||
description.find('[class*="ContentHeaderContributorImage"]').remove(); | ||
description.find('h1').remove(); | ||
return { | ||
title: item.title, | ||
pubDate: item.pubDate, | ||
link: item.link, | ||
category: item.categories, | ||
description: description.html(), | ||
}; | ||
}) | ||
) | ||
); | ||
|
||
return { | ||
title: 'GQ', | ||
link: host, | ||
description: `GQ is the global flagship of men's fashion, the arbiter of cool for anyone who sees the world through the lens of taste and style.`, | ||
item: items, | ||
}; | ||
} |
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,5 +1,5 @@ | ||
{{ if videoInfo.mobileUrl }} | ||
<video controls poster="{{ videoInfo.bigPosterUrl }}" preload="none"> | ||
<video controls poster="{{ videoInfo.bigPosterUrl }}" preload="metadata"> | ||
<source src="{{ videoInfo.mobileUrl }}" type="video/mp4"> | ||
</video> | ||
{{ /if }} |
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,13 @@ | ||
{{ if images }} | ||
{{ each images image }} | ||
{{ if image?.src }} | ||
<figure> | ||
<img | ||
{{ if image.alt }} | ||
alt="{{ image.alt }}" | ||
{{ /if }} | ||
src="{{ image.src }}"> | ||
</figure> | ||
{{ /if }} | ||
{{ /each }} | ||
{{ /if }} |
Oops, something went wrong.