mirror of
https://github.com/imrayya/SRTto3Dsubtitles.git
synced 2026-09-21 10:17:27 +02:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1c5d2e3934 | |||
| 9b7b8df874 |
@@ -4,19 +4,19 @@ namespace ConvertSRTto3DASS;
|
|||||||
|
|
||||||
internal static class Cli
|
internal static class Cli
|
||||||
{
|
{
|
||||||
public static void Run(string[] args)
|
public static bool Run(string[] args)
|
||||||
{
|
{
|
||||||
if (args.Length == 0 || args[0] is "--help" or "-h" or "/?")
|
if (args.Length == 0 || args[0] is "--help" or "-h" or "/?")
|
||||||
{
|
{
|
||||||
PrintUsage();
|
PrintUsage();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var inputPath = args[0];
|
var inputPath = args[0];
|
||||||
if (!File.Exists(inputPath))
|
if (!File.Exists(inputPath))
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine($"Input file not found: {inputPath}");
|
Console.Error.WriteLine($"Input file not found: {inputPath}");
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse options
|
// Parse options
|
||||||
@@ -80,7 +80,7 @@ internal static class Cli
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Console.Error.WriteLine($"Unknown argument: {args[i]}");
|
Console.Error.WriteLine($"Unknown argument: {args[i]}");
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@@ -106,11 +106,13 @@ internal static class Cli
|
|||||||
var result = SrtConverter.Convert(options);
|
var result = SrtConverter.Convert(options);
|
||||||
Console.WriteLine($"Parsed: {result.SubtitleCount} subtitle blocks");
|
Console.WriteLine($"Parsed: {result.SubtitleCount} subtitle blocks");
|
||||||
Console.WriteLine("Conversion complete.");
|
Console.WriteLine("Conversion complete.");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine($"ERROR: {ex.Message}");
|
Console.Error.WriteLine($"ERROR: {ex.Message}");
|
||||||
Console.Error.WriteLine(ex.ToString());
|
Console.Error.WriteLine(ex.ToString());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
string GetNextArg(int index) => index + 1 < args.Length ? args[index + 1] : throw new ArgumentException($"Missing value for {args[index]}");
|
string GetNextArg(int index) => index + 1 < args.Length ? args[index + 1] : throw new ArgumentException($"Missing value for {args[index]}");
|
||||||
|
|||||||
@@ -13,6 +13,9 @@
|
|||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
|
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
|
<PublishSingleFile>true</PublishSingleFile>
|
||||||
|
<PublishReadyToRun>false</PublishReadyToRun>
|
||||||
|
<StripSymbols>true</StripSymbols>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -2,5 +2,10 @@ namespace ConvertSRTto3DASS;
|
|||||||
|
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
static void Main(string[] args) => Cli.Run(args);
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
var hadError = Cli.Run(args);
|
||||||
|
if (hadError)
|
||||||
|
Console.ReadLine();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,10 @@
|
|||||||
<RootNamespace>ConvertSRTto3DASS</RootNamespace>
|
<RootNamespace>ConvertSRTto3DASS</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
|
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ public static class SrtConverter
|
|||||||
|
|
||||||
public static ConversionResult Convert(ConversionOptions options)
|
public static ConversionResult Convert(ConversionOptions options)
|
||||||
{
|
{
|
||||||
|
// Register legacy codepage support (needed for CP1252, etc.)
|
||||||
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||||
|
|
||||||
var srtText = ReadSrt(options.InputPath);
|
var srtText = ReadSrt(options.InputPath);
|
||||||
var subtitles = ParseSrt(srtText);
|
var subtitles = ParseSrt(srtText);
|
||||||
var header = CreateHeader(options);
|
var header = CreateHeader(options);
|
||||||
|
|||||||
Generated
+6
-2
@@ -71,11 +71,13 @@ partial class Form1
|
|||||||
Size = new Size(1040, 80)
|
Size = new Size(1040, 80)
|
||||||
};
|
};
|
||||||
label_InputFile = new Label { Text = "Input SRT:", Font = segoe, Location = new Point(15, 25), AutoSize = true };
|
label_InputFile = new Label { Text = "Input SRT:", Font = segoe, Location = new Point(15, 25), AutoSize = true };
|
||||||
textBox_InputFile = new TextBox { Location = new Point(100, 22), Size = new Size(780, 23), ReadOnly = true };
|
textBox_InputFile = new TextBox { Location = new Point(100, 22), Size = new Size(780, 23) };
|
||||||
button_BrowseInput = new Button { Text = "Browse...", Location = new Point(890, 20), Size = new Size(90, 25), Font = segoe, FlatStyle = FlatStyle.Flat };
|
button_BrowseInput = new Button { Text = "Browse...", Location = new Point(890, 20), Size = new Size(90, 25), Font = segoe, FlatStyle = FlatStyle.Flat };
|
||||||
|
button_BrowseInput.Click += button_BrowseInput_Click;
|
||||||
label_OutputFile = new Label { Text = "Output ASS:", Font = segoe, Location = new Point(15, 55), AutoSize = true };
|
label_OutputFile = new Label { Text = "Output ASS:", Font = segoe, Location = new Point(15, 55), AutoSize = true };
|
||||||
textBox_OutputFile = new TextBox { Location = new Point(100, 52), Size = new Size(780, 23), ReadOnly = true };
|
textBox_OutputFile = new TextBox { Location = new Point(100, 52), Size = new Size(780, 23) };
|
||||||
button_BrowseOutput = new Button { Text = "Browse...", Location = new Point(890, 50), Size = new Size(90, 25), Font = segoe, FlatStyle = FlatStyle.Flat };
|
button_BrowseOutput = new Button { Text = "Browse...", Location = new Point(890, 50), Size = new Size(90, 25), Font = segoe, FlatStyle = FlatStyle.Flat };
|
||||||
|
button_BrowseOutput.Click += button_BrowseOutput_Click;
|
||||||
groupBox_File.Controls.AddRange([label_InputFile, textBox_InputFile, button_BrowseInput, label_OutputFile, textBox_OutputFile, button_BrowseOutput]);
|
groupBox_File.Controls.AddRange([label_InputFile, textBox_InputFile, button_BrowseInput, label_OutputFile, textBox_OutputFile, button_BrowseOutput]);
|
||||||
|
|
||||||
// ---- Mode section ----
|
// ---- Mode section ----
|
||||||
@@ -95,6 +97,7 @@ partial class Form1
|
|||||||
DropDownStyle = ComboBoxStyle.DropDownList
|
DropDownStyle = ComboBoxStyle.DropDownList
|
||||||
};
|
};
|
||||||
comboBox_Mode.Items.AddRange(["SBS (Side-by-Side)", "OU (Over-Under)", "RG (Red-Green)"]);
|
comboBox_Mode.Items.AddRange(["SBS (Side-by-Side)", "OU (Over-Under)", "RG (Red-Green)"]);
|
||||||
|
comboBox_Mode.SelectedIndexChanged += comboBox_Mode_SelectedIndexChanged;
|
||||||
groupBox_Mode.Controls.AddRange([label_Mode, comboBox_Mode]);
|
groupBox_Mode.Controls.AddRange([label_Mode, comboBox_Mode]);
|
||||||
|
|
||||||
// ---- Resolution section ----
|
// ---- Resolution section ----
|
||||||
@@ -165,6 +168,7 @@ partial class Form1
|
|||||||
ForeColor = Color.White,
|
ForeColor = Color.White,
|
||||||
FlatAppearance = { BorderSize = 0 }
|
FlatAppearance = { BorderSize = 0 }
|
||||||
};
|
};
|
||||||
|
button_Convert.Click += button_Convert_Click;
|
||||||
|
|
||||||
// ---- Status ----
|
// ---- Status ----
|
||||||
textBox_Status = new TextBox
|
textBox_Status = new TextBox
|
||||||
|
|||||||
Reference in New Issue
Block a user