Merge pull request 'Release 0.4: using Plyr.js for mp4 and Video.js for hls' (#99) from v0.4.0/migrate-to-plyr-js into develop

Reviewed-on: #99
This commit is contained in:
lamacchinadesiderante 2024-05-25 13:05:50 +00:00
commit e09e8d2f15
7 changed files with 29 additions and 14 deletions

View File

@ -24,7 +24,7 @@ export default async function VideoPage({ params }: { params: { platform: Platfo
const [data, related] = await new VideoAgent(platform).getVideo(decodedId)
if (!data.lowResUrl && (!data.srcSet || data.srcSet.length == 0)) {
if (!data.hlsUrl && (!data.srcSet || data.srcSet.length == 0)) {
redirect(`/${locale}/404`)
}

View File

@ -17,8 +17,8 @@ const VideoJS: React.FC<Props> = (props) => {
const { data } = props;
const videoSrc = data.hlsUrl ?? data.lowResUrl
const videoType = data.hlsUrl ? 'application/x-mpegURL' : 'video/mp4'
const videoSrc = data.hlsUrl
const videoType = 'application/x-mpegURL'
const playerRef = React.useRef(null);

View File

@ -11,7 +11,6 @@ import Results from '@/components/Layout/Results';
import { GalleryData, VideoData } from '@/meta/data';
import { Platforms } from '@/meta/settings';
import Disclaimer from '@/components/Layout/Header/Disclaimer';
import { platform } from 'os';
interface Props {
@ -29,7 +28,7 @@ const Video: React.FC<Props> = (props) => {
<>
<Header />
<Disclaimer platform={platform} />
{data.srcSet ? <PlyrJS data={data} /> : <VideoJS data={data} />}
{data.hlsUrl ? <VideoJS data={data} /> : <PlyrJS data={data} />}
<SearchBar />
{related && <Results data={related} />}
</>

View File

@ -19,8 +19,6 @@ export interface VideoSourceItem {
}
export interface VideoData {
lowResUrl?: string,
hiResUrl?: string,
hlsUrl?: string
srcSet?: VideoSourceItem[]
}

View File

@ -13,7 +13,7 @@ import { getPornHubMediaUrlList, getPornHubRelatedVideoData } from "./url";
export const fetchPornHubVideoData = async (videoId: string, params?: FetchParams): Promise<[VideoData, GalleryData[]]> => {
let data: VideoData = {
lowResUrl: '',
hlsUrl: '',
srcSet: []
}

View File

@ -14,7 +14,8 @@ import { getDataFromRedis, storeDataIntoRedis } from '@/redis/client';
export const fetchXNXXVideoData = async (videoId: string, params?: FetchParams): Promise<[VideoData, GalleryData[]]> => {
let data: VideoData = {
lowResUrl: ''
hlsUrl: '',
srcSet: []
}
let related: GalleryData[] = [];
@ -50,11 +51,19 @@ export const fetchXNXXVideoData = async (videoId: string, params?: FetchParams):
const hlsUrl = findVideoUrlInsideTagStringByFunctionNameAndExtension($(elem).toString(), 'setVideoHLS', '.m3u8')
if (lowResUrl) {
data.lowResUrl = lowResUrl;
data.srcSet?.push({
src: lowResUrl,
type: 'video/mp4',
size: "480"
})
}
if (hiResUrl) {
data.hiResUrl = hiResUrl
data.srcSet?.push({
src: hiResUrl,
type: 'video/mp4',
size: "720"
})
}
if (hlsUrl) {

View File

@ -14,7 +14,8 @@ import { DEFAULT_RELATED_VIDEO_KEY_PATH, DEFAULT_XVIDEOS_CONTENT_EXPIRY } from '
export const fetchXvideosVideoData = async (videoId: string, params?: FetchParams): Promise<[VideoData, GalleryData[]]> => {
let data: VideoData = {
lowResUrl: ''
hlsUrl: '',
srcSet: []
}
let related: GalleryData[] = [];
@ -50,11 +51,19 @@ export const fetchXvideosVideoData = async (videoId: string, params?: FetchParam
const hlsUrl = findVideoUrlInsideTagStringByFunctionNameAndExtension($(elem).toString(), 'setVideoHLS', '.m3u8')
if (lowResUrl) {
data.lowResUrl = lowResUrl;
data.srcSet?.push({
src: lowResUrl,
type: 'video/mp4',
size: "480"
})
}
if (hiResUrl) {
data.hiResUrl = hiResUrl
data.srcSet?.push({
src: hiResUrl,
type: 'video/mp4',
size: "720"
})
}
if (hlsUrl) {