From bfe0af95fed2edcdbc471e9c4defbdd49c6a0e03 Mon Sep 17 00:00:00 2001 From: Tony Date: Tue, 4 Jun 2024 23:29:11 +0800 Subject: [PATCH] feat(route): manyvids (#15822) --- lib/routes/mangadex/namespace.ts | 2 +- lib/routes/manyvids/namespace.ts | 7 ++ lib/routes/manyvids/templates/video.art | 3 + lib/routes/manyvids/types.ts | 89 +++++++++++++++++++++++++ lib/routes/manyvids/video.ts | 51 ++++++++++++++ 5 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 lib/routes/manyvids/namespace.ts create mode 100644 lib/routes/manyvids/templates/video.art create mode 100644 lib/routes/manyvids/types.ts create mode 100644 lib/routes/manyvids/video.ts diff --git a/lib/routes/mangadex/namespace.ts b/lib/routes/mangadex/namespace.ts index d7d9327f9..f7d015eb1 100644 --- a/lib/routes/mangadex/namespace.ts +++ b/lib/routes/mangadex/namespace.ts @@ -1,6 +1,6 @@ import type { Namespace } from '@/types'; export const namespace: Namespace = { - name: 'Unknown', + name: 'MangaDex', url: 'mangadex.org', }; diff --git a/lib/routes/manyvids/namespace.ts b/lib/routes/manyvids/namespace.ts new file mode 100644 index 000000000..aec6fa113 --- /dev/null +++ b/lib/routes/manyvids/namespace.ts @@ -0,0 +1,7 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: 'ManyVids', + url: 'www.manyvids.com', + categories: ['multimedia'], +}; diff --git a/lib/routes/manyvids/templates/video.art b/lib/routes/manyvids/templates/video.art new file mode 100644 index 000000000..63d221442 --- /dev/null +++ b/lib/routes/manyvids/templates/video.art @@ -0,0 +1,3 @@ + diff --git a/lib/routes/manyvids/types.ts b/lib/routes/manyvids/types.ts new file mode 100644 index 000000000..f8529b69b --- /dev/null +++ b/lib/routes/manyvids/types.ts @@ -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; +} diff --git a/lib/routes/manyvids/video.ts b/lib/routes/manyvids/video.ts new file mode 100644 index 000000000..51b8e86e6 --- /dev/null +++ b/lib/routes/manyvids/video.ts @@ -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; + +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(`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, + }; +}