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.
feat(route/chikubi): refactor URL fetching and add new routes (DIYgod…
…#16758) * refactor(route/chikubi): switch to native /feed for article URL fetching * feat: add new routes * refactor: remove decodeURIComponent * fix: Handle unescaped characters in tag URLs * chore: use '@/utils/rss-parser' instead of 'rss-parser' * chore: update description * feat(utils): add getPostById and getPostsByIdList for REST API content fetching * refactor(search): use getPostsByIdList instead of processItems * fix: Handle unescaped characters * refactor: Separate index and navigation * feat: optimize post fetching by id and add category & tag functions * refactor: use api to get posts for tags and categories * chore: directly use url * fix: use API to fetch 'best' * fix: destructure post object in map function * feat: optimize getPosts function for reusability * refactor: remove wrapper functions for getBySlug and getPostsBy
- Loading branch information
Showing
9 changed files
with
411 additions
and
73 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,41 @@ | ||
import { Route, Data } from '@/types'; | ||
import { getBySlug, getPostsBy } from './utils'; | ||
|
||
export const route: Route = { | ||
path: '/category/:keyword', | ||
categories: ['multimedia'], | ||
example: '/chikubi/category/nipple-lesbian', | ||
parameters: { keyword: 'Keyword' }, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
name: 'Category', | ||
maintainers: ['SnowAgar25'], | ||
handler, | ||
radar: [ | ||
{ | ||
title: 'Category', | ||
source: ['chikubi.jp/category/:keyword'], | ||
target: '/category/:keyword', | ||
}, | ||
], | ||
}; | ||
|
||
async function handler(ctx): Promise<Data> { | ||
const baseUrl = 'https://chikubi.jp'; | ||
const { keyword } = ctx.req.param(); | ||
const { id, name } = await getBySlug('category', keyword); | ||
|
||
const items = await getPostsBy('category', id); | ||
|
||
return { | ||
title: `Category: ${name} - chikubi.jp`, | ||
link: `${baseUrl}/category/${keyword}`, | ||
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
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,66 @@ | ||
import { Route, Data } from '@/types'; | ||
import { getBySlug, getPostsBy, processItems } from './utils'; | ||
import parser from '@/utils/rss-parser'; | ||
|
||
export const route: Route = { | ||
path: '/:keyword', | ||
categories: ['multimedia'], | ||
example: '/chikubi', | ||
parameters: { keyword: '導覽列,見下表,默認爲最新' }, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
name: 'Navigation', | ||
maintainers: ['SnowAgar25'], | ||
handler, | ||
description: `| 殿堂 | 動畫 | VR | 漫畫 | 音聲 | CG・イラスト | | ||
| ---- | ----- | -- | ----- | ----- | -- | | ||
| best | video | vr | comic | voice | cg |`, | ||
}; | ||
|
||
const navigationItems = { | ||
video: { url: '/nipple-video', title: '動畫' }, | ||
vr: { url: '/nipple-video-category/cat-nipple-video-vr', title: 'VR' }, | ||
comic: { url: '/comic', title: '漫畫' }, | ||
voice: { url: '/voice', title: '音聲' }, | ||
cg: { url: '/cg', title: 'CG' }, | ||
}; | ||
|
||
async function handler(ctx): Promise<Data> { | ||
const keyword = ctx.req.param('keyword') ?? ''; | ||
const baseUrl = 'https://chikubi.jp'; | ||
|
||
if (keyword === 'best') { | ||
const { id } = await getBySlug('category', 'nipple-best'); | ||
const items = await getPostsBy('category', id); | ||
|
||
return { | ||
title: '殿堂 - chikubi.jp', | ||
link: `${baseUrl}/best-nipple-article`, | ||
item: items, | ||
}; | ||
} else { | ||
const { url, title } = navigationItems[keyword]; | ||
|
||
const feed = await parser.parseURL(`${baseUrl}${url}/feed`); | ||
|
||
const list = feed.items.map((item) => ({ | ||
title: item.title, | ||
link: item.link, | ||
})); | ||
|
||
// 獲取內文 | ||
const items = await processItems(list); | ||
|
||
return { | ||
title: `${title} - chikubi.jp`, | ||
link: `${baseUrl}${url}`, | ||
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,49 @@ | ||
import { Route, Data } from '@/types'; | ||
import { processItems } from './utils'; | ||
import parser from '@/utils/rss-parser'; | ||
|
||
export const route: Route = { | ||
path: '/nipple-video-category/:keyword', | ||
categories: ['multimedia'], | ||
example: '/chikubi/nipple-video-category/cat-nipple-video-god', | ||
parameters: { keyword: 'Keyword' }, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
name: '動画カテゴリー', | ||
maintainers: ['SnowAgar25'], | ||
handler, | ||
radar: [ | ||
{ | ||
title: '動画カテゴリー', | ||
source: ['chikubi.jp/nipple-video-category/:keyword'], | ||
target: '/nipple-video-category/:keyword', | ||
}, | ||
], | ||
}; | ||
|
||
async function handler(ctx): Promise<Data> { | ||
const { keyword } = ctx.req.param(); | ||
const baseUrl = 'https://chikubi.jp'; | ||
const url = `/nipple-video-category/${encodeURIComponent(keyword)}`; | ||
|
||
const feed = await parser.parseURL(`${baseUrl}${url}/feed`); | ||
|
||
const list = feed.items.map((item) => ({ | ||
title: item.title, | ||
link: item.link, | ||
})); | ||
|
||
const items = await processItems(list); | ||
|
||
return { | ||
title: `動画カテゴリー: ${feed.title?.split('-')[0]} - chikubi.jp`, | ||
link: `${baseUrl}${url}`, | ||
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,49 @@ | ||
import { Route, Data } from '@/types'; | ||
import { processItems } from './utils'; | ||
import parser from '@/utils/rss-parser'; | ||
|
||
export const route: Route = { | ||
path: '/nipple-video-maker/:keyword', | ||
categories: ['multimedia'], | ||
example: '/chikubi/nipple-video-maker/nipple-video-maker-nh', | ||
parameters: { keyword: 'Keyword' }, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
name: 'AVメーカー', | ||
maintainers: ['SnowAgar25'], | ||
handler, | ||
radar: [ | ||
{ | ||
title: 'AVメーカー', | ||
source: ['chikubi.jp/nipple-video-maker/:keyword'], | ||
target: '/nipple-video-maker/:keyword', | ||
}, | ||
], | ||
}; | ||
|
||
async function handler(ctx): Promise<Data> { | ||
const { keyword } = ctx.req.param(); | ||
const baseUrl = 'https://chikubi.jp'; | ||
const url = `/nipple-video-maker/${encodeURIComponent(keyword)}`; | ||
|
||
const feed = await parser.parseURL(`${baseUrl}${url}/feed`); | ||
|
||
const list = feed.items.map((item) => ({ | ||
title: item.title, | ||
link: item.link, | ||
})); | ||
|
||
const items = await processItems(list); | ||
|
||
return { | ||
title: `AVメーカー: ${feed.title?.split('-')[0]} - chikubi.jp`, | ||
link: `${baseUrl}${url}`, | ||
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,39 @@ | ||
import { Route, Data } from '@/types'; | ||
import { getPosts } from './utils'; | ||
import got from '@/utils/got'; | ||
|
||
export const route: Route = { | ||
path: '/search/:keyword', | ||
categories: ['multimedia'], | ||
example: '/chikubi/search/ギャップ', | ||
parameters: { keyword: 'Keyword' }, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
name: 'Search', | ||
maintainers: ['SnowAgar25'], | ||
handler, | ||
}; | ||
|
||
async function handler(ctx): Promise<Data> { | ||
const { keyword } = ctx.req.param(); | ||
const baseUrl = 'https://chikubi.jp'; | ||
const searchUrl = `${baseUrl}/wp-json/wp/v2/search?search=${keyword}`; | ||
|
||
const response = await got.get(searchUrl); | ||
const searchResults = response.data; | ||
|
||
const postIds = searchResults.map((item) => item.id.toString()); | ||
const items = await getPosts(postIds); | ||
|
||
return { | ||
title: `Search: ${keyword} - chikubi.jp`, | ||
link: `${baseUrl}/search/${encodeURIComponent(keyword)}`, | ||
item: items, | ||
}; | ||
} |
Oops, something went wrong.