Use a specific version of yt-dlp and verify the sha246

This commit is contained in:
rroller 2024-10-19 16:19:55 -07:00
parent 3afc39fed3
commit 9a61a4e941
3 changed files with 18 additions and 13 deletions

View file

@ -21,14 +21,18 @@ ENV MR_DOWNLOAD_DIR="/download"
RUN apk add --update --no-cache \ RUN apk add --update --no-cache \
curl curl
COPY --from=builder /app/media-roller /app/media-roller # https://hub.docker.com/r/mwader/static-ffmpeg/tags
# https://github.com/wader/static-ffmpeg
COPY --from=mwader/static-ffmpeg:7.1 /ffmpeg /usr/local/bin/ COPY --from=mwader/static-ffmpeg:7.1 /ffmpeg /usr/local/bin/
COPY --from=builder /app/media-roller /app/media-roller
COPY templates /app/templates COPY templates /app/templates
COPY static /app/static COPY static /app/static
WORKDIR /app WORKDIR /app
RUN curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp && \ # Get new releases here https://github.com/yt-dlp/yt-dlp/releases
RUN curl -L https://github.com/yt-dlp/yt-dlp/releases/download/2024.10.07/yt-dlp -o /usr/local/bin/yt-dlp && \
echo "8d8151368376c4d2f6dd6993d893be09334c06b7e6fa1e7e07bc3c4fbef848b3 /usr/local/bin/yt-dlp" | sha256sum -c - && \
chmod a+rx /usr/local/bin/yt-dlp chmod a+rx /usr/local/bin/yt-dlp
# Sanity check # Sanity check

View file

@ -2,6 +2,7 @@ package main
import ( import (
"context" "context"
"errors"
"github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
"media-roller/src/media" "media-roller/src/media"
@ -53,7 +54,7 @@ func main() {
go func() { go func() {
<-shutdownCtx.Done() <-shutdownCtx.Done()
if shutdownCtx.Err() == context.DeadlineExceeded { if errors.Is(shutdownCtx.Err(), context.DeadlineExceeded) {
log.Fatal().Msg("graceful shutdown timed out.. forcing exit.") log.Fatal().Msg("graceful shutdown timed out.. forcing exit.")
} }
}() }()
@ -68,7 +69,7 @@ func main() {
// Run the server // Run the server
err := server.ListenAndServe() err := server.ListenAndServe()
if err != nil && err != http.ErrServerClosed { if err != nil && !errors.Is(err, http.ErrServerClosed) {
log.Fatal().Err(err) log.Fatal().Err(err)
} }

View file

@ -32,7 +32,7 @@ type Media struct {
HumanSize string HumanSize string
} }
type MediaResults struct { type Results struct {
Medias []Media Medias []Media
} }
@ -79,10 +79,10 @@ func FetchMediaApi(w http.ResponseWriter, r *http.Request) {
streamFileToClientById(w, r, response.Medias[0].Id) streamFileToClientById(w, r, response.Medias[0].Id)
} }
func getMediaResults(r *http.Request) (MediaResults, error) { func getMediaResults(r *http.Request) (Results, error) {
url := r.URL.Query().Get("url") url := r.URL.Query().Get("url")
if url == "" { if url == "" {
return MediaResults{}, errors.New("Missing URL") return Results{}, errors.New("Missing URL")
} }
// NOTE: This system is for a simple use case, meant to run at home. This is not a great design for a robust system. // NOTE: This system is for a simple use case, meant to run at home. This is not a great design for a robust system.
@ -96,15 +96,15 @@ func getMediaResults(r *http.Request) (MediaResults, error) {
// We don't, so go fetch it // We don't, so go fetch it
id, err = downloadMedia(url) id, err = downloadMedia(url)
if err != nil { if err != nil {
return MediaResults{}, err return Results{}, err
} }
medias, err = getAllFilesForId(id) medias, err = getAllFilesForId(id)
if err != nil { if err != nil {
return MediaResults{}, err return Results{}, err
} }
} }
return MediaResults{ return Results{
Medias: medias, Medias: medias,
}, nil }, nil
} }