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 #1375 from DIYgod/master
[pull] master from diygod:master
- Loading branch information
Showing
4 changed files
with
73 additions
and
3 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,6 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: 'Digital Camera World', | ||
url: 'digitalcameraworld.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,61 @@ | ||
import { Route } from '@/types'; | ||
import { load } from 'cheerio'; | ||
import { ofetch } from 'ofetch'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
const host = 'https://www.digitalcameraworld.com'; | ||
export const route: Route = { | ||
path: '/news', | ||
categories: ['new-media'], | ||
example: '/digitalcameraworld/news', | ||
parameters: {}, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
radar: [ | ||
{ | ||
source: ['digitalcameraworld.com/'], | ||
}, | ||
], | ||
name: 'News', | ||
maintainers: ['EthanWng97'], | ||
handler, | ||
}; | ||
|
||
async function handler() { | ||
const rssUrl = `${host}/feeds.xml`; | ||
|
||
const response = await ofetch(rssUrl); | ||
|
||
const $ = load(response, { | ||
xmlMode: true, | ||
}); | ||
|
||
const items = $('item') | ||
.toArray() | ||
.map((item) => { | ||
item = $(item); | ||
let description = item.find('dc\\:content').text(); | ||
description = $('<div>').html(description); | ||
description.find('.vanilla-image-block').removeAttr('style'); | ||
description.find('.fancy-box').remove(); | ||
|
||
return { | ||
title: item.find('title').text(), | ||
pubDate: parseDate(item.find('pubDate').text()), | ||
link: item.find('link').text(), | ||
description: description.html(), | ||
}; | ||
}); | ||
|
||
return { | ||
title: 'Digital Camera World', | ||
link: host, | ||
description: 'Camera news, reviews and features', | ||
item: items, | ||
}; | ||
} |