diff --git a/TwitchDownloaderCLI/Modes/DownloadVideo.cs b/TwitchDownloaderCLI/Modes/DownloadVideo.cs index df291fad..ad367404 100644 --- a/TwitchDownloaderCLI/Modes/DownloadVideo.cs +++ b/TwitchDownloaderCLI/Modes/DownloadVideo.cs @@ -7,6 +7,7 @@ using TwitchDownloaderCore; using TwitchDownloaderCore.Interfaces; using TwitchDownloaderCore.Options; +using TwitchDownloaderCore.Services; using TwitchDownloaderCore.Tools; namespace TwitchDownloaderCLI.Modes diff --git a/TwitchDownloaderCLI/Modes/InfoHandler.cs b/TwitchDownloaderCLI/Modes/InfoHandler.cs index 7d4ed846..fe373964 100644 --- a/TwitchDownloaderCLI/Modes/InfoHandler.cs +++ b/TwitchDownloaderCLI/Modes/InfoHandler.cs @@ -113,7 +113,6 @@ private static void HandleVodTable(GqlVideoResponse videoInfo, GqlVideoChapterRe const string DEFAULT_STRING = "-"; var infoVideo = videoInfo.data.video; - var hasBitrate = m3u8.Streams.Any(x => x.StreamInfo.Bandwidth != default); var infoTableTitle = new TableTitle("Video Info"); var infoTable = new Table() @@ -138,6 +137,7 @@ private static void HandleVodTable(GqlVideoResponse videoInfo, GqlVideoChapterRe .AddColumn(new TableColumn("FPS").RightAligned()) .AddColumn(new TableColumn("Codecs").RightAligned()); + var hasBitrate = m3u8.Streams.Any(x => x.StreamInfo.Bandwidth != default); if (hasBitrate) { streamTable @@ -154,7 +154,7 @@ private static void HandleVodTable(GqlVideoResponse videoInfo, GqlVideoChapterRe if (hasBitrate) { - var videoLength = TimeSpan.FromSeconds(videoInfo.data.video.lengthSeconds); + var videoLength = TimeSpan.FromSeconds(infoVideo.lengthSeconds); var bitrate = stream.StreamInfo.Bandwidth.StringifyOrDefault(x => $"{x / 1000}kbps", DEFAULT_STRING); var fileSize = stream.StreamInfo.Bandwidth.StringifyOrDefault(x => $"~{VideoSizeEstimator.StringifyByteCount(VideoSizeEstimator.EstimateVideoSize(x, TimeSpan.Zero, videoLength))}", DEFAULT_STRING); streamTable.AddRow(name, resolution, fps, codecs, bitrate, fileSize); diff --git a/TwitchDownloaderCLI/Tools/FileCollisionHandler.cs b/TwitchDownloaderCLI/Tools/FileCollisionHandler.cs index 0d6ab36a..e73e6e60 100644 --- a/TwitchDownloaderCLI/Tools/FileCollisionHandler.cs +++ b/TwitchDownloaderCLI/Tools/FileCollisionHandler.cs @@ -3,7 +3,7 @@ using TwitchDownloaderCLI.Models; using TwitchDownloaderCLI.Modes.Arguments; using TwitchDownloaderCore.Interfaces; -using TwitchDownloaderCore.Tools; +using TwitchDownloaderCore.Services; namespace TwitchDownloaderCLI.Tools { diff --git a/TwitchDownloaderCore.Tests/ToolTests/FilenameServiceTests.cs b/TwitchDownloaderCore.Tests/ServiceTests/FilenameServiceTests.cs similarity index 99% rename from TwitchDownloaderCore.Tests/ToolTests/FilenameServiceTests.cs rename to TwitchDownloaderCore.Tests/ServiceTests/FilenameServiceTests.cs index 8765975b..7a346abf 100644 --- a/TwitchDownloaderCore.Tests/ToolTests/FilenameServiceTests.cs +++ b/TwitchDownloaderCore.Tests/ServiceTests/FilenameServiceTests.cs @@ -1,6 +1,6 @@ -using TwitchDownloaderCore.Tools; +using TwitchDownloaderCore.Services; -namespace TwitchDownloaderCore.Tests.ToolTests +namespace TwitchDownloaderCore.Tests.ServiceTests { public class FilenameServiceTests { diff --git a/TwitchDownloaderCore/Tools/FilenameService.cs b/TwitchDownloaderCore/Services/FilenameService.cs similarity index 99% rename from TwitchDownloaderCore/Tools/FilenameService.cs rename to TwitchDownloaderCore/Services/FilenameService.cs index 4ba70011..477c3e75 100644 --- a/TwitchDownloaderCore/Tools/FilenameService.cs +++ b/TwitchDownloaderCore/Services/FilenameService.cs @@ -5,8 +5,9 @@ using System.Text; using System.Text.RegularExpressions; using TwitchDownloaderCore.Extensions; +using TwitchDownloaderCore.Tools; -namespace TwitchDownloaderCore.Tools +namespace TwitchDownloaderCore.Services { public static class FilenameService { diff --git a/TwitchDownloaderCore/TwitchDownloaderCore.csproj b/TwitchDownloaderCore/TwitchDownloaderCore.csproj index 776c3337..f777aeae 100644 --- a/TwitchDownloaderCore/TwitchDownloaderCore.csproj +++ b/TwitchDownloaderCore/TwitchDownloaderCore.csproj @@ -23,13 +23,13 @@ - - + + - - - - + + + + diff --git a/TwitchDownloaderCore/TwitchHelper.cs b/TwitchDownloaderCore/TwitchHelper.cs index 2ecc18bf..36c02415 100644 --- a/TwitchDownloaderCore/TwitchHelper.cs +++ b/TwitchDownloaderCore/TwitchHelper.cs @@ -355,7 +355,7 @@ private static async Task> GetStvEmotesMetadata(int stre public static async Task> GetThirdPartyEmotes(List comments, int streamerId, string cacheFolder, ITaskLogger logger, EmbeddedData embeddedData = null, bool bttv = true, bool ffz = true, bool stv = true, bool allowUnlistedEmotes = true, bool offline = false, CancellationToken cancellationToken = default) { List returnList = new List(); - List alreadyAdded = new List(); + HashSet alreadyAdded = new HashSet(); // No 3rd party emotes are wanted if (!bttv && !ffz && !stv) @@ -459,7 +459,7 @@ public static async Task> GetThirdPartyEmotes(List co return returnList; static async Task FetchEmoteImages(IReadOnlyCollection comments, IEnumerable emoteResponse, ICollection returnList, - ICollection alreadyAdded, DirectoryInfo cacheFolder, ITaskLogger logger, CancellationToken cancellationToken) + ISet alreadyAdded, DirectoryInfo cacheFolder, ITaskLogger logger, CancellationToken cancellationToken) { if (!cacheFolder.Exists) cacheFolder = CreateDirectory(cacheFolder.FullName); @@ -500,8 +500,8 @@ where comments.Any(comment => Regex.IsMatch(comment.message.body, pattern)) public static async Task> GetEmotes(List comments, string cacheFolder, ITaskLogger logger, EmbeddedData embeddedData = null, bool offline = false, CancellationToken cancellationToken = default) { List returnList = new List(); - List alreadyAdded = new List(); - List failedEmotes = new List(); + HashSet alreadyAdded = new HashSet(); + HashSet failedEmotes = new HashSet(); DirectoryInfo emoteFolder = new DirectoryInfo(Path.Combine(cacheFolder, "emotes")); if (!emoteFolder.Exists) @@ -633,7 +633,7 @@ public static async Task> GetEmotes(List comments, st public static async Task> GetChatBadges(List comments, int streamerId, string cacheFolder, ITaskLogger logger, EmbeddedData embeddedData = null, bool offline = false, CancellationToken cancellationToken = default) { List returnList = new List(); - List alreadyAdded = new List(); + HashSet alreadyAdded = new HashSet(); // Load our embedded data from file if (embeddedData?.twitchBadges != null) @@ -781,7 +781,7 @@ public static async Task> GetEmojis(string cacheFol public static async Task> GetBits(List comments, string cacheFolder, string channelId, ITaskLogger logger, EmbeddedData embeddedData = null, bool offline = false, CancellationToken cancellationToken = default) { List returnList = new List(); - List alreadyAdded = new List(); + HashSet alreadyAdded = new HashSet(); // Load our embedded data from file if (embeddedData?.twitchBits != null) diff --git a/TwitchDownloaderCore/TwitchObjects/ChatRootInfo.cs b/TwitchDownloaderCore/TwitchObjects/ChatRootInfo.cs index 6eb27389..1cd81bd0 100644 --- a/TwitchDownloaderCore/TwitchObjects/ChatRootInfo.cs +++ b/TwitchDownloaderCore/TwitchObjects/ChatRootInfo.cs @@ -41,7 +41,7 @@ public override string ToString() => $"{Major}.{Minor}.{Patch}"; public override int GetHashCode() - => ToString().GetHashCode(); + => HashCode.Combine(Major, Minor, Patch); public static bool operator >(ChatRootVersion left, ChatRootVersion right) { diff --git a/TwitchDownloaderWPF/PageChatDownload.xaml.cs b/TwitchDownloaderWPF/PageChatDownload.xaml.cs index a3333536..80592ee8 100644 --- a/TwitchDownloaderWPF/PageChatDownload.xaml.cs +++ b/TwitchDownloaderWPF/PageChatDownload.xaml.cs @@ -11,6 +11,7 @@ using System.Windows.Media.Imaging; using TwitchDownloaderCore; using TwitchDownloaderCore.Options; +using TwitchDownloaderCore.Services; using TwitchDownloaderCore.Tools; using TwitchDownloaderCore.TwitchObjects.Gql; using TwitchDownloaderWPF.Models; diff --git a/TwitchDownloaderWPF/PageChatUpdate.xaml.cs b/TwitchDownloaderWPF/PageChatUpdate.xaml.cs index dc682d61..09edf21c 100644 --- a/TwitchDownloaderWPF/PageChatUpdate.xaml.cs +++ b/TwitchDownloaderWPF/PageChatUpdate.xaml.cs @@ -12,6 +12,7 @@ using TwitchDownloaderCore; using TwitchDownloaderCore.Chat; using TwitchDownloaderCore.Options; +using TwitchDownloaderCore.Services; using TwitchDownloaderCore.Tools; using TwitchDownloaderCore.TwitchObjects; using TwitchDownloaderCore.TwitchObjects.Gql; diff --git a/TwitchDownloaderWPF/PageClipDownload.xaml.cs b/TwitchDownloaderWPF/PageClipDownload.xaml.cs index 3a98693b..a34ca344 100644 --- a/TwitchDownloaderWPF/PageClipDownload.xaml.cs +++ b/TwitchDownloaderWPF/PageClipDownload.xaml.cs @@ -10,6 +10,7 @@ using System.Windows.Media.Imaging; using TwitchDownloaderCore; using TwitchDownloaderCore.Options; +using TwitchDownloaderCore.Services; using TwitchDownloaderCore.Tools; using TwitchDownloaderCore.TwitchObjects.Gql; using TwitchDownloaderWPF.Models; diff --git a/TwitchDownloaderWPF/PageVodDownload.xaml.cs b/TwitchDownloaderWPF/PageVodDownload.xaml.cs index 713d7cc6..7d98e169 100644 --- a/TwitchDownloaderWPF/PageVodDownload.xaml.cs +++ b/TwitchDownloaderWPF/PageVodDownload.xaml.cs @@ -16,6 +16,7 @@ using TwitchDownloaderCore; using TwitchDownloaderCore.Extensions; using TwitchDownloaderCore.Options; +using TwitchDownloaderCore.Services; using TwitchDownloaderCore.Tools; using TwitchDownloaderCore.TwitchObjects.Gql; using TwitchDownloaderWPF.Models; diff --git a/TwitchDownloaderWPF/Services/FileCollisionService.cs b/TwitchDownloaderWPF/Services/FileCollisionService.cs index 520d9e26..528e8640 100644 --- a/TwitchDownloaderWPF/Services/FileCollisionService.cs +++ b/TwitchDownloaderWPF/Services/FileCollisionService.cs @@ -3,7 +3,7 @@ using System.IO; using System.Windows; using Ookii.Dialogs.Wpf; -using TwitchDownloaderCore.Tools; +using TwitchDownloaderCore.Services; using TwitchDownloaderWPF.Models; using TwitchDownloaderWPF.Properties; diff --git a/TwitchDownloaderWPF/WindowQueueOptions.xaml.cs b/TwitchDownloaderWPF/WindowQueueOptions.xaml.cs index 51724eae..ef116239 100644 --- a/TwitchDownloaderWPF/WindowQueueOptions.xaml.cs +++ b/TwitchDownloaderWPF/WindowQueueOptions.xaml.cs @@ -7,6 +7,7 @@ using System.Windows.Media; using TwitchDownloaderCore; using TwitchDownloaderCore.Options; +using TwitchDownloaderCore.Services; using TwitchDownloaderCore.Tools; using TwitchDownloaderWPF.Properties; using TwitchDownloaderWPF.Services;