From 75c31372626c277fa144b66fe1c315268bed58d4 Mon Sep 17 00:00:00 2001 From: Viktor Varland Date: Fri, 28 Mar 2025 15:37:50 +0100 Subject: [PATCH] ci: setup container build --- .forgejo/workflows/build.yaml | 15 ++++++++++++ Containerfile | 46 +++++++++++++++++++++++++++++++++++ README.md | 1 + internal/config/config.go | 1 + main.go | 6 ++--- 5 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 .forgejo/workflows/build.yaml create mode 100644 Containerfile diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml new file mode 100644 index 0000000..bcf991d --- /dev/null +++ b/.forgejo/workflows/build.yaml @@ -0,0 +1,15 @@ +name: build +run-name: ${{ gitea.actor }} is building subsyt +on: + push: + branches: + - 'master' + +jobs: + build: + runs-on: podman + steps: + - uses: actions/checkout@v3 + - run: podman login --username registry --password ${{ secrets.MEATBAG_REGISTRY_TOKEN }} registry.meatbag.se + - run: podman build -t varl/subsyt:latest . + - run: podman push varl/subsyt registry.meatbag.se/varl/subsyt diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..2ffc474 --- /dev/null +++ b/Containerfile @@ -0,0 +1,46 @@ +FROM golang:1.24-alpine as builder + +WORKDIR /src + +COPY go.* . +RUN go mod download + +COPY . . +RUN go build -o /src/build/subsyt . + +FROM archlinux:latest + +RUN pacman -Syu --noconfirm \ + yt-dlp \ + ffmpeg \ + rtmpdump \ + atomicparsley \ + aria2 \ + python-mutagen \ + python-pycryptodome \ + python-pycryptodomex \ + python-websockets \ + python-brotli \ + python-brotlicffi \ + python-xattr \ + python-pyxattr + +COPY <<-EOT /app/config.toml + dry_run = false + out_dir = "/data/vids" + + [provider] + [provider.youtube] + cmd = "yt-dlp" + url = "https://www.youtube.com" + throttle = 1 + range = "1:5:1" + after_date = "20250326" + cookies = "/data/cookies.txt" + opml_file = "/data/opml.xml" +EOT + +COPY --from=builder /src/build/subsyt /app/subsyt + +WORKDIR /app +ENTRYPOINT [ "/app/subsyt" ] diff --git a/README.md b/README.md index f28de7f..ab0a38d 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ throttle = 1 # throttle yt request range = "1:5:1" # [START][:STOP][:STEP] after_date = "20250326" # not in use cookies = "./cookies.txt" # pass user cookies to yt +opml_file = "./opml.xml" # the opml file to use ``` `subs-opml.xml`: diff --git a/internal/config/config.go b/internal/config/config.go index 772a088..bd348e9 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -14,6 +14,7 @@ type Provider struct { After_date string Cmd string Cookies string + Opml_file string } type Config struct { diff --git a/main.go b/main.go index 90d2304..324d80e 100644 --- a/main.go +++ b/main.go @@ -14,13 +14,13 @@ func main() { panic(err) } - opml, err := opml.Load("./subs-opml.xml") + provider := cfg.Provider["youtube"] + + opml, err := opml.Load(provider.Opml_file) if err != nil { panic(err) } - provider := cfg.Provider["youtube"] - for _, outlines := range opml.Body.Outline { log.Printf("Archiving videos from OPML: %s", outlines.Title)