Skip to content

Commit

Permalink
feat(route): manyvids (#15822)
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyRL authored Jun 4, 2024
1 parent 857f180 commit bfe0af9
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/routes/mangadex/namespace.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: 'Unknown',
name: 'MangaDex',
url: 'mangadex.org',
};
7 changes: 7 additions & 0 deletions lib/routes/manyvids/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: 'ManyVids',
url: 'www.manyvids.com',
categories: ['multimedia'],
};
3 changes: 3 additions & 0 deletions lib/routes/manyvids/templates/video.art
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<video controls preload="metadata" poster="{{ poster }}">
<source src="{{ src }}" type="video/mp4">
</video>
89 changes: 89 additions & 0 deletions lib/routes/manyvids/types.ts
Original file line number Diff line number Diff line change
@@ -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;
}
51 changes: 51 additions & 0 deletions lib/routes/manyvids/video.ts
Original file line number Diff line number Diff line change
@@ -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,
};
}

0 comments on commit bfe0af9

Please sign in to comment.