Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 7 additions & 2 deletions src/RipSharp/Core/RipOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,16 @@ public static RipOptions ParseArgs(string[] args)
}
if (string.IsNullOrEmpty(opts.Temp))
{
opts.Temp = Path.Combine(opts.Output, ".makemkv");
opts.Temp = Path.Combine(opts.Output, GetTempDirectoryName());
}
return opts;
}

private static string GetTempDirectoryName()
{
return $".{Path.GetFileNameWithoutExtension(Path.GetRandomFileName())}";
}

public static void DisplayHelp(IConsoleWriter writer)
{
writer.Plain("ripsharp - DVD/Blu-Ray/UHD disc ripping tool");
Expand All @@ -95,7 +100,7 @@ public static void DisplayHelp(IConsoleWriter writer)
writer.Plain(" - movie: Treat as single movie");
writer.Plain(" - tv: Treat as TV series");
writer.Plain(" --disc PATH Optical drive path (default: disc:0)");
writer.Plain(" --temp PATH Temporary ripping directory (default: {output}/.makemkv)");
writer.Plain(" --temp PATH Temporary ripping directory (default: {output}/<RANDOM_STRING>)");
writer.Plain(" --title TEXT Custom title for file naming");
writer.Plain(" --year YYYY Release year (movies only)");
writer.Plain(" --season N Season number (TV only, default: 1)");
Expand Down
32 changes: 32 additions & 0 deletions src/RipSharp/Services/DiscRipper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ public async Task<List<string>> ProcessDiscAsync(RipOptions options)
}

var finalFiles = await EncodeAndRenameAsync(discInfo, titleIds, rippedFilesMap, metadata, options);

if (finalFiles.Count > 0)
{
CleanupTempDirectory(options);
}
Comment thread
mapitman marked this conversation as resolved.

_notifier.Success($"Processing complete. Output files: {finalFiles.Count}");
foreach (var f in finalFiles) _notifier.Plain(f);
return finalFiles;
Expand Down Expand Up @@ -262,4 +268,30 @@ private async Task<List<string>> EncodeAndRenameAsync(DiscInfo discInfo, List<in
}
return finalFiles;
}

private void CleanupTempDirectory(RipOptions options)
{
if (string.IsNullOrWhiteSpace(options.Temp)) return;

var tempPath = Path.GetFullPath(options.Temp);
var outputPath = Path.GetFullPath(options.Output);

if (tempPath == outputPath)
{
_notifier.Warning("Skipping temp cleanup because temp directory matches the output directory.");
return;
}

if (!Directory.Exists(tempPath)) return;

try
{
Directory.Delete(tempPath, recursive: true);
_notifier.Muted($"Cleaned up temporary rip files at {tempPath}");
}
catch (Exception ex)
{
_notifier.Warning($"Failed to clean up temp directory '{tempPath}': {ex.Message}");
}
}
Comment thread
mapitman marked this conversation as resolved.
}
Loading