forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(route): add KISS blog (DIYgod#16984)
* feat(route): add KISS blog * add lang settings
- Loading branch information
Showing
2 changed files
with
80 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,74 @@ | ||
import { Route } from '@/types'; | ||
import got from '@/utils/got'; | ||
import { load } from 'cheerio'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
import timezone from '@/utils/timezone'; | ||
|
||
const baseUrl = 'https://www.kisskiss.tv/kiss/diary.php'; | ||
|
||
export const route: Route = { | ||
path: '/blog/:category?', | ||
categories: ['game'], | ||
example: '/blog/DLC', | ||
parameters: { category: 'category' }, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
radar: [ | ||
{ | ||
source: ['www.kisskiss.tv/kiss/diary.php'], | ||
target: '/blog', | ||
}, | ||
], | ||
name: 'ブログ', | ||
maintainers: ['keocheung'], | ||
handler, | ||
}; | ||
|
||
async function handler(ctx) { | ||
const { category } = ctx.req.param(); | ||
const url = category ? `${baseUrl}?category=${category}` : baseUrl; | ||
|
||
const response = await got(url); | ||
const $ = load(response.data); | ||
|
||
const items = $('table.blog_frame_top') | ||
.toArray() | ||
.map((item) => { | ||
const title = $(item); | ||
const body = title.next('div.blog_frame_middle'); | ||
const i = { | ||
title: title.find('tbody tr td').text(), | ||
link: title.find('tbody tr td a').attr('href'), | ||
pubDate: timezone( | ||
parseDate( | ||
body | ||
.find('div.blog_data div.data_r') | ||
.text() | ||
.match(/\d+年\d+月\d+日 \(\d+:\d+\)/)[0], | ||
'YYYY年M月D日 (HH:mm)' | ||
), | ||
9 | ||
), | ||
}; | ||
body.find('a img').each(function () { | ||
$(this).attr('src', $(this).parent('a').attr('href')); | ||
$(this).unwrap(); | ||
}); | ||
body.find('div.blog_data').remove(); | ||
i.description = `<div lang="ja-JP">${body.html()}</div>`; | ||
return i; | ||
}); | ||
|
||
return { | ||
title: 'KISS ブログ', | ||
link: url, | ||
item: items, | ||
language: 'ja', | ||
}; | ||
} |
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: 'KISS', | ||
url: 'www.kisskiss.tv', | ||
}; |