12 Commits
Author SHA1 Message Date
Stevan Freeborn 34b1a17f9f chore(release): 0.3.0 [skip ci] 2025-10-09 21:14:51 +00:00
Stevan Freeborn 4277ea1283 Merge pull request #14 from StevanFreeborn/stevanfreeborn/feat/add-output-directory-config-setting
feat: add configurable output directory with validation
2025-10-09 16:14:33 -05:00
Stevan Freeborn 6ebec7c285 fix: use file system abstraction in base directory method. thanks copilot 🤖 2025-10-09 16:14:10 -05:00
Stevan Freeborn 8632f88817 feat: add configurable output directory with validation
- Add support for OutputDirectory configuration setting.
- The command now validates the configured directory path,
  creates it if needed, and falls back to the application
  base directory if invalid. Includes error handling for
  path-related exceptions.
2025-10-09 16:08:56 -05:00
Stevan Freeborn 487183ef1f chore(release): 0.2.0 [skip ci] 2025-08-21 03:18:07 +00:00
Stevan Freeborn 708b97a5c0 Merge pull request #8 from StevanFreeborn/stevanfreeborn/feat/5-display-location-of-shorts
feat: display location of output with link inside panel
2025-08-20 22:17:47 -05:00
Stevan Freeborn 57e95b2ea1 feat: display location of output with link inside panel 2025-08-20 22:17:06 -05:00
Stevan Freeborn 9b5a65fc92 chore(release): 0.1.0 [skip ci] 2025-08-21 02:43:39 +00:00
Stevan Freeborn ecc676bff1 Merge pull request #7 from StevanFreeborn/stevanfreeborn/feat/6-throw-error-if-appsettings-not-present
feat: make sure error is shown to user if appsettings.json file is not present
2025-08-20 21:43:16 -05:00
Stevan Freeborn d560909f16 feat: fallback to static AnsiConsole if exception occurs before registered in DI container 2025-08-20 21:42:19 -05:00
Stevan Freeborn 51f5359202 Merge branch 'main' of github.com:StevanFreeborn/stream-shorts 2025-08-20 16:32:21 -05:00
Stevan Freeborn 022798d11b chore: update gitignore 2025-08-20 16:32:15 -05:00
6 changed files with 85 additions and 20 deletions
+3
View File
@@ -3,6 +3,9 @@
##
## Get latest from `dotnet new gitignore`
# published files
dist/
# dotenv files
.env
appsettings*.json
+25
View File
@@ -2,6 +2,31 @@
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>
## [0.2.0](https://www.github.com/StevanFreeborn/stream-shorts/releases/tag/v0.2.0) (2025-08-21)
### Features
* display location of output with link inside panel ([57e95b2](https://www.github.com/StevanFreeborn/stream-shorts/commit/57e95b2ea19ea97019df70bd7a5414984faaa1c7))
<a name="0.1.0"></a>
## [0.1.0](https://www.github.com/StevanFreeborn/stream-shorts/releases/tag/v0.1.0) (2025-08-21)
### Features
* fallback to static AnsiConsole if exception occurs before registered in DI container ([d560909](https://www.github.com/StevanFreeborn/stream-shorts/commit/d560909f16f0a97b399f8139f94b6f2fe07cf033))
<a name="0.0.0"></a>
## [0.0.0](https://www.github.com/StevanFreeborn/stream-shorts/releases/tag/v0.0.0) (2025-08-20)
@@ -10,7 +10,9 @@ internal sealed class DefaultCommand(
ITranscriber transcriber,
ITranscriptAnalyzer transcriptAnalyzer,
IShortsCreator shortsCreator,
TimeProvider timeProvider
TimeProvider timeProvider,
IConfiguration appConfig,
ILogger<DefaultCommand> logger
) : AsyncCommand<DefaultCommand.Settings>
{
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 IShortsCreator _shortsCreator = shortsCreator ?? throw new ArgumentNullException(nameof(shortsCreator));
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>
/// Represents the settings for the default command.
@@ -71,10 +75,7 @@ internal sealed class DefaultCommand(
await _console.Status()
.Spinner(Spinner.Known.Dots)
.StartAsync("Extracting audio...", async _ =>
{
audioStream = await _audioExtractor.ExtractMp3FromMp4Async(videoStream);
});
.StartAsync("Extracting audio...", async _ => audioStream = await _audioExtractor.ExtractMp3FromMp4Async(videoStream));
if (audioStream is null)
{
@@ -102,10 +103,9 @@ internal sealed class DefaultCommand(
var now = _timeProvider.GetUtcNow();
var inputFileName = _fileSystem.Path.GetFileNameWithoutExtension(settings.Stream);
var outputDirectoryPath = _fileSystem.Path.Combine(
AppContext.BaseDirectory,
$"{now:yyyy_MM_dd_HH_mm_ss}_{inputFileName}"
);
var baseDirectory = ValidateAndGetBaseOutputDirectory();
var artifactsOutputDirectory = $"{now:yyyy_MM_dd_HH_mm_ss}_{inputFileName}";
var outputDirectoryPath = _fileSystem.Path.Combine(baseDirectory, artifactsOutputDirectory);
_fileSystem.Directory.CreateDirectory(outputDirectoryPath);
@@ -118,10 +118,7 @@ internal sealed class DefaultCommand(
await _console.Status()
.Spinner(Spinner.Known.Dots)
.StartAsync("Analyzing transcript...", async _ =>
{
analysis = await _transcriptAnalyzer.AnalyzeAsync(transcriptionSegments);
});
.StartAsync("Analyzing transcript...", async _ => analysis = await _transcriptAnalyzer.AnalyzeAsync(transcriptionSegments));
if (analysis is null)
{
@@ -149,14 +146,54 @@ internal sealed class DefaultCommand(
}
});
_console.MarkupLine($"[blue]Shorts created[/] [green]successfully![/]");
var directoryUri = new Uri(outputDirectoryPath).AbsoluteUri;
var panel = new Panel($"[blue link={directoryUri}]{artifactsOutputDirectory}[/]")
{
Header = new PanelHeader($"[blue]Shorts created[/] [green]successfully![/]")
};
return 0;
_console.Write(panel);
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
{
FailedToExtractAudio,
FailedToAnalyzeTranscript,
SuccessFullyProcessedStream,
}
}
@@ -18,9 +18,9 @@ internal static class HostBuilderExtensions
app.Configure(static c =>
c.SetExceptionHandler(static (ex, resolver) =>
{
var console = resolver?.Resolve(typeof(IAnsiConsole)) as IAnsiConsole;
console?.MarkupLine($"[red]An error occurred while executing the command:[/]");
console?.WriteException(ex, ExceptionFormats.ShortenEverything);
var console = resolver?.Resolve(typeof(IAnsiConsole)) as IAnsiConsole ?? AnsiConsole.Console;
console.MarkupLine($"[red]An error occurred while executing the command:[/]");
console.WriteException(ex, ExceptionFormats.ShortenEverything);
})
);
+1 -1
View File
@@ -25,7 +25,7 @@ try
services.AddSingleton(TimeProvider.System);
services.AddSingleton<IAudioExtractor, AudioExtractor>();
services.AddSingleton<ITranscriber, WhisperTranscriber>();
services.AddSingleton<ITranscriptAnalyzer, GeminiAnalyzer>(sp =>
services.AddSingleton<ITranscriptAnalyzer, GeminiAnalyzer>(static sp =>
{
const string modelOptionName = "Model";
const string keyOptionName = "ApiKey";
@@ -4,7 +4,7 @@
<AssemblyTitle>StreamShorts.Console</AssemblyTitle>
<Product>StreamShorts.Console</Product>
<Description>A command-line interface for StreamShorts</Description>
<Version>0.0.0</Version>
<Version>0.3.0</Version>
<Authors>Stevan Freeborn</Authors>
<OutputType>Exe</OutputType>
<PublishSingleFile>true</PublishSingleFile>