Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34b1a17f9f | ||
|
|
4277ea1283 | ||
|
|
6ebec7c285 | ||
|
|
8632f88817 |
@@ -2,6 +2,17 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file. See [versionize](https://github.com/versionize/versionize) for commit guidelines.
|
All notable changes to this project will be documented in this file. See [versionize](https://github.com/versionize/versionize) for commit guidelines.
|
||||||
|
|
||||||
|
<a name="0.3.0"></a>
|
||||||
|
## [0.3.0](https://www.github.com/StevanFreeborn/stream-shorts/releases/tag/v0.3.0) (2025-10-09)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add configurable output directory with validation ([8632f88](https://www.github.com/StevanFreeborn/stream-shorts/commit/8632f88817c78663c632156a490eb118b802fef6))
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* use file system abstraction in base directory method. thanks copilot 🤖 ([6ebec7c](https://www.github.com/StevanFreeborn/stream-shorts/commit/6ebec7c2859200fd6c4374a84786c21dfa143171))
|
||||||
|
|
||||||
<a name="0.2.0"></a>
|
<a name="0.2.0"></a>
|
||||||
## [0.2.0](https://www.github.com/StevanFreeborn/stream-shorts/releases/tag/v0.2.0) (2025-08-21)
|
## [0.2.0](https://www.github.com/StevanFreeborn/stream-shorts/releases/tag/v0.2.0) (2025-08-21)
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ internal sealed class DefaultCommand(
|
|||||||
ITranscriber transcriber,
|
ITranscriber transcriber,
|
||||||
ITranscriptAnalyzer transcriptAnalyzer,
|
ITranscriptAnalyzer transcriptAnalyzer,
|
||||||
IShortsCreator shortsCreator,
|
IShortsCreator shortsCreator,
|
||||||
TimeProvider timeProvider
|
TimeProvider timeProvider,
|
||||||
|
IConfiguration appConfig,
|
||||||
|
ILogger<DefaultCommand> logger
|
||||||
) : AsyncCommand<DefaultCommand.Settings>
|
) : AsyncCommand<DefaultCommand.Settings>
|
||||||
{
|
{
|
||||||
private readonly JsonSerializerOptions _jsonSerializerOptions = new()
|
private readonly JsonSerializerOptions _jsonSerializerOptions = new()
|
||||||
@@ -26,6 +28,8 @@ internal sealed class DefaultCommand(
|
|||||||
private readonly ITranscriptAnalyzer _transcriptAnalyzer = transcriptAnalyzer ?? throw new ArgumentNullException(nameof(transcriptAnalyzer));
|
private readonly ITranscriptAnalyzer _transcriptAnalyzer = transcriptAnalyzer ?? throw new ArgumentNullException(nameof(transcriptAnalyzer));
|
||||||
private readonly IShortsCreator _shortsCreator = shortsCreator ?? throw new ArgumentNullException(nameof(shortsCreator));
|
private readonly IShortsCreator _shortsCreator = shortsCreator ?? throw new ArgumentNullException(nameof(shortsCreator));
|
||||||
private readonly TimeProvider _timeProvider = timeProvider ?? throw new ArgumentNullException(nameof(timeProvider));
|
private readonly TimeProvider _timeProvider = timeProvider ?? throw new ArgumentNullException(nameof(timeProvider));
|
||||||
|
private readonly IConfiguration _appConfig = appConfig ?? throw new ArgumentNullException(nameof(appConfig));
|
||||||
|
private readonly ILogger<DefaultCommand> _logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the settings for the default command.
|
/// Represents the settings for the default command.
|
||||||
@@ -99,8 +103,9 @@ internal sealed class DefaultCommand(
|
|||||||
|
|
||||||
var now = _timeProvider.GetUtcNow();
|
var now = _timeProvider.GetUtcNow();
|
||||||
var inputFileName = _fileSystem.Path.GetFileNameWithoutExtension(settings.Stream);
|
var inputFileName = _fileSystem.Path.GetFileNameWithoutExtension(settings.Stream);
|
||||||
var outputDirectory = $"{now:yyyy_MM_dd_HH_mm_ss}_{inputFileName}";
|
var baseDirectory = ValidateAndGetBaseOutputDirectory();
|
||||||
var outputDirectoryPath = _fileSystem.Path.Combine(AppContext.BaseDirectory, outputDirectory);
|
var artifactsOutputDirectory = $"{now:yyyy_MM_dd_HH_mm_ss}_{inputFileName}";
|
||||||
|
var outputDirectoryPath = _fileSystem.Path.Combine(baseDirectory, artifactsOutputDirectory);
|
||||||
|
|
||||||
_fileSystem.Directory.CreateDirectory(outputDirectoryPath);
|
_fileSystem.Directory.CreateDirectory(outputDirectoryPath);
|
||||||
|
|
||||||
@@ -142,7 +147,7 @@ internal sealed class DefaultCommand(
|
|||||||
});
|
});
|
||||||
|
|
||||||
var directoryUri = new Uri(outputDirectoryPath).AbsoluteUri;
|
var directoryUri = new Uri(outputDirectoryPath).AbsoluteUri;
|
||||||
var panel = new Panel($"[blue link={directoryUri}]{outputDirectory}[/]")
|
var panel = new Panel($"[blue link={directoryUri}]{artifactsOutputDirectory}[/]")
|
||||||
{
|
{
|
||||||
Header = new PanelHeader($"[blue]Shorts created[/] [green]successfully![/]")
|
Header = new PanelHeader($"[blue]Shorts created[/] [green]successfully![/]")
|
||||||
};
|
};
|
||||||
@@ -152,6 +157,39 @@ internal sealed class DefaultCommand(
|
|||||||
return (int)ExitCode.SuccessFullyProcessedStream;
|
return (int)ExitCode.SuccessFullyProcessedStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string ValidateAndGetBaseOutputDirectory()
|
||||||
|
{
|
||||||
|
var baseDirectory = _appConfig.GetValue<string>("OutputDirectory");
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(baseDirectory))
|
||||||
|
{
|
||||||
|
return AppContext.BaseDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var fullPath = _fileSystem.Path.GetFullPath(baseDirectory);
|
||||||
|
|
||||||
|
if (_fileSystem.Directory.Exists(fullPath) is false)
|
||||||
|
{
|
||||||
|
_fileSystem.Directory.CreateDirectory(fullPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
return fullPath;
|
||||||
|
}
|
||||||
|
catch (Exception ex) when (
|
||||||
|
ex is ArgumentException
|
||||||
|
or NotSupportedException
|
||||||
|
or PathTooLongException
|
||||||
|
or DirectoryNotFoundException
|
||||||
|
or UnauthorizedAccessException
|
||||||
|
)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, "The configured output directory '{BaseDirectory}' is invalid. Defaulting to application base directory.", baseDirectory);
|
||||||
|
return AppContext.BaseDirectory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private enum ExitCode
|
private enum ExitCode
|
||||||
{
|
{
|
||||||
FailedToExtractAudio,
|
FailedToExtractAudio,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<AssemblyTitle>StreamShorts.Console</AssemblyTitle>
|
<AssemblyTitle>StreamShorts.Console</AssemblyTitle>
|
||||||
<Product>StreamShorts.Console</Product>
|
<Product>StreamShorts.Console</Product>
|
||||||
<Description>A command-line interface for StreamShorts</Description>
|
<Description>A command-line interface for StreamShorts</Description>
|
||||||
<Version>0.2.0</Version>
|
<Version>0.3.0</Version>
|
||||||
<Authors>Stevan Freeborn</Authors>
|
<Authors>Stevan Freeborn</Authors>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<PublishSingleFile>true</PublishSingleFile>
|
<PublishSingleFile>true</PublishSingleFile>
|
||||||
|
|||||||
Reference in New Issue
Block a user