mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-18 14:29:01 +08:00
08a38f0a5e
* refactor: typing house-keeping * fix: fix parse date not accepting strict mode * refactor: use npm package * fix: address review
33 lines
723 B
TypeScript
33 lines
723 B
TypeScript
import Parser from 'rss-parser';
|
|
|
|
import { config } from '@/config';
|
|
import type { DataItem, Language } from '@/types';
|
|
|
|
interface ParsedFeed {
|
|
author?: string;
|
|
copyright?: string;
|
|
creator?: string;
|
|
generator?: string;
|
|
language?: Language;
|
|
lastBuildDate?: string;
|
|
managingEditor?: string;
|
|
pubDate?: string;
|
|
publisher?: string;
|
|
webMaster?: string;
|
|
}
|
|
|
|
type ParsedItem = Pick<DataItem, 'author' | 'category' | 'description' | 'enclosure_type' | 'enclosure_url' | 'id'> & {
|
|
magnet?: string;
|
|
};
|
|
|
|
const parser = new Parser<ParsedFeed, ParsedItem>({
|
|
customFields: {
|
|
item: ['magnet'],
|
|
},
|
|
headers: {
|
|
'User-Agent': config.ua,
|
|
},
|
|
});
|
|
|
|
export default parser;
|