From 7db9ef2af515e45dd2cd2f6b9d955246bf269161 Mon Sep 17 00:00:00 2001 From: immisterio <96652250+immisterio@users.noreply.github.com> Date: Sun, 18 Dec 2022 11:38:45 +0200 Subject: [PATCH] Update DLNA.cs --- Controllers/PLUGINS/DLNA.cs | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/Controllers/PLUGINS/DLNA.cs b/Controllers/PLUGINS/DLNA.cs index b5cb5dab..7c91911a 100644 --- a/Controllers/PLUGINS/DLNA.cs +++ b/Controllers/PLUGINS/DLNA.cs @@ -431,6 +431,21 @@ async public Task Download(string path, int[] indexs, string thumb) await manager.StartAsync(); await manager.WaitForMetadataAsync(); } + + #region overideindexs + if (indexs != null && indexs.Length > 0) + { + var overideindexs = new List(); + + for (int i = 0; i < manager.Files.Count; i++) + { + if (indexs.Contains(i) || manager.Files[i].Priority != Priority.DoNotDownload) + overideindexs.Add(i); + } + + indexs = overideindexs.ToArray(); + } + #endregion } else { @@ -451,6 +466,21 @@ async public Task Download(string path, int[] indexs, string thumb) await manager.StartAsync(); await manager.WaitForMetadataAsync(); + #region overideindexs + if (indexs != null && indexs.Length > 0) + { + var overideindexs = new List(); + + for (int i = 0; i < manager.Files.Count; i++) + { + if (indexs.Contains(i) || IO.File.Exists(manager.Files[i].FullPath)) + overideindexs.Add(i); + } + + indexs = overideindexs.ToArray(); + } + #endregion + #region TorrentStateChanged manager.TorrentStateChanged += async (s, e) => { @@ -487,6 +517,15 @@ async public Task Download(string path, int[] indexs, string thumb) if (indexs == null || indexs.Length == 0) { await manager.SetFilePriorityAsync(manager.Files[0], Priority.High); + + if (manager.Files.Count > 1) + { + foreach (var file in manager.Files.Skip(1)) + { + if (file.Priority != Priority.Normal) + await manager.SetFilePriorityAsync(file, Priority.Normal); + } + } } else {