diff --git a/TwitchDownloaderCore.Tests/ToolTests/M3U8Tests.cs b/TwitchDownloaderCore.Tests/ToolTests/M3U8Tests.cs index e9a14cde..2855a5d2 100644 --- a/TwitchDownloaderCore.Tests/ToolTests/M3U8Tests.cs +++ b/TwitchDownloaderCore.Tests/ToolTests/M3U8Tests.cs @@ -14,7 +14,7 @@ public class M3U8Tests [InlineData(true, "ru-RU")] public void CorrectlyParsesTwitchM3U8OfTransportStreams(bool useStream, string culture) { - const string ExampleM3U8Twitch = + const string EXAMPLE_M3U8_TWITCH = "#EXTM3U" + "\n#EXT-X-VERSION:3" + "\n#EXT-X-TARGETDURATION:10" + @@ -37,13 +37,13 @@ public void CorrectlyParsesTwitchM3U8OfTransportStreams(bool useStream, string c M3U8 m3u8; if (useStream) { - var bytes = Encoding.Unicode.GetBytes(ExampleM3U8Twitch); + var bytes = Encoding.Unicode.GetBytes(EXAMPLE_M3U8_TWITCH); using var ms = new MemoryStream(bytes); m3u8 = M3U8.Parse(ms, Encoding.Unicode); } else { - m3u8 = M3U8.Parse(ExampleM3U8Twitch); + m3u8 = M3U8.Parse(EXAMPLE_M3U8_TWITCH); } CultureInfo.CurrentCulture = oldCulture; @@ -73,7 +73,7 @@ public void CorrectlyParsesTwitchM3U8OfTransportStreams(bool useStream, string c [InlineData(true, "ru-RU")] public void CorrectlyParsesTwitchM3U8OfLiveStreams(bool useStream, string culture) { - const string ExampleM3U8Twitch = + const string EXAMPLE_M3U8_TWITCH = "#EXTM3U" + "\n#EXT-X-VERSION:3" + "\n#EXT-X-TARGETDURATION:5" + @@ -129,13 +129,13 @@ public void CorrectlyParsesTwitchM3U8OfLiveStreams(bool useStream, string cultur M3U8 m3u8; if (useStream) { - var bytes = Encoding.Unicode.GetBytes(ExampleM3U8Twitch); + var bytes = Encoding.Unicode.GetBytes(EXAMPLE_M3U8_TWITCH); using var ms = new MemoryStream(bytes); m3u8 = M3U8.Parse(ms, Encoding.Unicode); } else { - m3u8 = M3U8.Parse(ExampleM3U8Twitch); + m3u8 = M3U8.Parse(EXAMPLE_M3U8_TWITCH); } CultureInfo.CurrentCulture = oldCulture; @@ -167,7 +167,7 @@ public void CorrectlyParsesTwitchM3U8OfLiveStreams(bool useStream, string cultur [InlineData(true, "ru-RU")] public void CorrectlyParsesTwitchM3U8OfPlaylists(bool useStream, string culture) { - const string ExampleM3U8Twitch = + const string EXAMPLE_M3U8_TWITCH = "#EXTM3U" + "\n#EXT-X-TWITCH-INFO:ORIGIN=\"s3\",B=\"false\",REGION=\"NA\",USER-IP=\"255.255.255.255\",SERVING-ID=\"123abc456def789ghi012jkl345mno67\",CLUSTER=\"cloudfront_vod\",USER-COUNTRY=\"US\",MANIFEST-CLUSTER=\"cloudfront_vod\"" + "\n#EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID=\"chunked\",NAME=\"1080p60\",AUTOSELECT=NO,DEFAULT=NO" + @@ -217,13 +217,13 @@ public void CorrectlyParsesTwitchM3U8OfPlaylists(bool useStream, string culture) M3U8 m3u8; if (useStream) { - var bytes = Encoding.Unicode.GetBytes(ExampleM3U8Twitch); + var bytes = Encoding.Unicode.GetBytes(EXAMPLE_M3U8_TWITCH); using var ms = new MemoryStream(bytes); m3u8 = M3U8.Parse(ms, Encoding.Unicode); } else { - m3u8 = M3U8.Parse(ExampleM3U8Twitch); + m3u8 = M3U8.Parse(EXAMPLE_M3U8_TWITCH); } CultureInfo.CurrentCulture = oldCulture; @@ -280,7 +280,7 @@ public void CorrectlyParsesTwitchM3U8StreamInfo(string streamInfoString, int ban [InlineData(true, "ru-RU")] public void CorrectlyParsesKickM3U8OfTransportStreams(bool useStream, string culture) { - const string ExampleM3U8Kick = + const string EXAMPLE_M3U8_KICK = "#EXTM3U" + "\n#EXT-X-VERSION:4" + "\n#EXT-X-MEDIA-SEQUENCE:0" + @@ -343,13 +343,13 @@ public void CorrectlyParsesKickM3U8OfTransportStreams(bool useStream, string cul M3U8 m3u8; if (useStream) { - var bytes = Encoding.Unicode.GetBytes(ExampleM3U8Kick); + var bytes = Encoding.Unicode.GetBytes(EXAMPLE_M3U8_KICK); using var ms = new MemoryStream(bytes); m3u8 = M3U8.Parse(ms, Encoding.Unicode); } else { - m3u8 = M3U8.Parse(ExampleM3U8Kick); + m3u8 = M3U8.Parse(EXAMPLE_M3U8_KICK); } CultureInfo.CurrentCulture = oldCulture; @@ -378,7 +378,7 @@ public void CorrectlyParsesKickM3U8OfTransportStreams(bool useStream, string cul [InlineData(true, "ru-RU")] public void CorrectlyParsesKickM3U8OfPlaylists(bool useStream, string culture) { - const string ExampleM3U8Kick = + const string EXAMPLE_M3U8_KICK = "#EXTM3U" + "\n#EXT-X-SESSION-DATA:DATA-ID=\"net.live-video.content.id\",VALUE=\"AbC123dEf456\"" + "\n#EXT-X-SESSION-DATA:DATA-ID=\"net.live-video.customer.id\",VALUE=\"123456789012\"" + @@ -423,13 +423,13 @@ public void CorrectlyParsesKickM3U8OfPlaylists(bool useStream, string culture) M3U8 m3u8; if (useStream) { - var bytes = Encoding.Unicode.GetBytes(ExampleM3U8Kick); + var bytes = Encoding.Unicode.GetBytes(EXAMPLE_M3U8_KICK); using var ms = new MemoryStream(bytes); m3u8 = M3U8.Parse(ms, Encoding.Unicode); } else { - m3u8 = M3U8.Parse(ExampleM3U8Kick); + m3u8 = M3U8.Parse(EXAMPLE_M3U8_KICK); } CultureInfo.CurrentCulture = oldCulture; diff --git a/TwitchDownloaderCore/Extensions/M3U8Extensions.cs b/TwitchDownloaderCore/Extensions/M3U8Extensions.cs index 3ef590fb..b27526d5 100644 --- a/TwitchDownloaderCore/Extensions/M3U8Extensions.cs +++ b/TwitchDownloaderCore/Extensions/M3U8Extensions.cs @@ -28,7 +28,7 @@ public static M3U8.Stream GetStreamOfQuality(this M3U8 m3u8, string qualityStrin { if (m3u8.Streams.Length == 0) { - throw new ArgumentException(nameof(m3u8), "M3U8 does not contain any streams."); + throw new ArgumentException("M3U8 does not contain any streams.", nameof(m3u8)); } if (TryGetKeywordStream(m3u8, qualityString, out var keywordStream)) diff --git a/TwitchDownloaderCore/Tools/M3U8Parse.cs b/TwitchDownloaderCore/Tools/M3U8Parse.cs index dfa45e0a..1d5186f9 100644 --- a/TwitchDownloaderCore/Tools/M3U8Parse.cs +++ b/TwitchDownloaderCore/Tools/M3U8Parse.cs @@ -283,9 +283,9 @@ public static ExtByteRange Parse(ReadOnlySpan text) public partial record ExtMediaInfo { - public static Stream.ExtMediaInfo Parse(ReadOnlySpan text) + public static ExtMediaInfo Parse(ReadOnlySpan text) { - var mediaInfo = new Stream.ExtMediaInfo(); + var mediaInfo = new ExtMediaInfo(); if (text.StartsWith(MEDIA_INFO_KEY)) text = text[13..]; diff --git a/TwitchDownloaderCore/TsMerger.cs b/TwitchDownloaderCore/TsMerger.cs index c10030c2..59c86252 100644 --- a/TwitchDownloaderCore/TsMerger.cs +++ b/TwitchDownloaderCore/TsMerger.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; using System.Threading; using System.Threading.Tasks; @@ -135,7 +134,6 @@ private static async Task VerifyVideoPart(string filePath) private async Task CombineVideoParts(IReadOnlyCollection fileList, FileStream outputStream, CancellationToken cancellationToken) { DriveInfo outputDrive = DriveHelper.GetOutputDrive(mergeOptions.OutputFile); - string outputFile = mergeOptions.OutputFile; int partCount = fileList.Count; int doneCount = 0; diff --git a/TwitchDownloaderCore/TwitchHelper.cs b/TwitchDownloaderCore/TwitchHelper.cs index cd16d92d..5307dc77 100644 --- a/TwitchDownloaderCore/TwitchHelper.cs +++ b/TwitchDownloaderCore/TwitchHelper.cs @@ -105,7 +105,7 @@ public static async Task GetVideoPlaylist(long videoId, string token, st return await response.Content.ReadAsStringAsync(); } - static bool IsAuthException(Exception ex) + private static bool IsAuthException(Exception ex) { while (ex != null) { @@ -566,7 +566,7 @@ public static async Task> GetEmotes(List comments, st var nameList = comments.Where(comment => comment.message.user_badges != null) .SelectMany(comment => comment.message.user_badges) - .Where(badge => !String.IsNullOrWhiteSpace(badge._id)) + .Where(badge => !string.IsNullOrWhiteSpace(badge._id)) .Where(badge => globalBadges.ContainsKey(badge._id) || subBadges.ContainsKey(badge._id)) .Select(badge => badge._id).Distinct(); @@ -1011,15 +1011,6 @@ where DateTime.UtcNow.Ticks - directoryInfo.LastWriteTimeUtc.Ticks > TimeSpan.Ti : $"{wasDeleted} old video caches were deleted, {toDelete.Length - wasDeleted} could not be deleted."); } - public static int TimestampToSeconds(string input) - { - // Gets total seconds from timestamp in the format of 0h0m0s - input = input.Replace('h', ':').Replace('m', ':').Replace("s", ""); - TimeSpan returnSpan = TimeSpan.Parse(input); - - return (int)returnSpan.TotalSeconds; - } - public static async Task GetStreamerName(int id) { try @@ -1036,7 +1027,7 @@ public static async Task GetUserInfo(IEnumerable id { RequestUri = new Uri("https://gql.twitch.tv/gql"), Method = HttpMethod.Post, - Content = new StringContent("{\"query\":\"query{users(ids:[" + String.Join(",", idList.Select(x => "\\\"" + x + "\\\"").ToArray()) + "]){id,login,createdAt,updatedAt,description,profileImageURL(width:300)}}\",\"variables\":{}}", Encoding.UTF8, "application/json") + Content = new StringContent("{\"query\":\"query{users(ids:[" + string.Join(",", idList.Select(x => "\\\"" + x + "\\\"").ToArray()) + "]){id,login,createdAt,updatedAt,description,profileImageURL(width:300)}}\",\"variables\":{}}", Encoding.UTF8, "application/json") }; request.Headers.Add("Client-ID", "kimne78kx3ncx6brgo4mv6wki5h1ko"); using var response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead); @@ -1086,7 +1077,7 @@ public static async Task GetImage(DirectoryInfo cacheDir, string imageUr } catch (Exception e) when (e is IOException or SecurityException) { - // File being written to by parallel process? Maybe. Can just fallback to HTTP request. + // File being written to by parallel process? Maybe. Can just fall back to HTTP request. logger.LogVerbose($"Failed to read from or delete {file.Name}: {e.Message}"); } } diff --git a/TwitchDownloaderCore/TwitchObjects/Api/BTTVChannelEmoteResponse.cs b/TwitchDownloaderCore/TwitchObjects/Api/BTTVChannelEmoteResponse.cs index 2c91158f..75a0cb04 100644 --- a/TwitchDownloaderCore/TwitchObjects/Api/BTTVChannelEmoteResponse.cs +++ b/TwitchDownloaderCore/TwitchObjects/Api/BTTVChannelEmoteResponse.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; namespace TwitchDownloaderCore.TwitchObjects.Api { diff --git a/TwitchDownloaderCore/TwitchObjects/Api/STVChannelEmoteResponse.cs b/TwitchDownloaderCore/TwitchObjects/Api/STVChannelEmoteResponse.cs index 2ff6ad14..85b11300 100644 --- a/TwitchDownloaderCore/TwitchObjects/Api/STVChannelEmoteResponse.cs +++ b/TwitchDownloaderCore/TwitchObjects/Api/STVChannelEmoteResponse.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; namespace TwitchDownloaderCore.TwitchObjects.Api { diff --git a/TwitchDownloaderCore/TwitchObjects/Api/STVGlobalEmoteResponse.cs b/TwitchDownloaderCore/TwitchObjects/Api/STVGlobalEmoteResponse.cs index dbe6b7b7..f8af0f92 100644 --- a/TwitchDownloaderCore/TwitchObjects/Api/STVGlobalEmoteResponse.cs +++ b/TwitchDownloaderCore/TwitchObjects/Api/STVGlobalEmoteResponse.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; namespace TwitchDownloaderCore.TwitchObjects.Api { diff --git a/TwitchDownloaderCore/TwitchObjects/GifEmote.cs b/TwitchDownloaderCore/TwitchObjects/GifEmote.cs deleted file mode 100644 index 595e6110..00000000 --- a/TwitchDownloaderCore/TwitchObjects/GifEmote.cs +++ /dev/null @@ -1,66 +0,0 @@ -using SkiaSharp; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Text; - -namespace TwitchDownloaderCore.TwitchObjects -{ - public class GifEmote - { - public Point Offset { get; set; } - public string Name { get; set; } - public SKCodec Codec { get; set; } - public int FrameCount { get; set; } - public List DurationList { get; set; } - public int TotalDuration { get; set; } - public int ImageScale { get; set; } - public int Width { get; set; } - public int Height { get; set; } - public List ImageFrames { get; set; } - public SKBitmap BackgroundImage { get; set; } - - public GifEmote(Point offset, string name, SKCodec codec, int imageScale, List imageFrames) - { - Offset = offset; - Name = name; - Codec = codec; - ImageScale = imageScale; - ImageFrames = imageFrames; - FrameCount = codec.FrameCount; - - DurationList = new List(); - for (int i = 0; i < FrameCount; i++) - { - var duration = Codec.FrameInfo[i].Duration / 10; - DurationList.Add(duration); - TotalDuration += duration; - } - - if (TotalDuration == 0 || TotalDuration == FrameCount) - { - for (int i = 0; i < DurationList.Count; i++) - { - DurationList.RemoveAt(i); - DurationList.Insert(i, 10); - } - TotalDuration = DurationList.Count * 10; - } - - for (int i = 0; i < DurationList.Count; i++) - { - if (DurationList[i] == 0) - { - TotalDuration += 10; - DurationList[i] = 10; - } - } - - Width = ImageFrames.First().Width; - Height = ImageFrames.First().Height; - - imageScale = ImageScale; - } - } -} diff --git a/TwitchDownloaderCore/TwitchObjects/Gql/GqlBadgeResponse.cs b/TwitchDownloaderCore/TwitchObjects/Gql/GqlBadgeResponse.cs index f64e2a61..366e8de1 100644 --- a/TwitchDownloaderCore/TwitchObjects/Gql/GqlBadgeResponse.cs +++ b/TwitchDownloaderCore/TwitchObjects/Gql/GqlBadgeResponse.cs @@ -1,9 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; using System.Text.Json.Serialization; -using System.Threading.Tasks; namespace TwitchDownloaderCore.TwitchObjects.Gql { diff --git a/TwitchDownloaderCore/TwitchObjects/Gql/GqlCheerResponse.cs b/TwitchDownloaderCore/TwitchObjects/Gql/GqlCheerResponse.cs index 21feda0c..410692df 100644 --- a/TwitchDownloaderCore/TwitchObjects/Gql/GqlCheerResponse.cs +++ b/TwitchDownloaderCore/TwitchObjects/Gql/GqlCheerResponse.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; +using System.Collections.Generic; namespace TwitchDownloaderCore.TwitchObjects.Gql { diff --git a/TwitchDownloaderCore/TwitchObjects/Gql/GqlClipTokenResponse.cs b/TwitchDownloaderCore/TwitchObjects/Gql/GqlClipTokenResponse.cs index 1e909c1e..97fbce66 100644 --- a/TwitchDownloaderCore/TwitchObjects/Gql/GqlClipTokenResponse.cs +++ b/TwitchDownloaderCore/TwitchObjects/Gql/GqlClipTokenResponse.cs @@ -5,7 +5,6 @@ public class ClipToken public string id { get; set; } public PlaybackAccessToken playbackAccessToken { get; set; } public VideoQuality[] videoQualities { get; set; } - public string __typename { get; set; } } public class ClipTokenData @@ -17,7 +16,6 @@ public class PlaybackAccessToken { public string signature { get; set; } public string value { get; set; } - public string __typename { get; set; } } public class GqlClipTokenResponse @@ -31,6 +29,5 @@ public class VideoQuality public double frameRate { get; set; } public string quality { get; set; } public string sourceURL { get; set; } - public string __typename { get; set; } } } diff --git a/TwitchDownloaderCore/TwitchObjects/Gql/GqlCommentResponse.cs b/TwitchDownloaderCore/TwitchObjects/Gql/GqlCommentResponse.cs index 165a4348..6c6a04f5 100644 --- a/TwitchDownloaderCore/TwitchObjects/Gql/GqlCommentResponse.cs +++ b/TwitchDownloaderCore/TwitchObjects/Gql/GqlCommentResponse.cs @@ -1,15 +1,11 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace TwitchDownloaderCore.TwitchObjects.Gql { public class CommentChannel { public string id { get; set; } - public string __typename { get; set; } } public class CommentCommenter @@ -17,21 +13,18 @@ public class CommentCommenter public string id { get; set; } public string login { get; set; } public string displayName { get; set; } - public string __typename { get; set; } } public class CommentComments { public List edges { get; set; } public CommentPageInfo pageInfo { get; set; } - public string __typename { get; set; } } public class Creator { public string id { get; set; } public CommentChannel channel { get; set; } - public string __typename { get; set; } } public class CommentData @@ -43,14 +36,12 @@ public class CommentEdge { public string cursor { get; set; } public CommentNode node { get; set; } - public string __typename { get; set; } } public class CommentFragment { public CommentEmote emote { get; set; } public string text { get; set; } - public string __typename { get; set; } } public class CommentEmote @@ -58,7 +49,6 @@ public class CommentEmote public string id { get; set; } public string emoteID { get; set; } public int from { get; set; } - public string __typename { get; set; } } public class CommentMessage @@ -66,7 +56,6 @@ public class CommentMessage public List fragments { get; set; } public List userBadges { get; set; } public string userColor { get; set; } - public string __typename { get; set; } } public class CommentNode @@ -76,14 +65,12 @@ public class CommentNode public int contentOffsetSeconds { get; set; } public DateTime createdAt { get; set; } public CommentMessage message { get; set; } - public string __typename { get; set; } } public class CommentPageInfo { public bool hasNextPage { get; set; } public bool hasPreviousPage { get; set; } - public string __typename { get; set; } } public class GqlCommentResponse @@ -97,7 +84,6 @@ public class CommentUserBadge public string id { get; set; } public string setID { get; set; } public string version { get; set; } - public string __typename { get; set; } } public class CommentVideo @@ -105,6 +91,5 @@ public class CommentVideo public string id { get; set; } public Creator creator { get; set; } public CommentComments comments { get; set; } - public string __typename { get; set; } } } diff --git a/TwitchDownloaderCore/TwitchObjects/Gql/GqlUserInfoResponse.cs b/TwitchDownloaderCore/TwitchObjects/Gql/GqlUserInfoResponse.cs index bff2cbaf..2f228c90 100644 --- a/TwitchDownloaderCore/TwitchObjects/Gql/GqlUserInfoResponse.cs +++ b/TwitchDownloaderCore/TwitchObjects/Gql/GqlUserInfoResponse.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace TwitchDownloaderCore.TwitchObjects.Gql { diff --git a/TwitchDownloaderCore/TwitchObjects/Gql/GqlVideoTokenResponse.cs b/TwitchDownloaderCore/TwitchObjects/Gql/GqlVideoTokenResponse.cs index d223a73d..fd2f4690 100644 --- a/TwitchDownloaderCore/TwitchObjects/Gql/GqlVideoTokenResponse.cs +++ b/TwitchDownloaderCore/TwitchObjects/Gql/GqlVideoTokenResponse.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TwitchDownloaderCore.TwitchObjects.Gql +namespace TwitchDownloaderCore.TwitchObjects.Gql { public class GqlVideoData { @@ -21,6 +15,5 @@ public class VideoPlaybackAccessToken { public string value { get; set; } public string signature { get; set; } - public string __typename { get; set; } } } diff --git a/TwitchDownloaderCore/TwitchObjects/TwitchComment.cs b/TwitchDownloaderCore/TwitchObjects/TwitchComment.cs deleted file mode 100644 index 2a13c886..00000000 --- a/TwitchDownloaderCore/TwitchObjects/TwitchComment.cs +++ /dev/null @@ -1,16 +0,0 @@ -using SkiaSharp; -using System; -using System.Collections.Generic; -using System.Text; - -namespace TwitchDownloaderCore.TwitchObjects -{ - public class TwitchComment - { - public string Section { get; set; } - public double SecondsOffset { get; set; } - public List GifEmotes { get; set; } - public List NormalEmotes { get; set; } - public List NormalEmotesPositions { get; set; } - } -} diff --git a/TwitchDownloaderCore/TwitchObjects/UpdateFrame.cs b/TwitchDownloaderCore/TwitchObjects/UpdateFrame.cs index 2f91e0b5..ffbe47d1 100644 --- a/TwitchDownloaderCore/TwitchObjects/UpdateFrame.cs +++ b/TwitchDownloaderCore/TwitchObjects/UpdateFrame.cs @@ -1,9 +1,5 @@ using SkiaSharp; -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace TwitchDownloaderCore.TwitchObjects { diff --git a/TwitchDownloaderCore/VideoDownloader.cs b/TwitchDownloaderCore/VideoDownloader.cs index 3069c08b..eecb1d74 100644 --- a/TwitchDownloaderCore/VideoDownloader.cs +++ b/TwitchDownloaderCore/VideoDownloader.cs @@ -5,7 +5,6 @@ using System.Globalization; using System.IO; using System.Linq; -using System.Net; using System.Net.Http; using System.Text; using System.Text.RegularExpressions; @@ -122,8 +121,8 @@ await FfmpegMetadata.SerializeAsync(metadataPath, videoInfo.owner.displayName, d ffmpegExitCode = await RunFfmpegVideoCopy(downloadFolder, outputFileInfo, concatListPath, metadataPath, startOffset, endDuration, videoLength, ffmpegRetries > 0, cancellationToken); if (ffmpegExitCode != 0) { - _progress.LogError($"Failed to finalize video (code {ffmpegExitCode}), retrying in 10 seconds..."); - await Task.Delay(10_000, cancellationToken); + _progress.LogError($"Failed to finalize video (code {ffmpegExitCode}), retrying in 5 seconds..."); + await Task.Delay(5_000, cancellationToken); } } while (ffmpegExitCode != 0 && ffmpegRetries++ < 1); diff --git a/TwitchDownloaderWPF/PageChatRender.xaml.cs b/TwitchDownloaderWPF/PageChatRender.xaml.cs index 21d5d19b..3ccccff0 100644 --- a/TwitchDownloaderWPF/PageChatRender.xaml.cs +++ b/TwitchDownloaderWPF/PageChatRender.xaml.cs @@ -20,7 +20,6 @@ using TwitchDownloaderCore.TwitchObjects; using TwitchDownloaderWPF.Models; using TwitchDownloaderWPF.Properties; -using TwitchDownloaderWPF.Translations; using TwitchDownloaderWPF.Utils; using WpfAnimatedGif; using MessageBox = System.Windows.MessageBox; @@ -197,14 +196,14 @@ private void LoadSettings() RadioEmojiNone.IsChecked = (EmojiVendor)Settings.Default.RenderEmojiVendor == EmojiVendor.None; comboBadges.Items.Clear(); - comboBadges.Items.Add(new CheckComboBoxItem { Content = Strings.BadgeMaskBroadcaster, Tag = ChatBadgeType.Broadcaster }); - comboBadges.Items.Add(new CheckComboBoxItem { Content = Strings.BadgeMaskModerator, Tag = ChatBadgeType.Moderator }); - comboBadges.Items.Add(new CheckComboBoxItem { Content = Strings.BadgeMaskVIP, Tag = ChatBadgeType.VIP }); - comboBadges.Items.Add(new CheckComboBoxItem { Content = Strings.BadgeMaskSubscriber, Tag = ChatBadgeType.Subscriber }); - comboBadges.Items.Add(new CheckComboBoxItem { Content = Strings.BadgeMaskPredictions, Tag = ChatBadgeType.Predictions }); - comboBadges.Items.Add(new CheckComboBoxItem { Content = Strings.BadgeMaskNoAudioNoVideo, Tag = ChatBadgeType.NoAudioVisual }); - comboBadges.Items.Add(new CheckComboBoxItem { Content = Strings.BadgeMaskTwitchPrime, Tag = ChatBadgeType.PrimeGaming }); - comboBadges.Items.Add(new CheckComboBoxItem { Content = Strings.BadgeMaskOthers, Tag = ChatBadgeType.Other }); + comboBadges.Items.Add(new CheckComboBoxItem { Content = Translations.Strings.BadgeMaskBroadcaster, Tag = ChatBadgeType.Broadcaster }); + comboBadges.Items.Add(new CheckComboBoxItem { Content = Translations.Strings.BadgeMaskModerator, Tag = ChatBadgeType.Moderator }); + comboBadges.Items.Add(new CheckComboBoxItem { Content = Translations.Strings.BadgeMaskVIP, Tag = ChatBadgeType.VIP }); + comboBadges.Items.Add(new CheckComboBoxItem { Content = Translations.Strings.BadgeMaskSubscriber, Tag = ChatBadgeType.Subscriber }); + comboBadges.Items.Add(new CheckComboBoxItem { Content = Translations.Strings.BadgeMaskPredictions, Tag = ChatBadgeType.Predictions }); + comboBadges.Items.Add(new CheckComboBoxItem { Content = Translations.Strings.BadgeMaskNoAudioNoVideo, Tag = ChatBadgeType.NoAudioVisual }); + comboBadges.Items.Add(new CheckComboBoxItem { Content = Translations.Strings.BadgeMaskTwitchPrime, Tag = ChatBadgeType.PrimeGaming }); + comboBadges.Items.Add(new CheckComboBoxItem { Content = Translations.Strings.BadgeMaskOthers, Tag = ChatBadgeType.Other }); var badgeMask = (ChatBadgeType)Settings.Default.ChatBadgeMask; foreach (CheckComboBoxItem item in comboBadges.Items) diff --git a/TwitchDownloaderWPF/PageClipDownload.xaml.cs b/TwitchDownloaderWPF/PageClipDownload.xaml.cs index 42fd3f3a..06b7770d 100644 --- a/TwitchDownloaderWPF/PageClipDownload.xaml.cs +++ b/TwitchDownloaderWPF/PageClipDownload.xaml.cs @@ -1,6 +1,5 @@ using Microsoft.Win32; using System; -using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Threading; diff --git a/TwitchDownloaderWPF/PageQueue.xaml.cs b/TwitchDownloaderWPF/PageQueue.xaml.cs index 5f1baf84..4ab7508d 100644 --- a/TwitchDownloaderWPF/PageQueue.xaml.cs +++ b/TwitchDownloaderWPF/PageQueue.xaml.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; using System.ComponentModel; using System.Threading; using System.Windows; @@ -17,7 +16,7 @@ namespace TwitchDownloaderWPF /// public partial class PageQueue : Page { - public static object taskLock = new object(); + public static readonly object taskLock = new object(); public static ObservableCollection taskList { get; set; } = new ObservableCollection(); BackgroundWorker taskManager = new BackgroundWorker(); @@ -33,13 +32,6 @@ public PageQueue() taskManager.DoWork += TaskManager_DoWork; taskManager.RunWorkerAsync(); - - taskList.CollectionChanged += TaskList_CollectionChanged; - } - - private void TaskList_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) - { - } private void TaskManager_DoWork(object sender, DoWorkEventArgs e) diff --git a/TwitchDownloaderWPF/Services/AvailableCultures.cs b/TwitchDownloaderWPF/Services/AvailableCultures.cs index 9b257903..c7056860 100644 --- a/TwitchDownloaderWPF/Services/AvailableCultures.cs +++ b/TwitchDownloaderWPF/Services/AvailableCultures.cs @@ -49,6 +49,6 @@ static AvailableCultures() SimplifiedChinese = new Culture("zh-CN", "简体中文"), }; } - // ReSharper enable StringLiteralTypo + // ReSharper restore StringLiteralTypo } } diff --git a/TwitchDownloaderWPF/Services/NativeFunctions.cs b/TwitchDownloaderWPF/Services/NativeFunctions.cs index 5be4c370..aa788fc4 100644 --- a/TwitchDownloaderWPF/Services/NativeFunctions.cs +++ b/TwitchDownloaderWPF/Services/NativeFunctions.cs @@ -27,12 +27,14 @@ public record struct FlashWInfo public uint FlashCount; public uint Timeout; + // ReSharper disable InconsistentNaming public const uint FLASHW_STOP = 0; public const uint FLASHW_CAPTION = 1; public const uint FLASHW_TRAY = 2; public const uint FLASHW_ALL = 3; public const uint FLASHW_TIMER = 4; public const uint FLASHW_TIMERNOFG = 12; + // ReSharper restore InconsistentNaming } } } \ No newline at end of file diff --git a/TwitchDownloaderWPF/Translations/Strings.ja.resx b/TwitchDownloaderWPF/Translations/Strings.ja.resx index 8ee84dcb..015c1b67 100644 --- a/TwitchDownloaderWPF/Translations/Strings.ja.resx +++ b/TwitchDownloaderWPF/Translations/Strings.ja.resx @@ -239,7 +239,7 @@ ダウンロード - + コネクション: @@ -248,7 +248,7 @@ ダウンロードフォーマット: - + ダウンロードスレッド: