diff --git a/lib/routes/spankbang/namespace.ts b/lib/routes/spankbang/namespace.ts new file mode 100644 index 000000000..bc37481f9 --- /dev/null +++ b/lib/routes/spankbang/namespace.ts @@ -0,0 +1,6 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: 'SpankBang', + url: 'spankbang.com', +}; diff --git a/lib/routes/spankbang/new-videos.ts b/lib/routes/spankbang/new-videos.ts new file mode 100644 index 000000000..54490e097 --- /dev/null +++ b/lib/routes/spankbang/new-videos.ts @@ -0,0 +1,64 @@ +import { Data, Route } from '@/types'; +import { getCurrentPath } from '@/utils/helpers'; + +import ofetch from '@/utils/ofetch'; +import * as cheerio from 'cheerio'; +import { art } from '@/utils/render'; +import path from 'node:path'; +import { config } from '@/config'; + +const __dirname = getCurrentPath(import.meta.url); +const render = (data) => art(path.join(__dirname, 'templates/video.art'), data); + +const handler = async () => { + const baseUrl = 'https://spankbang.com'; + const link = `${baseUrl}/new_videos/`; + + const response = await ofetch(link, { + headers: { + 'User-Agent': config.trueUA, + }, + }); + const $ = cheerio.load(response); + + const items = $('.video-item') + .toArray() + .map((item) => { + const $item = $(item); + const thumb = $item.find('.thumb'); + const cover = $item.find('img.cover'); + + return { + title: thumb.attr('title'), + link: new URL(thumb.attr('href')!, baseUrl).href, + description: render({ + cover: cover.data('src'), + preview: cover.data('preview'), + }), + }; + }); + + return { + title: $('head title').text(), + description: $('head meta[name="description"]').attr('content'), + link, + item: items, + } as unknown as Promise; +}; + +export const route: Route = { + path: '/new_videos', + categories: ['multimedia'], + example: '/spankbang/new_videos', + name: 'New Porn Videos', + maintainers: ['TonyRL'], + features: { + antiCrawler: true, + }, + radar: [ + { + source: ['spankbang.com/new_videos/', 'spankbang.com/'], + }, + ], + handler, +}; diff --git a/lib/routes/spankbang/templates/video.art b/lib/routes/spankbang/templates/video.art new file mode 100644 index 000000000..c30942421 --- /dev/null +++ b/lib/routes/spankbang/templates/video.art @@ -0,0 +1,7 @@ +{{ if preview }} + +{{ /if }}