import React, {useContext, useState} from 'react';
import {deleteVideos} from "../api";
import {Link, useNavigate, useParams} from "react-router-dom";
import _ from "lodash";
import {BackButton, epochToDateString, humanFileSize, humanNumber, PageContainer, useTitle} from "./Common";
import {Confirm} from "semantic-ui-react";
import Grid from "semantic-ui-react/dist/commonjs/collections/Grid";
import Container from "semantic-ui-react/dist/commonjs/elements/Container";
import {VideoPlaceholder} from "./Placeholder";
import {useChannel} from "../hooks/customHooks";
import {ThemeContext} from "../contexts/contexts";
import {Button, darkTheme, Header, Icon, Segment, Tab, TabPane} from "./Theme";
import {VideoCard} from "./Videos";
const MEDIA_PATH = '/media';
function videoFileLink(video, name, directory = false) {
const path = video[name];
if (path) {
const href = directory ?
`${MEDIA_PATH}/${encodeURIComponent(path)}/` :
`${MEDIA_PATH}/${encodeURIComponent(path)}`;
return
{video.size ? humanFileSize(video.size) : '???'} {video.url ? {video.url} : 'N/A'} {viewCount ? humanNumber(viewCount) : 'N/A'} {video.censored ? 'Yes' : 'No'}
{favorite_button}
{path}
} else {
return 'Unknown'
}
}
function VideoPage({videoFile, prevFile, nextFile, setFavorite, ...props}) {
const {theme} = useContext(ThemeContext);
const navigate = useNavigate();
const videoRef = React.useRef();
let [deleteOpen, setDeleteOpen] = useState(false);
useTitle(videoFile === null || videoFile === undefined ? null : videoFile.video.title);
let video;
if (videoFile) {
video = videoFile.video;
}
// Seeks to the `seconds` on video player.
const setVideoTime = (seconds) => {
videoRef.current.currentTime = seconds;
}
// Get the Video's channel, fallback to the URL's channel id.
const {channelId} = useParams();
const {channel} = useChannel(video && video.channel_id ? video.channel_id : channelId);
if (videoFile === null) {
return
{description}
Size
Source URL
View Count
Censored
{video.caption}
Video File
{videoFileLink(video, 'video_path')}
Info JSON File
{videoFileLink(video, 'info_json_path')}
Caption File
{videoFileLink(video, 'caption_path')}
Poster File
{videoFileLink(video, 'poster_path')}
Directory
{videoFileLink(video, 'directory', true)}
{epochToDateString(video.upload_date)}
}
{channel &&
{channel.name}
}