Skip to content

Commit

Permalink
Use a specific version of yt-dlp and verify the sha246
Browse files Browse the repository at this point in the history
  • Loading branch information
rroller committed Oct 19, 2024
1 parent 3afc39f commit 9a61a4e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
14 changes: 9 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,24 @@ FROM python:3.13.0-alpine3.20
ENV MR_DOWNLOAD_DIR="/download"

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=builder /app/media-roller /app/media-roller
COPY templates /app/templates
COPY static /app/static

WORKDIR /app

RUN curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp && \
chmod a+rx /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

# Sanity check
RUN yt-dlp --version && \
ffmpeg -version

CMD /app/media-roller
CMD /app/media-roller
5 changes: 3 additions & 2 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"errors"
"github.com/go-chi/chi/v5"
"github.com/rs/zerolog/log"
"media-roller/src/media"
Expand Down Expand Up @@ -53,7 +54,7 @@ func main() {

go func() {
<-shutdownCtx.Done()
if shutdownCtx.Err() == context.DeadlineExceeded {
if errors.Is(shutdownCtx.Err(), context.DeadlineExceeded) {
log.Fatal().Msg("graceful shutdown timed out.. forcing exit.")
}
}()
Expand All @@ -68,7 +69,7 @@ func main() {

// Run the server
err := server.ListenAndServe()
if err != nil && err != http.ErrServerClosed {
if err != nil && !errors.Is(err, http.ErrServerClosed) {
log.Fatal().Err(err)
}

Expand Down
12 changes: 6 additions & 6 deletions src/media/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type Media struct {
HumanSize string
}

type MediaResults struct {
type Results struct {
Medias []Media
}

Expand Down Expand Up @@ -79,10 +79,10 @@ func FetchMediaApi(w http.ResponseWriter, r *http.Request) {
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")
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.
Expand All @@ -96,15 +96,15 @@ func getMediaResults(r *http.Request) (MediaResults, error) {
// We don't, so go fetch it
id, err = downloadMedia(url)
if err != nil {
return MediaResults{}, err
return Results{}, err
}
medias, err = getAllFilesForId(id)
if err != nil {
return MediaResults{}, err
return Results{}, err
}
}

return MediaResults{
return Results{
Medias: medias,
}, nil
}
Expand Down

0 comments on commit 9a61a4e

Please sign in to comment.