-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a8c561
commit b251ae1
Showing
2 changed files
with
69 additions
and
0 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,63 @@ | ||
import { Route } from '@/types'; | ||
import cache from '@/utils/cache'; | ||
import parser from '@/utils/rss-parser'; | ||
import ofetch from '@/utils/ofetch'; | ||
import { load } from 'cheerio'; | ||
const host = 'https://www.magnumphotos.com'; | ||
export const route: Route = { | ||
path: '/magazine', | ||
categories: ['picture'], | ||
example: '/magnumphotos/magazine', | ||
parameters: {}, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
radar: [ | ||
{ | ||
source: ['magnumphotos.com/'], | ||
}, | ||
], | ||
name: 'Magazine', | ||
maintainers: ['EthanWng97'], | ||
handler, | ||
url: 'magnumphotos.com/', | ||
}; | ||
|
||
async function handler() { | ||
const rssUrl = `${host}/feed/`; | ||
const feed = await parser.parseURL(rssUrl); | ||
const items = await Promise.all( | ||
feed.items.map((item) => | ||
cache.tryGet(item.link, async () => { | ||
if (!item.link) { | ||
return; | ||
} | ||
const data = await ofetch(item.link); | ||
const $ = load(data); | ||
const description = $('#content'); | ||
description.find('ul.share').remove(); | ||
description.find('h1').remove(); | ||
|
||
return { | ||
title: item.title, | ||
pubDate: item.pubDate, | ||
link: item.link, | ||
category: item.categories, | ||
description: description.html(), | ||
}; | ||
}) | ||
) | ||
); | ||
|
||
return { | ||
title: 'Magnum Photos', | ||
link: host, | ||
description: 'Magnum is a community of thought, a shared human quality, a curiosity about what is going on in the world, a respect for what is going on and a desire to transcribe it visually', | ||
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,6 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: 'Magnum Photos', | ||
url: 'magnumphotos.com', | ||
}; |