feat: add shared size limit constants

This commit is contained in:
2026-05-18 15:08:26 +02:00
parent 56c8618f5f
commit 943285b356
6 changed files with 23 additions and 8 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"io"
"mal/pkg/net/limits"
"net/http"
"regexp"
"strconv"
@@ -53,7 +54,7 @@ func (e *providerExtractor) ExtractVideoLinks(ctx context.Context, providerPath
defer func() { _ = resp.Body.Close() }()
body, err := io.ReadAll(io.LimitReader(resp.Body, 2*1024*1024)) // 2MB limit
body, err := io.ReadAll(io.LimitReader(resp.Body, limits.MiB2)) // 2MB limit
if err != nil {
return nil, fmt.Errorf("read provider response: %w", err)
}
@@ -157,7 +158,7 @@ func (e *providerExtractor) parseM3U8(ctx context.Context, masterURL string, ref
}
defer func() { _ = resp.Body.Close() }()
body, err := io.ReadAll(io.LimitReader(resp.Body, 512*1024)) // 512KB limit
body, err := io.ReadAll(io.LimitReader(resp.Body, limits.KiB512)) // 512KB limit
if err != nil {
return nil, err
}