Compare commits

...

2 commits

Author SHA1 Message Date
a6a33526a4
ci: enable docker build cache
All checks were successful
CI / build (push) Successful in 1m28s
2025-04-24 18:44:55 -04:00
dcb87b225a
fix: Fix content-range header in video proxy for partial requests
from: https://github.com/iv-org/invidious-companion/pull/101
2025-04-24 18:42:10 -04:00
2 changed files with 10 additions and 14 deletions

View file

@ -32,17 +32,6 @@ jobs:
type=sha,format=short,prefix={{date 'YYYY.MM.DD'}}-,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} type=sha,format=short,prefix={{date 'YYYY.MM.DD'}}-,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
- name: Go Build Cache for Docker
uses: actions/cache@v4
with:
path: go-build-cache
key: ${{ runner.os }}-go-build-cache-${{ hashFiles('**/go.sum') }}
- name: Inject go-build-cache
uses: https://github.com/reproducible-containers/buildkit-cache-dance@v3
with:
cache-source: go-build-cache
- name: Build and push Docker - name: Build and push Docker
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
@ -50,3 +39,5 @@ jobs:
platforms: linux/amd64 platforms: linux/amd64
push: true push: true
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max

View file

@ -184,7 +184,14 @@ func Videoplayback(w http.ResponseWriter, req *http.Request) {
byteParts := strings.Split(requestBytes, "-") byteParts := strings.Split(requestBytes, "-")
firstByte, lastByte := byteParts[0], byteParts[1] firstByte, lastByte := byteParts[0], byteParts[1]
if lastByte != "" { if lastByte != "" {
w.Header().Add("content-range", "bytes "+requestBytes+"/*") clen := q.Get("clen")
if clen == "" {
w.Header().Add("content-range", "bytes "+requestBytes+"/*")
} else {
w.Header().Add("content-range", "bytes "+requestBytes+"/"+clen)
}
w.WriteHeader(206) w.WriteHeader(206)
} else { } else {
// i.e. "bytes=0-", "bytes=600-" // i.e. "bytes=0-", "bytes=600-"
@ -205,8 +212,6 @@ func Videoplayback(w http.ResponseWriter, req *http.Request) {
} }
} }
// w.WriteHeader(resp.StatusCode)
if req.Method == "GET" && (resp.Header.Get("Content-Type") == "application/x-mpegurl" || resp.Header.Get("Content-Type") == "application/vnd.apple.mpegurl") { if req.Method == "GET" && (resp.Header.Get("Content-Type") == "application/x-mpegurl" || resp.Header.Get("Content-Type") == "application/vnd.apple.mpegurl") {
bytes, err := io.ReadAll(resp.Body) bytes, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {