Skip to content

Commit

Permalink
feat(route): add olevod.one (#15405)
Browse files Browse the repository at this point in the history
* feat(route): add olevod.one

* fix: feed category

---------

Co-authored-by: root <root@debian.st>
  • Loading branch information
fang63625 and root authored Apr 29, 2024
1 parent 715bad0 commit 6f97f7a
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/routes/olevod/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: '欧乐影院',
url: 'olevod.one',
};
49 changes: 49 additions & 0 deletions lib/routes/olevod/vod.ts
Original file line number Diff line number Diff line change
@@ -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,
};
}
48 changes: 48 additions & 0 deletions lib/routes/olevod/vodlist.ts
Original file line number Diff line number Diff line change
@@ -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,
};
}

0 comments on commit 6f97f7a

Please sign in to comment.