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 \
libjpeg-turbo \
giflib \
librsvg && \
librsvg \
ca-certificates && \
ln -sf python3 /usr/bin/python
# Install cloudflared (Binary download)
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
# Install yt-dlp, bgutil-ytdlp-pot-provider, and yt-dlp-ejs for YouTube n challenge solving

View File

@@ -215,8 +215,8 @@ const startServer = async () => {
// SPA Fallback for Frontend
app.get("*", (req, res) => {
// Don't serve index.html for API calls that 404
if (req.path.startsWith('/api') || req.path.startsWith('/cloud')) {
res.status(404).send('Not Found');
if (req.path.startsWith("/api") || req.path.startsWith("/cloud")) {
res.status(404).send("Not Found");
return;
}
res.sendFile(path.join(frontendDist, "index.html"));
@@ -250,7 +250,7 @@ const startServer = async () => {
cloudflaredService.start(settings.cloudflaredToken);
} else {
// Quick Tunnel
const port = typeof PORT === 'string' ? parseInt(PORT) : PORT;
const port = typeof PORT === "string" ? parseInt(PORT) : PORT;
cloudflaredService.start(undefined, port);
}
}

View File

@@ -613,7 +613,13 @@ const VideoPlayer: React.FC = () => {
};
// 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 (
<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 }}>
<VideoControls
src={videoUrl || video?.sourceUrl}
poster={posterUrl || video?.thumbnailUrl}
poster={posterUrl || localPosterUrl || video?.thumbnailUrl}
autoPlay={autoPlay}
autoLoop={autoLoop}
onTimeUpdate={handleTimeUpdate}