Release v0.4.0 #110
|
@ -1,8 +1,9 @@
|
||||||
|
import { Platforms } from "@/meta/settings";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|
||||||
type GetParams = {
|
type GetParams = {
|
||||||
params: {
|
params: {
|
||||||
platform: string
|
platform: Platforms
|
||||||
encodedUrl: string
|
encodedUrl: string
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -11,6 +12,16 @@ export async function GET(req: Request, { params }: GetParams) {
|
||||||
|
|
||||||
const { platform, encodedUrl } = params;
|
const { platform, encodedUrl } = params;
|
||||||
|
|
||||||
|
if (!Object.keys(Platforms).includes(platform)) {
|
||||||
|
return Response.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: 'Platform not supported!'
|
||||||
|
},
|
||||||
|
{ status: 404 }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const decodedUrl = decodeURIComponent(encodedUrl)
|
const decodedUrl = decodeURIComponent(encodedUrl)
|
||||||
|
|
||||||
const response = await axios.get<ReadableStream>(decodedUrl, {
|
const response = await axios.get<ReadableStream>(decodedUrl, {
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { PORNHUB_BASE_URL } from "@/constants/urls"
|
||||||
import axios, { AxiosHeaders } from "axios"
|
import axios, { AxiosHeaders } from "axios"
|
||||||
import { getHeadersWithCookie } from "../common/headers"
|
import { getHeadersWithCookie } from "../common/headers"
|
||||||
import { VideoSourceItem } from "@/meta/data"
|
import { VideoSourceItem } from "@/meta/data"
|
||||||
|
import { Platforms } from "@/meta/settings"
|
||||||
|
|
||||||
interface PornHubVideoSrcElem {
|
interface PornHubVideoSrcElem {
|
||||||
videoUrl: string
|
videoUrl: string
|
||||||
|
@ -28,7 +29,7 @@ export const getPornHubMediaUrlList = async (url: string, sessionCookie: string)
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
|
|
||||||
videos = await response.data.map((elem: PornHubVideoSrcElem) => ({
|
videos = await response.data.map((elem: PornHubVideoSrcElem) => ({
|
||||||
src: elem?.videoUrl,
|
src: `/api/stream/${Platforms.pornhub}/${encodeURIComponent(elem?.videoUrl)}`,
|
||||||
type: 'video/mp4',
|
type: 'video/mp4',
|
||||||
size: elem?.quality
|
size: elem?.quality
|
||||||
})) as VideoSourceItem[]
|
})) as VideoSourceItem[]
|
||||||
|
|
Loading…
Reference in New Issue