mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-30 20:06:22 -05:00
Creating Video.validated which is used by find_corrupt_videos.py to search.
This commit is contained in:
parent
d0d315cd67
commit
e8e5b5727f
17 changed files with 253 additions and 125 deletions
|
|
@ -33,7 +33,7 @@ function getEpubViewerURL(previewFile) {
|
|||
}
|
||||
}
|
||||
|
||||
function getIframeModal(previewFile) {
|
||||
function getIframePreviewModal(previewFile) {
|
||||
const url = getMediaPathURL(previewFile);
|
||||
return <ModalContent>
|
||||
<div className='full-height'>
|
||||
|
|
@ -47,7 +47,7 @@ function getIframeModal(previewFile) {
|
|||
</ModalContent>
|
||||
}
|
||||
|
||||
function getImageModal(previewFile) {
|
||||
function getImagePreviewModal(previewFile) {
|
||||
const path = previewFile.primary_path ?? previewFile.path;
|
||||
const url = getMediaPathURL(previewFile);
|
||||
// Get the file name from the absolute path.
|
||||
|
|
@ -64,7 +64,7 @@ function getImageModal(previewFile) {
|
|||
</React.Fragment>
|
||||
}
|
||||
|
||||
function getEpubModal(previewFile) {
|
||||
function getEpubPreviewModal(previewFile) {
|
||||
const downloadURL = getDownloadPathURL(previewFile);
|
||||
const viewerUrl = `/epub/epub.html?url=${downloadURL}`;
|
||||
return <ModalContent>
|
||||
|
|
@ -77,11 +77,10 @@ function getEpubModal(previewFile) {
|
|||
</ModalContent>
|
||||
}
|
||||
|
||||
function getVideoModal(previewFile) {
|
||||
function getVideoPreviewModal(previewFile) {
|
||||
const url = getMediaPathURL(previewFile);
|
||||
const path = previewFile.primary_path ?? previewFile.path;
|
||||
const name = path.replace(/^.*[\\\/]/, '');
|
||||
const type = previewFile.mimetype ? previewFile.mimetype : 'video/mp4';
|
||||
return <React.Fragment>
|
||||
<ModalHeader>
|
||||
{name}
|
||||
|
|
@ -94,13 +93,13 @@ function getVideoModal(previewFile) {
|
|||
playsInline={true}
|
||||
style={{maxWidth: '100%'}}
|
||||
>
|
||||
<source src={url} type={type}/>
|
||||
<source src={url}/>
|
||||
</video>
|
||||
</ModalContent>
|
||||
</React.Fragment>
|
||||
}
|
||||
|
||||
function getAudioModal(previewFile) {
|
||||
function getAudioPreviewModal(previewFile) {
|
||||
const url = getMediaPathURL(previewFile);
|
||||
const path = previewFile.primary_path ?? previewFile.path;
|
||||
const name = path.replace(/^.*[\\\/]/, '');
|
||||
|
|
@ -123,7 +122,7 @@ function getAudioModal(previewFile) {
|
|||
</React.Fragment>
|
||||
}
|
||||
|
||||
function getSTLModal(previewFile) {
|
||||
function getSTLPreviewModal(previewFile) {
|
||||
const url = getMediaPathURL(previewFile);
|
||||
const path = previewFile.primary_path ?? previewFile.path;
|
||||
const name = path.replace(/^.*[\\\/]/, '');
|
||||
|
|
@ -139,7 +138,7 @@ function getSTLModal(previewFile) {
|
|||
</React.Fragment>
|
||||
}
|
||||
|
||||
function getGenericModal(previewFile) {
|
||||
function getGenericPreviewModal(previewFile) {
|
||||
// No special handler for this file type, just open it.
|
||||
const path = previewFile.primary_path ?? previewFile.path;
|
||||
const name = path.replace(/^.*[\\\/]/, '');
|
||||
|
|
@ -275,27 +274,27 @@ export function FilePreviewProvider({children}) {
|
|||
// Large text files should be downloaded.
|
||||
window.open(downloadURL);
|
||||
} else if (mimetype.startsWith('text/') || mimetype.startsWith('application/json')) {
|
||||
setModalContent(getIframeModal(previewFile), url, downloadURL, path);
|
||||
setModalContent(getIframePreviewModal(previewFile), url, downloadURL, path);
|
||||
} else if (mimetype.startsWith('video/')) {
|
||||
setModalContent(getVideoModal(previewFile), url, downloadURL, path);
|
||||
setModalContent(getVideoPreviewModal(previewFile), url, downloadURL, path);
|
||||
} else if (mimetype.startsWith('audio/')) {
|
||||
setModalContent(getAudioModal(previewFile), url, downloadURL, path);
|
||||
setModalContent(getAudioPreviewModal(previewFile), url, downloadURL, path);
|
||||
} else if (mimetype.startsWith('application/epub')) {
|
||||
const viewerURL = getEpubViewerURL(previewFile);
|
||||
setModalContent(getEpubModal(previewFile), viewerURL, downloadURL, path);
|
||||
setModalContent(getEpubPreviewModal(previewFile), viewerURL, downloadURL, path);
|
||||
} else if (mimetype.startsWith('application/pdf')) {
|
||||
setModalContent(getIframeModal(previewFile), url, downloadURL, path);
|
||||
setModalContent(getIframePreviewModal(previewFile), url, downloadURL, path);
|
||||
} else if (mimetype.startsWith('image/')) {
|
||||
setModalContent(getImageModal(previewFile), url, null, path);
|
||||
setModalContent(getImagePreviewModal(previewFile), url, null, path);
|
||||
} else if (mimetype.startsWith('model/stl')) {
|
||||
setModalContent(getSTLModal(previewFile), null, downloadURL, path);
|
||||
setModalContent(getSTLPreviewModal(previewFile), null, downloadURL, path);
|
||||
} else if (mimetype.startsWith('application/octet-stream') && lowerPath.endsWith('.mp3')) {
|
||||
setModalContent(getAudioModal(previewFile), url, downloadURL, path);
|
||||
setModalContent(getAudioPreviewModal(previewFile), url, downloadURL, path);
|
||||
} else if (mimetype.startsWith('application/octet-stream') && lowerPath.endsWith('.stl')) {
|
||||
setModalContent(getSTLModal(previewFile), null, downloadURL, path);
|
||||
setModalContent(getSTLPreviewModal(previewFile), null, downloadURL, path);
|
||||
} else {
|
||||
// No special handler for this file type, just open it.
|
||||
setModalContent(getGenericModal(previewFile), url, downloadURL, path);
|
||||
setModalContent(getGenericPreviewModal(previewFile), url, downloadURL, path);
|
||||
}
|
||||
}
|
||||
}, [previewFile]);
|
||||
|
|
|
|||
|
|
@ -193,11 +193,6 @@ function VideoPage({videoFile, prevFile, nextFile, fetchVideo, ...props}) {
|
|||
}
|
||||
|
||||
let videoSource = <source src={videoUrl}/>;
|
||||
if (video.codec_names && video.codec_names.indexOf('mp4') >= 0) {
|
||||
videoSource = <source src={videoUrl} type="video/mp4"/>
|
||||
} else if (video.codec_names && video.codec_names.indexOf('vp9') >= 0) {
|
||||
videoSource = <source src={videoUrl} type='video/mp4;codecs="vp9, vorbis"'/>
|
||||
}
|
||||
|
||||
return <>
|
||||
<Container style={{margin: '1em'}}>
|
||||
|
|
|
|||
|
|
@ -77,30 +77,14 @@ class DownloadRow extends React.Component {
|
|||
super(props);
|
||||
this.state = {
|
||||
errorModalOpen: false,
|
||||
deleteOpen: false,
|
||||
}
|
||||
}
|
||||
|
||||
openDelete = (e) => {
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
this.setState({deleteOpen: true});
|
||||
}
|
||||
|
||||
closeDelete = (e) => {
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
this.setState({deleteOpen: false});
|
||||
}
|
||||
|
||||
handleDelete = async () => {
|
||||
const {id} = this.props;
|
||||
try {
|
||||
await deleteDownload(id);
|
||||
} finally {
|
||||
this.closeDelete();
|
||||
if (this.props.fetchDownloads) {
|
||||
this.props.fetchDownloads();
|
||||
}
|
||||
|
|
@ -109,7 +93,7 @@ class DownloadRow extends React.Component {
|
|||
|
||||
render() {
|
||||
let {url, frequency, last_successful_download, status, location, next_download, error} = this.props;
|
||||
const {errorModalOpen, deleteOpen} = this.state;
|
||||
const {errorModalOpen} = this.state;
|
||||
|
||||
const link = location ?
|
||||
(text) => <Link to={location}>{text}</Link> :
|
||||
|
|
@ -171,9 +155,6 @@ class DownloadRow extends React.Component {
|
|||
class StoppableRow extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
errorModalOpen: false,
|
||||
};
|
||||
}
|
||||
|
||||
handleDelete = async () => {
|
||||
|
|
@ -194,7 +175,6 @@ class StoppableRow extends React.Component {
|
|||
|
||||
render() {
|
||||
let {url, last_successful_download, status, location, error} = this.props;
|
||||
let {errorModalOpen} = this.state;
|
||||
|
||||
// Open downloads (/download), or external links in an anchor.
|
||||
const link = location && !location.startsWith('/download') ?
|
||||
|
|
@ -326,13 +306,15 @@ export function RecurringDownloadsTable({downloads, fetchDownloads}) {
|
|||
export function DownloadsPage() {
|
||||
useTitle('Downloads');
|
||||
|
||||
const {onceDownloads, recurringDownloads, fetchDownloads} = useDownloads();
|
||||
const {onceDownloads, recurringDownloads, pendingOnceDownloads, fetchDownloads} = useDownloads();
|
||||
|
||||
const pendingOnceDownloadsSpan = pendingOnceDownloads > 0 ? <span>({pendingOnceDownloads})</span> : null;
|
||||
|
||||
return <>
|
||||
<WROLModeMessage content='Downloads are disabled because WROL Mode is enabled.'/>
|
||||
<DisableDownloadsToggle/>
|
||||
|
||||
<Header as='h1'>Downloads</Header>
|
||||
<Header as='h1'>Downloads {pendingOnceDownloadsSpan}</Header>
|
||||
<OnceDownloadsTable downloads={onceDownloads} fetchDownloads={fetchDownloads}/>
|
||||
|
||||
<Header as='h1'>Recurring Downloads</Header>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue