style: Improve code formatting and add error retries
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -7,10 +7,10 @@ import cors from "cors";
|
||||
import express from "express";
|
||||
import path from "path";
|
||||
import {
|
||||
CLOUD_THUMBNAIL_CACHE_DIR,
|
||||
IMAGES_DIR,
|
||||
SUBTITLES_DIR,
|
||||
VIDEOS_DIR,
|
||||
CLOUD_THUMBNAIL_CACHE_DIR,
|
||||
IMAGES_DIR,
|
||||
SUBTITLES_DIR,
|
||||
VIDEOS_DIR,
|
||||
} from "./config/paths";
|
||||
import { runMigrations } from "./db/migrate";
|
||||
import { visitorModeMiddleware } from "./middleware/visitorModeMiddleware";
|
||||
@@ -214,12 +214,12 @@ 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');
|
||||
return;
|
||||
}
|
||||
res.sendFile(path.join(frontendDist, "index.html"));
|
||||
// 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");
|
||||
return;
|
||||
}
|
||||
res.sendFile(path.join(frontendDist, "index.html"));
|
||||
});
|
||||
|
||||
app.listen(PORT, () => {
|
||||
@@ -247,11 +247,11 @@ const startServer = async () => {
|
||||
const settings = storageService.getSettings();
|
||||
if (settings.cloudflaredTunnelEnabled) {
|
||||
if (settings.cloudflaredToken) {
|
||||
cloudflaredService.start(settings.cloudflaredToken);
|
||||
cloudflaredService.start(settings.cloudflaredToken);
|
||||
} else {
|
||||
// Quick Tunnel
|
||||
const port = typeof PORT === 'string' ? parseInt(PORT) : PORT;
|
||||
cloudflaredService.start(undefined, port);
|
||||
// Quick Tunnel
|
||||
const port = typeof PORT === "string" ? parseInt(PORT) : PORT;
|
||||
cloudflaredService.start(undefined, port);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user