style: Improve code formatting and add error retries

This commit is contained in:
Peifan Li
2025-12-28 00:13:21 -05:00
parent f8670680c4
commit d0c316a9bf
3 changed files with 26 additions and 19 deletions

View File

@@ -54,14 +54,15 @@ RUN apk add --no-cache \
pango \ pango \
libjpeg-turbo \ libjpeg-turbo \
giflib \ giflib \
librsvg && \ librsvg \
ca-certificates && \
ln -sf python3 /usr/bin/python ln -sf python3 /usr/bin/python
# Install cloudflared (Binary download) # Install cloudflared (Binary download)
ARG TARGETARCH ARG TARGETARCH
RUN curl -L --output /usr/local/bin/cloudflared https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-${TARGETARCH:-amd64} && \ RUN curl -L --retry 5 --retry-delay 2 --output /usr/local/bin/cloudflared https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-${TARGETARCH:-amd64} && \
chmod +x /usr/local/bin/cloudflared chmod +x /usr/local/bin/cloudflared
# Install yt-dlp, bgutil-ytdlp-pot-provider, and yt-dlp-ejs for YouTube n challenge solving # Install yt-dlp, bgutil-ytdlp-pot-provider, and yt-dlp-ejs for YouTube n challenge solving

View File

@@ -7,10 +7,10 @@ import cors from "cors";
import express from "express"; import express from "express";
import path from "path"; import path from "path";
import { import {
CLOUD_THUMBNAIL_CACHE_DIR, CLOUD_THUMBNAIL_CACHE_DIR,
IMAGES_DIR, IMAGES_DIR,
SUBTITLES_DIR, SUBTITLES_DIR,
VIDEOS_DIR, VIDEOS_DIR,
} from "./config/paths"; } from "./config/paths";
import { runMigrations } from "./db/migrate"; import { runMigrations } from "./db/migrate";
import { visitorModeMiddleware } from "./middleware/visitorModeMiddleware"; import { visitorModeMiddleware } from "./middleware/visitorModeMiddleware";
@@ -214,12 +214,12 @@ const startServer = async () => {
// SPA Fallback for Frontend // SPA Fallback for Frontend
app.get("*", (req, res) => { app.get("*", (req, res) => {
// Don't serve index.html for API calls that 404 // Don't serve index.html for API calls that 404
if (req.path.startsWith('/api') || req.path.startsWith('/cloud')) { if (req.path.startsWith("/api") || req.path.startsWith("/cloud")) {
res.status(404).send('Not Found'); res.status(404).send("Not Found");
return; return;
} }
res.sendFile(path.join(frontendDist, "index.html")); res.sendFile(path.join(frontendDist, "index.html"));
}); });
app.listen(PORT, () => { app.listen(PORT, () => {
@@ -247,11 +247,11 @@ const startServer = async () => {
const settings = storageService.getSettings(); const settings = storageService.getSettings();
if (settings.cloudflaredTunnelEnabled) { if (settings.cloudflaredTunnelEnabled) {
if (settings.cloudflaredToken) { if (settings.cloudflaredToken) {
cloudflaredService.start(settings.cloudflaredToken); cloudflaredService.start(settings.cloudflaredToken);
} else { } else {
// Quick Tunnel // Quick Tunnel
const port = typeof PORT === 'string' ? parseInt(PORT) : PORT; const port = typeof PORT === "string" ? parseInt(PORT) : PORT;
cloudflaredService.start(undefined, port); cloudflaredService.start(undefined, port);
} }
} }
}); });

View File

@@ -613,7 +613,13 @@ const VideoPlayer: React.FC = () => {
}; };
// Get thumbnail URL for poster // Get thumbnail URL for poster
const posterUrl = useCloudStorageUrl(video?.thumbnailPath, 'thumbnail'); // Only load thumbnail from cloud if the video itself is in cloud storage
const isVideoInCloud = video?.videoPath?.startsWith('cloud:') ?? false;
const thumbnailPathForCloud = isVideoInCloud ? video?.thumbnailPath : null;
const posterUrl = useCloudStorageUrl(thumbnailPathForCloud, 'thumbnail');
const localPosterUrl = !isVideoInCloud && video?.thumbnailPath
? `${import.meta.env.VITE_BACKEND_URL ?? 'http://localhost:5551'}${video.thumbnailPath}`
: undefined;
return ( return (
<Container maxWidth={false} disableGutters sx={{ py: { xs: 0, md: 4 }, px: { xs: 0, md: 2 } }}> <Container maxWidth={false} disableGutters sx={{ py: { xs: 0, md: 4 }, px: { xs: 0, md: 2 } }}>
@@ -622,7 +628,7 @@ const VideoPlayer: React.FC = () => {
<Grid size={{ xs: 12, lg: 8 }}> <Grid size={{ xs: 12, lg: 8 }}>
<VideoControls <VideoControls
src={videoUrl || video?.sourceUrl} src={videoUrl || video?.sourceUrl}
poster={posterUrl || video?.thumbnailUrl} poster={posterUrl || localPosterUrl || video?.thumbnailUrl}
autoPlay={autoPlay} autoPlay={autoPlay}
autoLoop={autoLoop} autoLoop={autoLoop}
onTimeUpdate={handleTimeUpdate} onTimeUpdate={handleTimeUpdate}