feat(route): add anime1 (#16842)
* feat(route): add anime1 add 2 anime1 route: 1. anime 2. search * Update anime.ts fix example * remove deprecated route remove deprecated anime1 route: 1. anime.js 2. search.js * Update search.ts remove radar rule
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { time, name } = ctx.params;
|
||||
const $ = await got.get(`https://anime1.me/category/${encodeURIComponent(time)}/${encodeURIComponent(name)}`).then((r) => cheerio.load(r.data));
|
||||
const title = $('.page-title').text().trim();
|
||||
ctx.state.data = {
|
||||
title,
|
||||
link: `https://anime1.me/category/${time}/${name}`,
|
||||
description: title,
|
||||
item: $('article')
|
||||
.toArray()
|
||||
.map((art) => {
|
||||
const $el = $(art);
|
||||
const title = $el.find('.entry-title a').text();
|
||||
return {
|
||||
title: $el.find('.entry-title a').text(),
|
||||
link: $el.find('.entry-title a').attr('href'),
|
||||
description: title,
|
||||
pubDate: new Date($el.find('time').attr('datetime')).toUTCString(),
|
||||
};
|
||||
}),
|
||||
};
|
||||
};
|
||||
@@ -1,25 +0,0 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { keyword } = ctx.params;
|
||||
const $ = await got.get(`https://anime1.me/?s=${encodeURIComponent(keyword)}`).then((r) => cheerio.load(r.data));
|
||||
const title = $('.page-title').text().trim();
|
||||
ctx.state.data = {
|
||||
title,
|
||||
link: `https://anime1.me/?s=${keyword}`,
|
||||
description: title,
|
||||
item: $('article:has(.cat-links)')
|
||||
.toArray()
|
||||
.map((art) => {
|
||||
const $el = $(art);
|
||||
const title = $el.find('.entry-title a').text();
|
||||
return {
|
||||
title: $el.find('.entry-title a').text(),
|
||||
link: $el.find('.entry-title a').attr('href'),
|
||||
description: title,
|
||||
pubDate: new Date($el.find('time').attr('datetime')).toUTCString(),
|
||||
};
|
||||
}),
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,63 @@
|
||||
import { Route } from '@/types';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import ofetch from '@/utils/ofetch';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
export const route: Route = {
|
||||
path: 'anime/:category/:name',
|
||||
name: 'Anime',
|
||||
url: 'anime1.me',
|
||||
maintainers: ['cxheng315'],
|
||||
example: '/anime1/anime/2024年夏季/神之塔-第二季',
|
||||
categories: ['anime'],
|
||||
parameters: {
|
||||
category: 'Anime1 Category',
|
||||
name: 'Anime1 Name',
|
||||
},
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: false,
|
||||
antiCrawler: false,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
radar: [
|
||||
{
|
||||
source: ['anime1.me/category/:category/:name'],
|
||||
target: '/anime/:category/:name',
|
||||
},
|
||||
],
|
||||
handler,
|
||||
};
|
||||
|
||||
async function handler(ctx) {
|
||||
const { category, name } = ctx.req.param();
|
||||
|
||||
const response = await ofetch(`https://anime1.me/category/${category}/${name}`);
|
||||
|
||||
const $ = load(response);
|
||||
|
||||
const title = $('page-title').text().trim();
|
||||
|
||||
const items = $('article')
|
||||
.toArray()
|
||||
.map((el) => {
|
||||
const $el = $(el);
|
||||
const title = $el.find('.entry-title a').text().trim();
|
||||
return {
|
||||
title,
|
||||
link: $el.find('.entry-title a').attr('href'),
|
||||
description: title,
|
||||
pubDate: parseDate($el.find('time').attr('datetime') || ''),
|
||||
itunes_item_image: $el.find('video').attr('poster'),
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
title,
|
||||
link: `https://anime1.me/category/${category}/${name}`,
|
||||
description: title,
|
||||
item: items,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import type { Namespace } from '@/types';
|
||||
|
||||
export const namespace: Namespace = {
|
||||
name: 'Anime1',
|
||||
url: 'anime1.me',
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
import { Route } from '@/types';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import ofetch from '@/utils/ofetch';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
export const route: Route = {
|
||||
path: 'search/:keyword',
|
||||
name: 'Search',
|
||||
url: 'anime1.me',
|
||||
maintainers: ['cxheng315'],
|
||||
example: '/anime1/search/神之塔',
|
||||
categories: ['anime'],
|
||||
parameters: {
|
||||
keyword: 'Anime1 Search Keyword',
|
||||
},
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: false,
|
||||
antiCrawler: false,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
handler,
|
||||
};
|
||||
|
||||
async function handler(ctx) {
|
||||
const { keyword } = ctx.req.param();
|
||||
|
||||
const response = await ofetch(`https://anime1.me/?s=${keyword}`);
|
||||
|
||||
const $ = load(response);
|
||||
|
||||
const title = $('page-title').text().trim();
|
||||
|
||||
const items = $('article.type-post')
|
||||
.toArray()
|
||||
.map((el) => {
|
||||
const $el = $(el);
|
||||
const title = $el.find('.entry-title a').text().trim();
|
||||
return {
|
||||
title,
|
||||
link: $el.find('.entry-title a').attr('href'),
|
||||
description: title,
|
||||
pubDate: parseDate($el.find('time').attr('datetime') || ''),
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
title,
|
||||
link: `https://anime1.me/?s=${keyword}`,
|
||||
description: title,
|
||||
itunes_author: 'Anime1',
|
||||
itunes_image: 'https://anime1.me/wp-content/uploads/2021/02/cropped-1-180x180.png',
|
||||
item: items,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user