Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor cleanup #1065

Merged
merged 2 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TwitchDownloaderCore/Chat/ChatHtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static async Task SerializeAsync(string filePath, ChatRoot chatRoot, ITas
TwitchHelper.CreateDirectory(outputDirectory.FullName);
}

await using var fs = File.Create(filePath);
await using var fs = File.Open(filePath, FileMode.Create, FileAccess.Write, FileShare.Read);
await using var sw = new StreamWriter(fs);

while (!templateReader.EndOfStream)
Expand Down
6 changes: 3 additions & 3 deletions TwitchDownloaderCore/Chat/ChatJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ private static async Task<JsonDocument> GetJsonDocumentAsync(Stream stream, stri
}
}

#pragma warning disable CS0618
#pragma warning disable CS0618 // Type or member is obsolete
private static async Task UpgradeChatJson(ChatRoot chatRoot)
{
const int MAX_STREAM_LENGTH = 172_800; // 48 hours in seconds. https://help.twitch.tv/s/article/broadcast-guidelines
Expand Down Expand Up @@ -239,7 +239,7 @@ private static async Task UpgradeChatJson(ChatRoot chatRoot)
}
}
}
#pragma warning restore CS0618
#pragma warning restore CS0618 // Type or member is obsolete

/// <summary>
/// Asynchronously serializes a chat json file.
Expand All @@ -254,7 +254,7 @@ public static async Task SerializeAsync(string filePath, ChatRoot chatRoot, Chat
TwitchHelper.CreateDirectory(outputDirectory.FullName);
}

await using var fs = File.Create(filePath);
await using var fs = File.Open(filePath, FileMode.Create, FileAccess.Write, FileShare.Read);
switch (compression)
{
case ChatCompression.None:
Expand Down
4 changes: 2 additions & 2 deletions TwitchDownloaderCore/Tools/FfmpegMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

namespace TwitchDownloaderCore.Tools
{
// https://ffmpeg.org/ffmpeg-formats.html#Metadata-1
// https://ffmpeg.org/ffmpeg-formats.html#Metadata-2
public static class FfmpegMetadata
{
private const string LINE_FEED = "\u000A";

public static async Task SerializeAsync(string filePath, string streamerName, string videoId, string videoTitle, DateTime videoCreation, int viewCount, string videoDescription = null,
TimeSpan startOffset = default, IEnumerable<VideoMomentEdge> videoMomentEdges = null, CancellationToken cancellationToken = default)
{
await using var fs = new FileStream(filePath, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.Read);
await using var fs = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.Read);
await using var sw = new StreamWriter(fs) { NewLine = LINE_FEED };

await SerializeGlobalMetadata(sw, streamerName, videoId, videoTitle, videoCreation, viewCount, videoDescription);
Expand Down
16 changes: 3 additions & 13 deletions TwitchDownloaderWPF/WindowSettings.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using TwitchDownloaderWPF.Models;
using TwitchDownloaderWPF.Properties;
using TwitchDownloaderWPF.Services;
using CheckComboBox = HandyControl.Controls.CheckComboBox;
using CheckComboBoxItem = HandyControl.Controls.CheckComboBoxItem;

namespace TwitchDownloaderWPF
Expand Down Expand Up @@ -70,20 +69,11 @@ private void Window_Initialized(object sender, EventArgs e)
}

// Setup culture dropdown
foreach (var culture in AvailableCultures.All)
{
ComboLocale.Items.Add(culture.NativeName);
}
var currentCulture = Settings.Default.GuiCulture;
var selectedIndex = AvailableCultures.All.Select((item, index) => (item, index))
.Where(x => x.item.Code == currentCulture)
.Select(x => x.index)
.DefaultIfEmpty(-1)
.First();

if (selectedIndex > -1)
foreach (var (culture, index) in AvailableCultures.All.Select((x, index) => (x, index)))
{
ComboLocale.SelectedIndex = selectedIndex;
ComboLocale.Items.Add(culture.NativeName);
if (culture.Code == currentCulture) ComboLocale.SelectedIndex = index;
}

ComboLogLevels.Items.Add(new CheckComboBoxItem { Content = Translations.Strings.LogLevelVerbose, Tag = LogLevel.Verbose });
Expand Down
Loading