import React, {useContext, useState} from 'react';
import {addTag, deleteVideos, removeTag} from "../api";
import {Link, useNavigate, useParams} from "react-router-dom";
import _ from "lodash";
import {
BackButton,
encodeMediaPath,
humanFileSize,
humanNumber,
isoDatetimeToString,
PageContainer,
PreviewPath,
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";
import {TagsSelector} from "../Tags";
const MEDIA_PATH = '/media';
function videoFileLink(path, directory = false) {
if (path) {
const href = directory ?
// Add / to end of directory.
`${MEDIA_PATH}/${encodeMediaPath(path)}/` :
`${MEDIA_PATH}/${encodeMediaPath(path)}`;
return
{videoFile.size ? humanFileSize(videoFile.size) : 'Unknown'} {video.url ? {video.url} : 'N/A'} {video.view_count ? humanNumber(video.view_count) : 'N/A'} {video.censored ? 'Yes' : 'No'}
{path}
} else {
return 'Unknown'
}
}
function VideoPage({videoFile, prevFile, nextFile, fetchVideo, ...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 || 'No captions available.'}
Video File
{videoFileLink(video['video_path'])}
Info JSON File
{info_json_file &&
Caption Files
{caption_files &&
caption_files.map(i => Poster File
{poster_file &&
Directory
{videoFileLink(videoFile['directory'], true)}
{isoDatetimeToString(video.upload_date)}
}
{channel &&
{channel.name}
}