Skip to content

Commit

Permalink
feat(route): spankbang (#16962)
Browse files Browse the repository at this point in the history
* feat(route): spankbang

* fix: add antiCrawler flag
  • Loading branch information
TonyRL authored Sep 29, 2024
1 parent 1524059 commit 4b128ac
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/routes/spankbang/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: 'SpankBang',
url: 'spankbang.com',
};
64 changes: 64 additions & 0 deletions lib/routes/spankbang/new-videos.ts
Original file line number Diff line number Diff line change
@@ -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<Data>;
};

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,
};
7 changes: 7 additions & 0 deletions lib/routes/spankbang/templates/video.art
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{ if preview }}
<video controls preload="metadata"
{{ if cover }} poster="{{ cover }}" {{ /if }}
>
<source src="{{ preview }}" type="video/mp4">
</video>
{{ /if }}

0 comments on commit 4b128ac

Please sign in to comment.