Move cast to app settings, #build

Changed:
- Moved cast to app settings
- Removed cast env var
This commit is contained in:
Simon
2025-03-08 18:37:20 +07:00
14 changed files with 397 additions and 393 deletions

View File

@@ -4,14 +4,14 @@ repos:
hooks:
- id: end-of-file-fixer
- repo: https://github.com/psf/black
rev: 24.10.0
rev: 25.1.0
hooks:
- id: black
alias: python
files: ^backend/
args: ["--line-length=79"]
- repo: https://github.com/pycqa/isort
rev: 5.13.2
rev: 6.0.1
hooks:
- id: isort
name: isort (python)
@@ -19,19 +19,19 @@ repos:
files: ^backend/
args: ["--profile", "black", "-l 79"]
- repo: https://github.com/pycqa/flake8
rev: 7.1.1
rev: 7.1.2
hooks:
- id: flake8
alias: python
files: ^backend/
args: ["--max-complexity=10", "--max-line-length=79"]
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
rev: v2.4.1
hooks:
- id: codespell
exclude: ^frontend/package-lock.json
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v9.17.0
rev: v9.22.0
hooks:
- id: eslint
name: eslint

View File

@@ -62,6 +62,7 @@ class AppConfigAppSerializer(
"""serialize app config"""
enable_snapshot = serializers.BooleanField()
enable_cast = serializers.BooleanField()
class AppConfigSerializer(ValidateUnknownFieldsMixin, serializers.Serializer):

View File

@@ -51,6 +51,7 @@ class ApplicationConfigType(TypedDict):
"""describes application config"""
enable_snapshot: bool
enable_cast: bool
class AppConfigType(TypedDict):
@@ -93,7 +94,10 @@ class AppConfig:
"integrate_ryd": False,
"integrate_sponsorblock": False,
},
"application": {"enable_snapshot": True},
"application": {
"enable_snapshot": True,
"enable_cast": False,
},
}
def __init__(self):

View File

@@ -24,7 +24,6 @@ class EnvironmentSettings:
HOST_UID: int = int(environ.get("HOST_UID", False))
HOST_GID: int = int(environ.get("HOST_GID", False))
ENABLE_CAST: bool = bool(environ.get("ENABLE_CAST"))
DISABLE_STATIC_AUTH: bool = bool(environ.get("DISABLE_STATIC_AUTH"))
TZ: str = str(environ.get("TZ", "UTC"))
TA_PORT: int = int(environ.get("TA_PORT", False))
@@ -73,7 +72,6 @@ class EnvironmentSettings:
HOST_UID: {self.HOST_UID}
HOST_GID: {self.HOST_GID}
TZ: {self.TZ}
ENABLE_CAST: {self.ENABLE_CAST}
DISABLE_STATIC_AUTH: {self.DISABLE_STATIC_AUTH}
TA_PORT: {self.TA_PORT}
TA_BACKEND_PORT: {self.TA_BACKEND_PORT}

View File

@@ -85,7 +85,6 @@ class Command(BaseCommand):
self._elastic_user_overwrite()
self._ta_port_overwrite()
self._ta_backend_port_overwrite()
self._enable_cast_overwrite()
self._create_superuser()
def _expected_vars(self):
@@ -167,14 +166,6 @@ class Command(BaseCommand):
self.stdout.write(self.style.SUCCESS(message))
def _enable_cast_overwrite(self):
"""enable cast env var"""
self.stdout.write("[6] check ENABLE_CAST overwrite")
overwrite = EnvironmentSettings.ENABLE_CAST
if not overwrite:
self.stdout.write(self.style.SUCCESS(" ENABLE_CAST is not set"))
return
def _disable_static_auth(self):
"""cast workaround, remove auth for static files in nginx"""
self.stdout.write("[7] check DISABLE_STATIC_AUTH overwrite")

View File

@@ -1,10 +1,10 @@
-r requirements.txt
ipython==8.32.0
ipython==9.0.1
pre-commit==4.1.0
pylint-django==2.6.1
pylint==3.3.4
pytest-django==4.10.0
pytest==8.3.4
pytest==8.3.5
python-dotenv==1.0.1
requirementscheck==0.0.5
types-requests==2.32.0.20241016
requirementscheck==0.0.6
types-requests==2.32.0.20250306

View File

@@ -3,7 +3,7 @@ celery==5.4.0
django-auth-ldap==5.1.0
django-celery-beat==2.7.0
django-cors-headers==4.7.0
Django==5.1.6
Django==5.1.7
djangorestframework==3.15.2
drf-spectacular==0.28.0
Pillow==11.1.0

View File

@@ -272,9 +272,9 @@ def thumbnail_check(self):
return
manager.init(self)
thumnail = ThumbValidator(task=self)
thumnail.validate()
thumnail.clean_up()
thumbnail = ThumbValidator(task=self)
thumbnail.validate()
thumbnail.clean_up()
@shared_task(bind=True, name="resync_thumbs", base=BaseTask)

File diff suppressed because it is too large Load Diff

View File

@@ -29,6 +29,7 @@ export type AppSettingsConfigType = {
};
application: {
enable_snapshot: boolean;
enable_cast: boolean;
};
};

View File

@@ -92,8 +92,7 @@ const EmbeddableVideoPlayer = ({ videoId }: EmbeddableVideoPlayerProps) => {
const likes = formatNumbers(video.stats.like_count);
const hasDislikes = video.stats.dislike_count > 0 && appSettingsConfig.downloads.integrate_ryd;
const dislikes = formatNumbers(video.stats.dislike_count);
// const config = videoResponse.config;
const cast = false; // config.enable_cast;
const cast = appSettingsConfig.application.enable_cast;
return (
<>

View File

@@ -92,6 +92,7 @@ const SettingsApplication = () => {
const [showApiToken, setShowApiToken] = useState(false);
const [downloadDislikes, setDownloadDislikes] = useState(false);
const [enableSponsorBlock, setEnableSponsorBlock] = useState(false);
const [enableCast, setEnableCast] = useState(false);
// Snapshots
const [enableSnapshots, setEnableSnapshots] = useState(false);
@@ -135,6 +136,7 @@ const SettingsApplication = () => {
// Integrations
setDownloadDislikes(appSettingsConfig.downloads.integrate_ryd);
setEnableSponsorBlock(appSettingsConfig.downloads.integrate_sponsorblock);
setEnableCast(appSettingsConfig.application.enable_cast);
// Snapshots
setEnableSnapshots(appSettingsConfig.application.enable_snapshot);
@@ -867,6 +869,16 @@ const SettingsApplication = () => {
updateCallback={handleUpdateConfig}
/>
</div>
<div className="settings-box-wrapper">
<div>
<p>Enable Cast</p>
</div>
<ToggleConfig
name="application.enable_cast"
value={enableCast}
updateCallback={handleUpdateConfig}
/>
</div>
</div>
<div className="info-box-item">
<h2>Snapshots</h2>

View File

@@ -39,7 +39,7 @@ import loadVideoNav, { VideoNavResponseType } from '../api/loader/loadVideoNav';
import useIsAdmin from '../functions/useIsAdmin';
import ToggleConfig from '../components/ToggleConfig';
import { PlaylistType } from '../api/loader/loadPlaylistById';
// import { useAppSettingsStore } from '../stores/AppSettingsStore';
import { useAppSettingsStore } from '../stores/AppSettingsStore';
const isInPlaylist = (videoId: string, playlist: PlaylistType) => {
return playlist.playlist_entries.some(entry => {
@@ -110,7 +110,7 @@ const Video = () => {
const { videoId } = useParams() as VideoParams;
const navigate = useNavigate();
const isAdmin = useIsAdmin();
// const { appSettingsConfig } = useAppSettingsStore();
const { appSettingsConfig } = useAppSettingsStore();
const [videoEnded, setVideoEnded] = useState(false);
const [playlistAutoplay, setPlaylistAutoplay] = useState(
@@ -193,7 +193,6 @@ const Video = () => {
const video = videoResponse;
const watched = videoResponse.player.watched;
// const config = appSettingsConfig;
const playlistNav = videoPlaylistNav;
const sponsorBlock = videoResponse.sponsorblock;
const customPlaylists = customPlaylistsResponse?.data;
@@ -202,7 +201,7 @@ const Video = () => {
console.log('playlistNav', playlistNav);
const cast = false; // config.enable_cast;
const cast = appSettingsConfig.application.enable_cast;
return (
<>

View File

@@ -36,6 +36,7 @@ export const useAppSettingsStore = create<AppSettingsState>(set => ({
},
application: {
enable_snapshot: false,
enable_cast: false,
},
},
setAppSettingsConfig: appSettingsConfig => set({ appSettingsConfig }),