complete server-side streaming
This commit is contained in:
parent
d8af939e31
commit
1ad9b46ea3
|
@ -1,8 +1,9 @@
|
|||
import { Platforms } from "@/meta/settings";
|
||||
import axios from "axios";
|
||||
|
||||
type GetParams = {
|
||||
params: {
|
||||
platform: string
|
||||
platform: Platforms
|
||||
encodedUrl: string
|
||||
};
|
||||
};
|
||||
|
@ -11,6 +12,16 @@ export async function GET(req: Request, { params }: GetParams) {
|
|||
|
||||
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 response = await axios.get<ReadableStream>(decodedUrl, {
|
||||
|
|
|
@ -2,6 +2,7 @@ import { PORNHUB_BASE_URL } from "@/constants/urls"
|
|||
import axios, { AxiosHeaders } from "axios"
|
||||
import { getHeadersWithCookie } from "../common/headers"
|
||||
import { VideoSourceItem } from "@/meta/data"
|
||||
import { Platforms } from "@/meta/settings"
|
||||
|
||||
interface PornHubVideoSrcElem {
|
||||
videoUrl: string
|
||||
|
@ -28,7 +29,7 @@ export const getPornHubMediaUrlList = async (url: string, sessionCookie: string)
|
|||
if (response.data) {
|
||||
|
||||
videos = await response.data.map((elem: PornHubVideoSrcElem) => ({
|
||||
src: elem?.videoUrl,
|
||||
src: `/api/stream/${Platforms.pornhub}/${encodeURIComponent(elem?.videoUrl)}`,
|
||||
type: 'video/mp4',
|
||||
size: elem?.quality
|
||||
})) as VideoSourceItem[]
|
||||
|
|
Loading…
Reference in New Issue