mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-01 12:26:19 -05:00
A user can define a destination when creating a channel/playlist download. This destination is then sent to VideoDownloader.
This commit is contained in:
parent
027d305abb
commit
7f54e592ed
4 changed files with 66 additions and 13 deletions
|
|
@ -752,12 +752,12 @@ export function mimetypeColor(mimetype) {
|
|||
return 'pink'
|
||||
} else if (mimetype.startsWith('text/html')) {
|
||||
return 'green'
|
||||
} else if (mimetype.startsWith('application/zip') || mimetype.startsWith('application/zlib') || mimetype.startsWith('application/x-7z-compressed') || mimetype.startsWith('application/x-bzip2') || mimetype.startsWith('application/x-xz')) {
|
||||
return 'purple'
|
||||
} else if (mimetype.startsWith('application/epub') || mimetype.startsWith('application/x-mobipocket-ebook')) {
|
||||
} else if (mimetype.startsWith('application/epub')) {
|
||||
return 'yellow'
|
||||
} else if (mimetype.startsWith('audio/')) {
|
||||
return 'violet'
|
||||
} else if (isZipMimetype(mimetype)) {
|
||||
return 'purple'
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
|
|
|||
|
|
@ -161,7 +161,15 @@ class ChannelDownload extends React.Component {
|
|||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
url: '', frequency: 604800, pending: false, disabled: false, ready: false, error: null, success: null,
|
||||
advancedOpen: false,
|
||||
destination: null,
|
||||
disabled: false,
|
||||
error: null,
|
||||
frequency: 604800,
|
||||
pending: false,
|
||||
ready: false,
|
||||
success: null,
|
||||
url: '',
|
||||
};
|
||||
this.freqOptions = [{key: 'once', text: 'Once', value: 0}, ...frequencyOptions.slice(1),];
|
||||
this.handleUrlChange = this.handleUrlChange.bind(this);
|
||||
|
|
@ -181,12 +189,13 @@ class ChannelDownload extends React.Component {
|
|||
|
||||
handleSubmit = async () => {
|
||||
this.setState({disabled: true, pending: true, success: null, error: null});
|
||||
const {url, frequency} = this.state;
|
||||
const {url, frequency, destination} = this.state;
|
||||
if (!url) {
|
||||
this.setState({error: 'URL is required'});
|
||||
return;
|
||||
}
|
||||
let response = await postDownload(url, 'video_channel', frequency);
|
||||
let response = await postDownload(url, 'video_channel', frequency,
|
||||
null, null, destination);
|
||||
if (response.status === 204) {
|
||||
this.setState({pending: false, disabled: false, success: true, url: '', ready: false});
|
||||
} else {
|
||||
|
|
@ -196,8 +205,15 @@ class ChannelDownload extends React.Component {
|
|||
}
|
||||
}
|
||||
|
||||
toggleAdvancedAccordion = (e) => {
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
this.setState({advancedOpen: !this.state.advancedOpen});
|
||||
}
|
||||
|
||||
render() {
|
||||
const {ready, disabled, url, error, frequency, pending, success} = this.state;
|
||||
const {advancedOpen, ready, disabled, url, error, frequency, pending, success} = this.state;
|
||||
const buttonDisabled = !ready || disabled;
|
||||
|
||||
const onceMessage = (<Message>
|
||||
|
|
@ -207,6 +223,17 @@ class ChannelDownload extends React.Component {
|
|||
in the future.</Message.Content>
|
||||
</Message>);
|
||||
|
||||
const directorySearch = <div style={{marginTop: '1em'}}>
|
||||
<SForm.Field>
|
||||
<label>
|
||||
Destination
|
||||
<HelpPopup
|
||||
content="Always download videos into this directory, rather than the Channel's directory."/>
|
||||
</label>
|
||||
<DirectorySearch onSelect={i => this.setState({destination: i})}/>
|
||||
</SForm.Field>
|
||||
</div>;
|
||||
|
||||
return <Form>
|
||||
<WROLModeMessage content='Downloading is disabled while WROL Mode is enabled'/>
|
||||
<Header as='h4'><Icon name='film' color='blue'/> Channel / Playlist</Header>
|
||||
|
|
@ -232,6 +259,18 @@ class ChannelDownload extends React.Component {
|
|||
|
||||
{frequency === 0 && onceMessage}
|
||||
|
||||
<Accordion>
|
||||
<AccordionTitle active={advancedOpen} onClick={this.toggleAdvancedAccordion}>
|
||||
<Icon name='dropdown'/>
|
||||
Advanced
|
||||
</AccordionTitle>
|
||||
<AccordionContent active={advancedOpen}>
|
||||
{directorySearch}
|
||||
</AccordionContent>
|
||||
</Accordion>
|
||||
|
||||
<br/>
|
||||
|
||||
<Button content='Cancel' onClick={this.props.clearSelected}/>
|
||||
<APIButton
|
||||
onClick={this.handleSubmit}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue