From b00795c464328ebd87be8f267c42b0cdc0f7b092 Mon Sep 17 00:00:00 2001 From: Felix Date: Sat, 2 May 2026 16:08:27 +0300 Subject: [PATCH] refactor(controller): restructure Ashdi stream handling logic Move the foreach loop inside the null/empty check for ashdiStreams to ensure proper iteration only when streams are available. This improves code readability and prevents potential issues with iterating over null or empty collections. --- LME.AnimeON/Controller.cs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/LME.AnimeON/Controller.cs b/LME.AnimeON/Controller.cs index 1da69be..a82ed23 100644 --- a/LME.AnimeON/Controller.cs +++ b/LME.AnimeON/Controller.cs @@ -247,19 +247,18 @@ namespace LME.AnimeON.Controllers if (streamLink.Contains("ashdi.vip/vod", StringComparison.OrdinalIgnoreCase)) { var ashdiStreams = await invoke.ParseAshdiPageStreams(streamLink); - if (ashdiStreams != null && ashdiStreams.Count > 0) - { - foreach (var ashdiStream in ashdiStreams) + if (ashdiStreams != null && ashdiStreams.Count > 0) { - string optionName = $"{translationName} {ashdiStream.Title}"; - string subtitlesParam = ashdiStream.Subtitles != null ? $"&subtitles={HttpUtility.UrlEncode(JsonSerializer.Serialize(ashdiStream.Subtitles.ToObject()))}" : string.Empty; - string callUrl = $"{host}/lite/lme_animeon/play?url={HttpUtility.UrlEncode(ashdiStream.Link)}{subtitlesParam}"; - movieTpl.Append(optionName, accsArgs(callUrl), "call"); + foreach (var ashdiStream in ashdiStreams) + { + string optionName = $"{translationName} {ashdiStream.Title}"; + string subtitlesParam = ashdiStream.Subtitles != null ? $"&subtitles={HttpUtility.UrlEncode(JsonSerializer.Serialize(ashdiStream.Subtitles.ToObject()))}" : string.Empty; + string callUrl = $"{host}/lite/lme_animeon/play?url={HttpUtility.UrlEncode(ashdiStream.Link)}{subtitlesParam}"; + tpl.Append(optionName, accsArgs(callUrl), "call"); + } } - } - continue; - } + continue; } if (needsResolve || streamLink.Contains("moonanime.art/iframe/") || streamLink.Contains("ashdi.vip/vod"))