Release v0.4: Add PornHub support / Server-side streaming / Plyr.js / Video srcset #96

Merged
lamacchinadesiderante merged 18 commits from feature/pornhub-support into develop 2024-05-25 11:46:42 +00:00
1 changed files with 3 additions and 16 deletions
Showing only changes of commit 81b3bb8660 - Show all commits

View File

@ -17,8 +17,6 @@ export const fetchPornHubVideoData = async (videoId: string, params?: FetchParam
srcSet: [] srcSet: []
} }
let related: GalleryData[] = [];
let mediaUrl, sessionCookie, convertedData: VideoSourceItem[] let mediaUrl, sessionCookie, convertedData: VideoSourceItem[]
let reqHeaders = getHeaders(PORNHUB_BASE_URL) let reqHeaders = getHeaders(PORNHUB_BASE_URL)
@ -26,10 +24,9 @@ export const fetchPornHubVideoData = async (videoId: string, params?: FetchParam
const queryUrl = `${PORNHUB_BASE_URL_VIDEO}${videoId.replace(/\//g, '')}` const queryUrl = `${PORNHUB_BASE_URL_VIDEO}${videoId.replace(/\//g, '')}`
const cachedVideoData = await getDataFromRedis(queryUrl) const cachedVideoData = await getDataFromRedis(queryUrl)
const cachedRelatedData = await getDataFromRedis(queryUrl + DEFAULT_RELATED_VIDEO_KEY_PATH)
if (cachedVideoData) { if (cachedVideoData) {
return [cachedVideoData as VideoData, cachedRelatedData as GalleryData[] ?? []] return [cachedVideoData as VideoData, []]
} }
await axios.get(queryUrl, reqHeaders) await axios.get(queryUrl, reqHeaders)
@ -51,14 +48,6 @@ export const fetchPornHubVideoData = async (videoId: string, params?: FetchParam
mediaUrl = getMediaUrl mediaUrl = getMediaUrl
} }
// // populate related gallery
// scriptTags.map((idx, elem) => {
// // magic goes here
// })
// await storeDataIntoRedis(queryUrl + DEFAULT_RELATED_VIDEO_KEY_PATH, related, DEFAULT_PORNHUB_VIDEO_EXPIRY);
}) })
}).catch((error: AxiosError) => { }).catch((error: AxiosError) => {
@ -67,12 +56,10 @@ export const fetchPornHubVideoData = async (videoId: string, params?: FetchParam
if (sessionCookie && mediaUrl) { if (sessionCookie && mediaUrl) {
convertedData = await getPornHubMediaUrlList(mediaUrl, sessionCookie) convertedData = await getPornHubMediaUrlList(mediaUrl, sessionCookie)
await storeDataIntoRedis(queryUrl, convertedData, DEFAULT_PORNHUB_VIDEO_EXPIRY);
data.srcSet = convertedData.reverse() data.srcSet = convertedData.reverse()
await storeDataIntoRedis(queryUrl, data, DEFAULT_PORNHUB_VIDEO_EXPIRY);
} }
return [ data, []] return [ data, []]
// return [ { lowResUrl: 'https://www.w3schools.com/html/mov_bbb.mp4' } ,[]]
} }