Handle AllAnime extractor errors
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"html"
|
"html"
|
||||||
"io"
|
"io"
|
||||||
|
"mal/pkg/errlog"
|
||||||
netutil "mal/pkg/net"
|
netutil "mal/pkg/net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
@@ -71,7 +72,9 @@ func (e *providerExtractor) ExtractVideoLinks(ctx context.Context, providerPath
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() { _ = resp.Body.Close() }()
|
defer func() {
|
||||||
|
errlog.Log("failed to close provider response body", resp.Body.Close())
|
||||||
|
}()
|
||||||
|
|
||||||
body, err := io.ReadAll(io.LimitReader(resp.Body, netutil.MiB2)) // 2MB limit
|
body, err := io.ReadAll(io.LimitReader(resp.Body, netutil.MiB2)) // 2MB limit
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -86,7 +89,9 @@ func (e *providerExtractor) ExtractEmbedVideoLinks(ctx context.Context, rawURL s
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("fetch embed response: %w", err)
|
return nil, fmt.Errorf("fetch embed response: %w", err)
|
||||||
}
|
}
|
||||||
defer func() { _ = resp.Body.Close() }()
|
defer func() {
|
||||||
|
errlog.Log("failed to close embed response body", resp.Body.Close())
|
||||||
|
}()
|
||||||
|
|
||||||
body, err := io.ReadAll(io.LimitReader(resp.Body, netutil.MiB2))
|
body, err := io.ReadAll(io.LimitReader(resp.Body, netutil.MiB2))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -170,8 +175,14 @@ func parseProviderSubtitles(items []any) []Subtitle {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
lang, _ := node["lang"].(string)
|
lang, ok := node["lang"].(string)
|
||||||
src, _ := node["src"].(string)
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
src, ok := node["src"].(string)
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
lang = strings.TrimSpace(lang)
|
lang = strings.TrimSpace(lang)
|
||||||
src = strings.TrimSpace(src)
|
src = strings.TrimSpace(src)
|
||||||
if lang == "" || src == "" {
|
if lang == "" || src == "" {
|
||||||
@@ -266,7 +277,9 @@ func (e *providerExtractor) parseM3U8(ctx context.Context, masterURL string, ref
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer func() { _ = resp.Body.Close() }()
|
defer func() {
|
||||||
|
errlog.Log("failed to close m3u8 response body", resp.Body.Close())
|
||||||
|
}()
|
||||||
|
|
||||||
body, err := io.ReadAll(io.LimitReader(resp.Body, netutil.KiB512)) // 512KB limit
|
body, err := io.ReadAll(io.LimitReader(resp.Body, netutil.KiB512)) // 512KB limit
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user