feat(route): manyvids (#15822)

This commit is contained in:
Tony 2024-06-04 23:29:11 +08:00 committed by GitHub
parent 857f1800f0
commit bfe0af95fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 151 additions and 1 deletions

View File

@ -1,6 +1,6 @@
import type { Namespace } from '@/types';
export const namespace: Namespace = {
name: 'Unknown',
name: 'MangaDex',
url: 'mangadex.org',
};

View File

@ -0,0 +1,7 @@
import type { Namespace } from '@/types';
export const namespace: Namespace = {
name: 'ManyVids',
url: 'www.manyvids.com',
categories: ['multimedia'],
};

View File

@ -0,0 +1,3 @@
<video controls preload="metadata" poster="{{ poster }}">
<source src="{{ src }}" type="video/mp4">
</video>

View File

@ -0,0 +1,89 @@
export interface UserProfile {
createdAt: string;
displayName: string;
profileId: string;
urlHandle: string;
userId: string;
legacyUserId: string;
userStatus: string;
userType: string;
avatar: string;
bio: string;
description: string;
dob: string;
identification: string;
location: string;
orientation: string;
currentRank: number;
bodyType: string;
hairColor: string;
ethnicity: string;
poAddress: string;
poCity: string;
poName: string;
poZip: string;
portrait: string;
shortLinkUrl: string;
profession: string;
socLnkFacebook: string;
socLnkInstagram: string;
socLnkReddit: string;
socLnkTwitter: string;
socLnkYoutube: string;
profileType: string;
hasPremiumMembership: boolean;
}
interface Avatar {
url: string;
}
interface Creator {
id: string;
slug: string;
stageName: string;
avatar: Avatar;
}
interface Thumbnail {
url: string;
}
interface Preview {
url: string;
}
interface Price {
free: boolean;
onSale: boolean;
regular: string;
}
interface Video {
id: string;
title: string;
slug: string;
duration: string;
creator: Creator;
thumbnail: Thumbnail;
preview: Preview;
price: Price;
likes: number;
views: number;
type: string;
}
interface Pagination {
total: number;
totalWithoutFilters: number;
currentPage: number;
totalPages: number;
nextPage: number;
}
export interface Videos {
statusCode: number;
statusMessage: string;
data: Video[];
pagination: Pagination;
}

View File

@ -0,0 +1,51 @@
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
import cache from '@/utils/cache';
import { UserProfile, Videos } from './types';
import { art } from '@/utils/render';
import path from 'node:path';
import { getCurrentPath } from '@/utils/helpers';
const __dirname = getCurrentPath(import.meta.url);
export const route: Route = {
path: '/profile/vids/:uid',
radar: [
{
source: ['www.manyvids.com/Profile/:uid/:handle/Store/*', 'www.manyvids.com/Profile/:uid/:handle/Store'],
},
],
parameters: { uid: 'User ID, can be found in the URL.' },
name: 'Creator Videos',
example: '/manyvids/profile/vids/1001213004',
maintainers: ['TonyRL'],
handler,
};
const getProfileById = (uid: string) => cache.tryGet(`manyvids:profile:${uid}`, () => ofetch(`https://www.manyvids.com/bff/profile/profiles/${uid}`)) as Promise<UserProfile>;
const render = (data) => art(path.join(__dirname, 'templates', 'video.art'), data);
async function handler(ctx) {
const { uid } = ctx.req.param();
const profile = await getProfileById(uid);
const videos = await ofetch<Videos>(`https://www.manyvids.com/bff/store/videos/${uid}/`, {
query: { page: 1 },
});
const items = videos.data.map((v) => ({
title: v.title,
link: `https://www.manyvids.com/Video/${v.id}/${v.slug}`,
author: v.creator.stageName,
description: render({ poster: v.thumbnail.url, src: v.preview.url }),
}));
return {
title: `${profile.displayName}'s Profile - Porn vids, Pics & More | ManyVids - ManyVids`,
link: `https://www.manyvids.com/Profile/${uid}/${profile.urlHandle}/Store/Videos`,
image: profile.avatar,
description: profile.bio,
item: items,
};
}