From 6f97f7a113ff93df348ad70325d07ac277235eed Mon Sep 17 00:00:00 2001 From: st Date: Tue, 30 Apr 2024 02:23:23 +0800 Subject: [PATCH] feat(route): add olevod.one (#15405) * feat(route): add olevod.one * fix: feed category --------- Co-authored-by: root --- lib/routes/olevod/namespace.ts | 6 +++++ lib/routes/olevod/vod.ts | 49 ++++++++++++++++++++++++++++++++++ lib/routes/olevod/vodlist.ts | 48 +++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 lib/routes/olevod/namespace.ts create mode 100644 lib/routes/olevod/vod.ts create mode 100644 lib/routes/olevod/vodlist.ts diff --git a/lib/routes/olevod/namespace.ts b/lib/routes/olevod/namespace.ts new file mode 100644 index 00000000000000..c0bcbcee5895c0 --- /dev/null +++ b/lib/routes/olevod/namespace.ts @@ -0,0 +1,6 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '欧乐影院', + url: 'olevod.one', +}; diff --git a/lib/routes/olevod/vod.ts b/lib/routes/olevod/vod.ts new file mode 100644 index 00000000000000..7f945ad78c0977 --- /dev/null +++ b/lib/routes/olevod/vod.ts @@ -0,0 +1,49 @@ +import { Route } from '@/types'; +import { load } from 'cheerio'; +import ofetch from '@/utils/ofetch'; + +export const route: Route = { + path: '/vod/:id', + categories: ['multimedia'], + example: '/olevod/vod/202449091', + parameters: { id: '视频id号' }, + radar: [ + { + source: ['www.olevod.one/vod/:id'], + target: '/vod/:id', + }, + ], + name: '视频', + maintainers: ['fang63625'], + handler, +}; + +async function handler(ctx) { + const urlBase = 'https://www.olevod.one'; + const id = ctx.req.param('id'); + const url = `${urlBase}/vod/${id}`; + + const response = await ofetch(url); + const $ = load(response); + + const title = $('.title.scookie').text().trim(); + const image = $('.vodlist_thumb.lazyload').attr('data-original'); + const items = $('.content_playlist.clearfix a') + .toArray() + .map((item) => { + const tmp = $(item); + const href = urlBase + tmp.attr('href'); + + return { + title: `${title} ${tmp.text()}`, + link: href, + }; + }); + + return { + title, + link: url, + item: items, + image: urlBase + image, + }; +} diff --git a/lib/routes/olevod/vodlist.ts b/lib/routes/olevod/vodlist.ts new file mode 100644 index 00000000000000..39ac6f6932126c --- /dev/null +++ b/lib/routes/olevod/vodlist.ts @@ -0,0 +1,48 @@ +import { Route } from '@/types'; +import { load } from 'cheerio'; +import ofetch from '@/utils/ofetch'; + +export const route: Route = { + path: '/vodlist', + categories: ['multimedia'], + example: '/olevod/vodlist', + radar: [ + { + source: ['www.olevod.one'], + target: '/vodlist', + }, + ], + name: '最新视频', + maintainers: ['fang63625'], + handler, +}; + +async function handler() { + const urlBase = 'https://www.olevod.one'; + const title = '欧乐影院 最新视频'; + + const response = await ofetch(urlBase); + const $ = load(response); + + const items = $('.cbox1 .vodlist_thumb.lazyload') + .toArray() + .map((item) => { + const tmp = $(item); + const href = urlBase + tmp.attr('href'); + const title = tmp.attr('title'); + const image = urlBase + tmp.attr('data-original'); + + return { + title: `${title} ${tmp.find('.pic_text.text_right').text()}`, + link: href, + image, + description: `豆瓣评分 ${tmp.find('.text_right.text_dy').text()}`, + }; + }); + + return { + title, + link: urlBase, + item: items, + }; +}