mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-22 16:06:19 -05:00
Not using browser profile if it is disabled, even if always_user_browser_profile is enabled. This enables the user to selectively disable cookies.
This commit is contained in:
parent
b9f39d7819
commit
41c52b9c1e
3 changed files with 37 additions and 8 deletions
|
|
@ -1,6 +1,14 @@
|
|||
import React, {useState} from "react";
|
||||
import {fetchVideoDownloaderConfig, getDownloaders, postDownload, putDownload} from "../api";
|
||||
import {APIButton, DirectorySearch, InfoHeader, InfoPopup, mergeDeep, RequiredAsterisk, useLocalStorage} from "./Common";
|
||||
import {
|
||||
APIButton,
|
||||
DirectorySearch,
|
||||
InfoHeader,
|
||||
InfoPopup,
|
||||
mergeDeep,
|
||||
RequiredAsterisk,
|
||||
useLocalStorage
|
||||
} from "./Common";
|
||||
import Icon from "semantic-ui-react/dist/commonjs/elements/Icon";
|
||||
import Message from "semantic-ui-react/dist/commonjs/collections/Message";
|
||||
import {Button, Form, FormInput, Header} from "./Theme";
|
||||
|
|
@ -8,7 +16,15 @@ import {Form as SForm, FormDropdown} from "semantic-ui-react";
|
|||
import {Link} from "react-router-dom";
|
||||
import {TagsSelector} from "../Tags";
|
||||
import Grid from "semantic-ui-react/dist/commonjs/collections/Grid";
|
||||
import {commaSeparatedValidator, InputForm, NumberInputForm, ToggleForm, UrlInput, UrlsTextarea, useForm} from "../hooks/useForm";
|
||||
import {
|
||||
commaSeparatedValidator,
|
||||
InputForm,
|
||||
NumberInputForm,
|
||||
ToggleForm,
|
||||
UrlInput,
|
||||
UrlsTextarea,
|
||||
useForm
|
||||
} from "../hooks/useForm";
|
||||
import {
|
||||
channelFrequencyOptions,
|
||||
days30Option,
|
||||
|
|
@ -22,6 +38,7 @@ import {
|
|||
frequencyOptions,
|
||||
weeklyOption
|
||||
} from "./Vars";
|
||||
import _ from "lodash";
|
||||
|
||||
export function DepthInputForm({form, required, name = 'depth', path = 'settings.depth'}) {
|
||||
return <NumberInputForm
|
||||
|
|
@ -339,6 +356,10 @@ export function UseBrowserProfile({form}) {
|
|||
const localFetchConfig = async () => {
|
||||
const result = await fetchVideoDownloaderConfig();
|
||||
setConfig(result);
|
||||
if (result?.always_use_browser_profile === true) {
|
||||
// Enable the toggle if "always_use_browser_profile" is set.
|
||||
form.setValue('settings.use_browser_profile', true);
|
||||
}
|
||||
}
|
||||
|
||||
React.useEffect(() => {
|
||||
|
|
|
|||
|
|
@ -175,6 +175,10 @@ export function useForm({
|
|||
}
|
||||
}
|
||||
|
||||
const setValue = (path, newValue) => {
|
||||
patchFormData(_.set(formData, path, newValue));
|
||||
}
|
||||
|
||||
const getCustomProps = ({name, validator, type = 'text', path, required = false}) => {
|
||||
// Props for any other elements.
|
||||
|
||||
|
|
@ -188,8 +192,8 @@ export function useForm({
|
|||
patchFormData(_.set(formData, path, type === 'array' ? [] : null));
|
||||
}
|
||||
// Allow bypass of `handleInputEvent` which only handles an input event.
|
||||
const setValue = newValue => {
|
||||
patchFormData(_.set(formData, path, newValue));
|
||||
const localSetValue = newValue => {
|
||||
setValue(path, newValue);
|
||||
debouncedValidate(path, newValue);
|
||||
}
|
||||
|
||||
|
|
@ -198,14 +202,14 @@ export function useForm({
|
|||
type,
|
||||
disabled,
|
||||
value,
|
||||
onChange: setValue,
|
||||
onChange: (newValue) => {setValue(path, newValue)},
|
||||
'data-path': path,
|
||||
}
|
||||
// Attributes about the input, but should not be passed as properties.
|
||||
const inputAttrs = {
|
||||
valid: validValues[path],
|
||||
path,
|
||||
setValue,
|
||||
localSetValue,
|
||||
};
|
||||
return [inputProps, inputAttrs]
|
||||
}
|
||||
|
|
@ -259,6 +263,7 @@ export function useForm({
|
|||
getInputProps,
|
||||
getSelectionProps,
|
||||
handleInputEvent,
|
||||
setValue,
|
||||
loading,
|
||||
onSubmit,
|
||||
ready,
|
||||
|
|
@ -440,4 +445,4 @@ export function ToggleForm({form, name, label, path, icon = null, iconSize = 'bi
|
|||
onChange={inputProps.onChange}
|
||||
/>
|
||||
</FormInput>
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -429,7 +429,10 @@ class VideoDownloader(Downloader, ABC):
|
|||
cmd = (*cmd, '--write-info-json')
|
||||
if config.yt_dlp_extra_args:
|
||||
cmd = (*cmd, *config.yt_dlp_extra_args.split(' '))
|
||||
if config.browser_profile and (config.always_use_browser_profile or settings.get('use_browser_profile')):
|
||||
if config.browser_profile and (
|
||||
(i := settings.get('use_browser_profile')) or (config.always_use_browser_profile and i != False)):
|
||||
# Use the browser profile to get cookies, but only if "always_use_browser_profile" is set and
|
||||
# "use_browser_profile" is not False, or if "use_browser_profile" is set.
|
||||
browser_profile = pathlib.Path(config.browser_profile)
|
||||
if browser_profile.exists():
|
||||
browser_profile = browser_profile_to_yt_dlp_arg(browser_profile)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue