diff --git a/Dockerfile b/Dockerfile index 05e2bf1..bb3cf29 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.23.3-alpine3.20 AS builder +FROM golang:1.23.4-alpine3.21 AS builder RUN apk add --no-cache curl @@ -13,7 +13,7 @@ RUN go mod download RUN go build -x -o media-roller ./src # yt-dlp needs python -FROM python:3.13.0-alpine3.20 +FROM python:3.13.1-alpine3.21 # This is where the downloaded files will be saved in the container. ENV MR_DOWNLOAD_DIR="/download" @@ -31,8 +31,8 @@ COPY static /app/static WORKDIR /app # 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.11.04/yt-dlp -o /usr/local/bin/yt-dlp && \ - echo "dad4a9ce9db902cf1e69ca71c0ca778917fa5a804a2ab43bac612b0abef76314 /usr/local/bin/yt-dlp" | sha256sum -c - && \ +RUN curl -L https://github.com/yt-dlp/yt-dlp/releases/download/2024.12.13/yt-dlp -o /usr/local/bin/yt-dlp && \ + echo "ec5f59f8b8908d93b2bdf6663c3ecba70781f39de21255d183220f250ebccc94 /usr/local/bin/yt-dlp" | sha256sum -c - && \ chmod a+rx /usr/local/bin/yt-dlp RUN yt-dlp --update --update-to nightly diff --git a/src/extractors/streamff.go b/src/extractors/streamff.go new file mode 100644 index 0000000..e21dbd3 --- /dev/null +++ b/src/extractors/streamff.go @@ -0,0 +1,15 @@ +package extractors + +import ( + "regexp" +) + +// https://streamff.com/v/e70b90d8 +var streamffRe = regexp.MustCompile(`^(?:https?://)?(?:www)?\.?streamff\.com/v/([A-Za-z0-9]+)/?`) + +func GetUrl(url string) string { + if matches := streamffRe.FindStringSubmatch(url); len(matches) == 2 { + return "https://ffedge.streamff.com/uploads/" + matches[1] + ".mp4" + } + return "" +} diff --git a/src/extractors/streamff_test.go b/src/extractors/streamff_test.go new file mode 100644 index 0000000..68f1394 --- /dev/null +++ b/src/extractors/streamff_test.go @@ -0,0 +1,26 @@ +package extractors + +import "testing" + +func TestGetUrl(t *testing.T) { + tests := []struct { + name string + url string + want string + }{ + {name: "t1", url: "https://streamff.com/v/e70b90d8", want: "https://ffedge.streamff.com/uploads/e70b90d8.mp4"}, + {name: "t2", url: "https://streamff.com/v/e70b90d8/", want: "https://ffedge.streamff.com/uploads/e70b90d8.mp4"}, + {name: "t3", url: "https://streamff.com/v/e70b90d8/test", want: "https://ffedge.streamff.com/uploads/e70b90d8.mp4"}, + {name: "t4", url: "https://streamff.com/v/e70b90d8?test", want: "https://ffedge.streamff.com/uploads/e70b90d8.mp4"}, + {name: "t5", url: "https://www.streamff.com/v/e70b90d8", want: "https://ffedge.streamff.com/uploads/e70b90d8.mp4"}, + {name: "t6", url: "streamff.com/v/e70b90d8?test", want: "https://ffedge.streamff.com/uploads/e70b90d8.mp4"}, + {name: "t7", url: "www.streamff.com/v/e70b90d8?test", want: "https://ffedge.streamff.com/uploads/e70b90d8.mp4"}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := GetUrl(tt.url); got != tt.want { + t.Errorf("GetUrl() = %v, want %v", got, tt.want) + } + }) + } +}