-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'my-feature' of https://github.com/findwei/RSSHub into m…
…y-feature
- Loading branch information
Showing
20 changed files
with
1,690 additions
and
575 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,69 @@ | ||
import { Route } from '@/types'; | ||
import type { Context } from 'hono'; | ||
|
||
import cache from '@/utils/cache'; | ||
import ofetch from '@/utils/ofetch'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
import { assetsConnectionByCriteriaQuery } from './query'; | ||
import { getItem } from './utils'; | ||
|
||
export const route: Route = { | ||
path: '/latest', | ||
categories: ['traditional-media'], | ||
example: '/afr/latest', | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
radar: [ | ||
{ | ||
source: ['www.afr.com/latest', 'www.afr.com/'], | ||
}, | ||
], | ||
name: 'Latest', | ||
maintainers: ['TonyRL'], | ||
handler, | ||
url: 'www.afr.com/latest', | ||
}; | ||
|
||
async function handler(ctx: Context) { | ||
const limit = Number.parseInt(ctx.req.query('limit') ?? '10'); | ||
const response = await ofetch('https://api.afr.com/graphql', { | ||
query: { | ||
query: assetsConnectionByCriteriaQuery, | ||
operationName: 'assetsConnectionByCriteria', | ||
variables: { | ||
brand: 'afr', | ||
first: limit, | ||
render: 'web', | ||
types: ['article', 'bespoke', 'featureArticle', 'liveArticle', 'video'], | ||
after: '', | ||
}, | ||
}, | ||
}); | ||
|
||
const list = response.data.assetsConnectionByCriteria.edges.map(({ node }) => ({ | ||
title: node.asset.headlines.headline, | ||
description: node.asset.about, | ||
link: `https://www.afr.com${node.urls.published.afr.path}`, | ||
pubDate: parseDate(node.dates.firstPublished), | ||
updated: parseDate(node.dates.modified), | ||
author: node.asset.byline, | ||
category: [node.tags.primary.displayName, ...node.tags.secondary.map((tag) => tag.displayName)], | ||
image: node.featuredImages && `https://static.ffx.io/images/${node.featuredImages.landscape16x9.data.id}`, | ||
})); | ||
|
||
const items = await Promise.all(list.map((item) => cache.tryGet(item.link, () => getItem(item)))); | ||
|
||
return { | ||
title: 'Latest | The Australian Financial Review | AFR', | ||
description: 'The latest news, events, analysis and opinion from The Australian Financial Review', | ||
image: 'https://www.afr.com/apple-touch-icon-1024x1024.png', | ||
link: 'https://www.afr.com/latest', | ||
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: 'The Australian Financial Review', | ||
url: 'afr.com', | ||
lang: 'en', | ||
}; |
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,75 @@ | ||
import { Route } from '@/types'; | ||
import type { Context } from 'hono'; | ||
|
||
import cache from '@/utils/cache'; | ||
import ofetch from '@/utils/ofetch'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
import { pageByNavigationPathQuery } from './query'; | ||
import { getItem } from './utils'; | ||
|
||
export const route: Route = { | ||
path: '/navigation/:path{.+}', | ||
categories: ['traditional-media'], | ||
example: '/afr/navigation/markets', | ||
parameters: { | ||
path: 'Navigation path, can be found in the URL of the page', | ||
}, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
radar: [ | ||
{ | ||
source: ['www.afr.com/path*'], | ||
}, | ||
], | ||
name: 'Navigation', | ||
maintainers: ['TonyRL'], | ||
handler, | ||
url: 'www.afr.com', | ||
}; | ||
|
||
async function handler(ctx: Context) { | ||
const { path } = ctx.req.param(); | ||
const limit = Number.parseInt(ctx.req.query('limit') ?? '10'); | ||
|
||
const response = await ofetch('https://api.afr.com/api/content-audience/afr/graphql', { | ||
query: { | ||
query: pageByNavigationPathQuery, | ||
operationName: 'pageByNavigationPath', | ||
variables: { | ||
input: { brandKey: 'afr', navigationPath: `/${path}`, renderName: 'web' }, | ||
firstStories: limit, | ||
afterStories: '', | ||
}, | ||
}, | ||
}); | ||
|
||
const list = response.data.pageByNavigationPath.page.latestStoriesConnection.edges.map(({ node }) => ({ | ||
title: node.headlines.headline, | ||
description: node.overview.about, | ||
link: `https://www.afr.com${node.urls.canonical.path}`, | ||
pubDate: parseDate(node.dates.firstPublished), | ||
updated: parseDate(node.dates.modified), | ||
author: node.byline | ||
.filter((byline) => byline.type === 'AUTHOR') | ||
.map((byline) => byline.author.name) | ||
.join(', '), | ||
category: [node.tags.primary.displayName, ...node.tags.secondary.map((tag) => tag.displayName)], | ||
image: node.images && `https://static.ffx.io/images/${node.images.landscape16x9.mediaId}`, | ||
})); | ||
|
||
const items = await Promise.all(list.map((item) => cache.tryGet(item.link, () => getItem(item)))); | ||
|
||
return { | ||
title: response.data.pageByNavigationPath.page.seo.title, | ||
description: response.data.pageByNavigationPath.page.seo.description, | ||
image: 'https://www.afr.com/apple-touch-icon-1024x1024.png', | ||
link: `https://www.afr.com/${path}`, | ||
item: items, | ||
}; | ||
} |
Oops, something went wrong.