From 648eb568ff39855c94e2575da2b87e73966a1626 Mon Sep 17 00:00:00 2001 From: mkelvers Date: Tue, 23 Jun 2026 17:16:46 +0200 Subject: [PATCH] refactor: inline single-use helpers in allanime --- integrations/playback/allanime/crypto.go | 4 ---- integrations/playback/allanime/extractor.go | 21 +++++++-------------- integrations/playback/allanime/sources.go | 2 +- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/integrations/playback/allanime/crypto.go b/integrations/playback/allanime/crypto.go index c8416fa..dc9bfca 100644 --- a/integrations/playback/allanime/crypto.go +++ b/integrations/playback/allanime/crypto.go @@ -153,10 +153,6 @@ func responseFromTobeparsed(data map[string]any) (map[string]any, error) { }, nil } -func hasEpisodeSourceURLs(data map[string]any) bool { - return len(nestedSlice(data, "episode", "sourceUrls")) > 0 -} - func parseGraphQLResponse(respBody []byte, decodeErrPrefix string) (map[string]any, error) { var parsed map[string]any if err := json.Unmarshal(respBody, &parsed); err != nil { diff --git a/integrations/playback/allanime/extractor.go b/integrations/playback/allanime/extractor.go index 01b8e25..dae0d3e 100644 --- a/integrations/playback/allanime/extractor.go +++ b/integrations/playback/allanime/extractor.go @@ -302,12 +302,17 @@ func parseM3U8Sources(body string, masterURL string, referer string) []StreamSou currentBandwidth = bandwidth continue } - if shouldSkipM3U8Line(trimmed) { + if trimmed == "" || strings.HasPrefix(trimmed, "#") { continue } + streamURL := trimmed + if !strings.HasPrefix(streamURL, "http://") && !strings.HasPrefix(streamURL, "https://") { + streamURL = baseURL + streamURL + } + sources = append(sources, StreamSource{ - URL: resolvePlaylistURL(trimmed, baseURL), + URL: streamURL, Quality: qualityFromBandwidth(currentBandwidth), Provider: "hls", Type: "m3u8", @@ -344,18 +349,6 @@ func parseStreamBandwidth(line string, bwPattern *regexp.Regexp) (int, bool) { return value, true } -func shouldSkipM3U8Line(line string) bool { - return line == "" || strings.HasPrefix(line, "#") -} - -func resolvePlaylistURL(streamURL string, baseURL string) string { - if strings.HasPrefix(streamURL, "http://") || strings.HasPrefix(streamURL, "https://") { - return streamURL - } - - return baseURL + streamURL -} - func qualityFromBandwidth(bandwidth int) string { kbps := bandwidth / 1000 diff --git a/integrations/playback/allanime/sources.go b/integrations/playback/allanime/sources.go index 6341e91..f7e0a39 100644 --- a/integrations/playback/allanime/sources.go +++ b/integrations/playback/allanime/sources.go @@ -281,7 +281,7 @@ func (c *AllAnimeProvider) graphqlRequestWithHash(ctx context.Context, showID, e return decrypted, nil } - if hasEpisodeSourceURLs(data) { + if len(nestedSlice(data, "episode", "sourceUrls")) > 0 { return parsed, nil }