6 Commits
Author SHA1 Message Date
l4kr 304d9ad047 Bump version to 1.0.5
Handle [TAG] NN episode-only filenames: when a file already
carries a bracket tag prefix followed directly by an episode
number (e.g. [WBDP] 03 - Deus Vult), inject the show name
from the parent folder between the tag and the episode part.

Also update ExtractShowName to handle bracket-style folder
names (text before the first [ is the show name).
2026-07-07 14:15:43 +02:00
l4kr 11a519d309 Ignore publish/ build output 2026-07-05 17:14:16 +02:00
l4kr 8b94fefe0f Bump version to 1.0.4
Extract in-filename suffix release tag (e.g. -DemiHuman) and
move it to a [DemiHuman] bracket prefix, stripping it from the
filename. File-level tag takes priority over folder-derived tag.
2026-07-05 17:14:08 +02:00
l4kr 02ce7bb872 Bump version to 1.0.3
- Suffix release tag support: folder name ending in -TAG
  prepends [TAG] to output filenames
- Show name injection from parent folder for episode-only
  filenames (e.g. S01E01-Name.mkv)
- Queue and logs display predicted output filename
- Run button label reflects rename when applicable
- Gray out main UI while strip/rename is in progress
2026-07-05 16:42:55 +02:00
l4kr e61cb5e709 fixed space to play 2026-07-04 12:08:56 +02:00
l4kr a322b6bb00 fixed shit with the renames 2026-07-04 12:01:13 +02:00
7 changed files with 244 additions and 50 deletions
+1
View File
@@ -1,5 +1,6 @@
bin/ bin/
obj/ obj/
publish/
*.user *.user
history.json history.json
settings.json settings.json
+2 -2
View File
@@ -9,8 +9,8 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<AssemblyName>Futonizer</AssemblyName> <AssemblyName>Futonizer</AssemblyName>
<RootNamespace>Futonizer</RootNamespace> <RootNamespace>Futonizer</RootNamespace>
<Version>1.0.2</Version> <Version>1.0.5</Version>
<FileVersion>1.0.2.0</FileVersion> <FileVersion>1.0.5.0</FileVersion>
<ApplicationIcon>Assets\app.ico</ApplicationIcon> <ApplicationIcon>Assets\app.ico</ApplicationIcon>
</PropertyGroup> </PropertyGroup>
+11 -1
View File
@@ -175,7 +175,7 @@
Foreground="#F44336" VerticalAlignment="Center" Foreground="#F44336" VerticalAlignment="Center"
Visibility="{Binding IsIncorrect, Converter={StaticResource BoolToVis}}"/> Visibility="{Binding IsIncorrect, Converter={StaticResource BoolToVis}}"/>
<TextBlock Grid.Column="1" Text="{Binding FileName}" <TextBlock Grid.Column="1" Text="{Binding DisplayFileName}"
FontSize="12" VerticalAlignment="Center" Margin="6,0" FontSize="12" VerticalAlignment="Center" Margin="6,0"
TextTrimming="CharacterEllipsis"/> TextTrimming="CharacterEllipsis"/>
@@ -230,6 +230,7 @@
GridLinesVisibility="None" GridLinesVisibility="None"
VirtualizingPanel.ScrollUnit="Pixel" VirtualizingPanel.ScrollUnit="Pixel"
PreviewMouseWheel="SmoothList_PreviewMouseWheel" PreviewMouseWheel="SmoothList_PreviewMouseWheel"
PreviewKeyDown="TrackGrid_PreviewKeyDown"
ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto"> ScrollViewer.VerticalScrollBarVisibility="Auto">
<DataGrid.RowStyle> <DataGrid.RowStyle>
@@ -330,6 +331,15 @@
</Grid> </Grid>
</Border> </Border>
<!-- Processing overlay: dims the entire content area while stripping is running -->
<Border x:Name="ProcessingOverlay"
Grid.ColumnSpan="3"
Background="#99000000"
CornerRadius="8"
Visibility="Collapsed"
IsHitTestVisible="True"
Panel.ZIndex="10"/>
<!-- Loading overlay: blocks interaction until every queued file has finished loading --> <!-- Loading overlay: blocks interaction until every queued file has finished loading -->
<Border x:Name="LoadingOverlay" <Border x:Name="LoadingOverlay"
Grid.ColumnSpan="3" Grid.ColumnSpan="3"
+21 -43
View File
@@ -2,7 +2,6 @@ using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
@@ -78,42 +77,6 @@ public partial class MainWindow : FluentWindow
// ── Helpers ────────────────────────────────────────────────────────────── // ── Helpers ──────────────────────────────────────────────────────────────
/// <summary>
/// If the file's parent folder has a bracketed prefix (e.g. "[neoHEVC] ")
/// and the file itself doesn't, renames the file on disk to include that
/// prefix and returns the new path. Returns the original path unchanged if
/// the condition isn't met or the rename fails.
/// </summary>
private static string TryApplyFolderPrefix(string filePath)
{
string? folder = Path.GetDirectoryName(filePath);
if (string.IsNullOrEmpty(folder)) return filePath;
string folderName = Path.GetFileName(folder);
var match = Regex.Match(folderName, @"^\[.+?\] ");
if (!match.Success) return filePath;
string prefix = match.Value;
string fileName = Path.GetFileName(filePath);
if (fileName.StartsWith(prefix, StringComparison.Ordinal)) return filePath;
string newFileName = prefix + fileName;
string newFilePath = Path.Combine(folder, newFileName);
if (File.Exists(newFilePath)) return filePath;
try
{
File.Move(filePath, newFilePath);
return newFilePath;
}
catch
{
return filePath;
}
}
private static void RestartApplication() private static void RestartApplication()
{ {
try try
@@ -168,6 +131,15 @@ public partial class MainWindow : FluentWindow
RunButton.ToolTip = allCorrect RunButton.ToolTip = allCorrect
? null ? null
: "Every file in the queue needs exactly one audio and one subtitle track selected before stripping."; : "Every file in the queue needs exactly one audio and one subtitle track selected before stripping.";
UpdateRunButtonLabel();
}
private void UpdateRunButtonLabel()
{
bool anyRename = _fileQueue.Any(f =>
!string.Equals(f.DisplayFileName, f.FileName, StringComparison.Ordinal));
RunButton.Content = anyRename ? "Rename and Strip Tracks" : "Strip Tracks";
} }
private void QueuedFileItem_PropertyChanged(object? sender, PropertyChangedEventArgs e) private void QueuedFileItem_PropertyChanged(object? sender, PropertyChangedEventArgs e)
@@ -249,23 +221,20 @@ public partial class MainWindow : FluentWindow
&& !_fileQueue.Any(q => string.Equals(q.FilePath, p, StringComparison.OrdinalIgnoreCase))) && !_fileQueue.Any(q => string.Equals(q.FilePath, p, StringComparison.OrdinalIgnoreCase)))
.ToList(); .ToList();
var addedPaths = new List<string>();
foreach (var path in newFiles) foreach (var path in newFiles)
{ {
string effectivePath = TryApplyFolderPrefix(path); var item = new QueuedFileItem(path);
var item = new QueuedFileItem(effectivePath);
item.PropertyChanged += QueuedFileItem_PropertyChanged; item.PropertyChanged += QueuedFileItem_PropertyChanged;
_fileQueue.Add(item); _fileQueue.Add(item);
_ = ScanFileItemAsync(item); _ = ScanFileItemAsync(item);
addedPaths.Add(effectivePath);
} }
UpdateLoadingOverlay(); UpdateLoadingOverlay();
if (addedPaths.Count > 0) if (newFiles.Count > 0)
{ {
var first = _fileQueue.FirstOrDefault(q => var first = _fileQueue.FirstOrDefault(q =>
string.Equals(q.FilePath, addedPaths[0], StringComparison.OrdinalIgnoreCase)); string.Equals(q.FilePath, newFiles[0], StringComparison.OrdinalIgnoreCase));
if (first != null) FileQueueList.SelectedItem = first; if (first != null) FileQueueList.SelectedItem = first;
} }
} }
@@ -443,6 +412,13 @@ public partial class MainWindow : FluentWindow
/// Windows has associated with .mkv files (typically the default video /// Windows has associated with .mkv files (typically the default video
/// player), so the user can quickly preview a file without leaving the app. /// player), so the user can quickly preview a file without leaving the app.
/// </summary> /// </summary>
private void TrackGrid_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
if (e.Key != System.Windows.Input.Key.Space) return;
OpenSelectedFileInDefaultPlayer();
e.Handled = true;
}
private void OpenSelectedFileInDefaultPlayer() private void OpenSelectedFileInDefaultPlayer()
{ {
if (FileQueueList.SelectedItem is not QueuedFileItem item) return; if (FileQueueList.SelectedItem is not QueuedFileItem item) return;
@@ -533,6 +509,7 @@ public partial class MainWindow : FluentWindow
_isProcessing = true; _isProcessing = true;
RunButton.IsEnabled = false; RunButton.IsEnabled = false;
StatusText.Text = string.Empty; StatusText.Text = string.Empty;
ProcessingOverlay.Visibility = Visibility.Visible;
var progressWin = new ProgressWindow(readyFiles, _settings.MkvMergePath, _settings.OutputFolder, MaxConcurrentStrips) var progressWin = new ProgressWindow(readyFiles, _settings.MkvMergePath, _settings.OutputFolder, MaxConcurrentStrips)
{ {
@@ -541,6 +518,7 @@ public partial class MainWindow : FluentWindow
progressWin.Closed += (_, _) => progressWin.Closed += (_, _) =>
{ {
_isProcessing = false; _isProcessing = false;
ProcessingOverlay.Visibility = Visibility.Collapsed;
if (progressWin.ShouldClearQueue) if (progressWin.ShouldClearQueue)
{ {
foreach (var item in _fileQueue) foreach (var item in _fileQueue)
+8
View File
@@ -3,6 +3,7 @@ using System.Collections.Specialized;
using System.ComponentModel; using System.ComponentModel;
using System.IO; using System.IO;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using Futonizer.Services;
namespace Futonizer.Models; namespace Futonizer.Models;
@@ -32,6 +33,13 @@ public class QueuedFileItem : INotifyPropertyChanged
public string FilePath { get; } public string FilePath { get; }
public string FileName => Path.GetFileName(FilePath); public string FileName => Path.GetFileName(FilePath);
/// <summary>
/// The filename as it will appear after rename adjustments (release-tag prefix
/// and/or show-name injection). Equals <see cref="FileName"/> when no
/// changes would be applied.
/// </summary>
public string DisplayFileName => FileNameHelper.ComputeOutputFileName(FilePath);
public string FileSizeDisplay { get; } public string FileSizeDisplay { get; }
public ObservableCollection<TrackItem> Tracks { get; } = new(); public ObservableCollection<TrackItem> Tracks { get; } = new();
+194
View File
@@ -0,0 +1,194 @@
using System.IO;
using System.Text.RegularExpressions;
namespace Futonizer.Services;
/// <summary>
/// Pure static helpers for computing the final output filename from a source
/// file path, applying release-tag prefixing and show-name injection.
/// </summary>
public static class FileNameHelper
{
// Folder suffix release tag: "Show Name-TTGA" → tag = "TTGA"
// All-uppercase, 2-8 chars, at end of folder name.
private static readonly Regex FolderSuffixTagRegex =
new(@"-([A-Z][A-Z0-9]{1,7})$", RegexOptions.Compiled);
// File suffix release tag: "…HEVC-DemiHuman" → tag = "DemiHuman"
// Mixed case, 3-21 chars (no dots/spaces), at end of filename stem.
// Min 3 chars avoids false-positives like "-v2" or "-HD".
private static readonly Regex FileSuffixTagRegex =
new(@"-([A-Za-z][A-Za-z0-9]{2,20})$", RegexOptions.Compiled);
// Prefix release tag: "[KAA] Show Name" → tag = "KAA"
private static readonly Regex PrefixTagRegex =
new(@"^\[(.+?)\]", RegexOptions.Compiled);
// Episode-only filename (no tag prefix): starts with S01E01, S1E1, etc.
private static readonly Regex EpisodeOnlyRegex =
new(@"^S\d+E\d+", RegexOptions.IgnoreCase | RegexOptions.Compiled);
// Episode start after a tag prefix is stripped: plain number OR S01E01 style.
// e.g. "03 - Deus Vult ..." or "S01E01-Deep Blue"
private static readonly Regex EpisodeStartRegex =
new(@"^(\d+|S\d+E\d+)", RegexOptions.IgnoreCase | RegexOptions.Compiled);
// Individual metadata-token patterns used to find where the show name ends
// inside a folder name.
private static readonly Regex[] MetadataPatterns =
[
new(@"^S\d+$", RegexOptions.IgnoreCase | RegexOptions.Compiled), // S01
new(@"^S\d+E\d+", RegexOptions.IgnoreCase | RegexOptions.Compiled), // S01E01...
new(@"^E[Pp]?\d+$", RegexOptions.IgnoreCase | RegexOptions.Compiled), // E01, EP01
new(@"^\d{3,4}[pP]$", RegexOptions.Compiled), // 1080p, 720p
new(@"^(4K|UHD|2160p)$", RegexOptions.IgnoreCase | RegexOptions.Compiled), // 4K, UHD
new(@"^(BD|BluRay|Blu-Ray|WEB|WEB-DL|WEBRip|HDTV|AMZN|NF|DSNP|HULU|MAX)$",RegexOptions.IgnoreCase | RegexOptions.Compiled), // sources
new(@"^(Remux|Encode)$", RegexOptions.IgnoreCase | RegexOptions.Compiled), // processing
new(@"^(HEVC|AVC|x264|x265|H\.?264|H\.?265|VP9)$", RegexOptions.IgnoreCase | RegexOptions.Compiled), // video codecs
new(@"^(FLAC|AAC|DTS|TrueHD|Atmos|AC3|EAC3|Opus|MP3)$", RegexOptions.IgnoreCase | RegexOptions.Compiled), // audio codecs
new(@"^(HDR|SDR|10bit|8bit|HDR10|DV|DoVi)$", RegexOptions.IgnoreCase | RegexOptions.Compiled), // HDR / bit-depth
];
// -------------------------------------------------------------------------
/// <summary>
/// Computes the final output filename for a given source file path, applying
/// (in order):
/// <list type="number">
/// <item>Filename suffix tag extraction — a trailing <c>-GroupName</c> on
/// the filename stem is stripped and promoted to a bracket prefix.
/// Takes priority over any folder-derived tag.</item>
/// <item>Show-name injection — if the (now tag-free) filename starts with
/// an episode code (e.g. S01E01) the show name is derived from the
/// parent folder and prepended.</item>
/// <item>Release-tag prefix — a <c>[TAG]</c> bracket prefix, sourced from
/// the filename suffix, the folder suffix, or the folder prefix,
/// in that priority order.</item>
/// </list>
/// Returns the original filename unchanged when no transformations apply.
/// </summary>
public static string ComputeOutputFileName(string sourceFilePath)
{
string fileName = Path.GetFileName(sourceFilePath);
string ext = Path.GetExtension(fileName);
string stemNoExt = Path.GetFileNameWithoutExtension(fileName);
string? folder = Path.GetDirectoryName(sourceFilePath);
string folderName = string.IsNullOrEmpty(folder) ? "" : (Path.GetFileName(folder) ?? "");
// 1. Extract in-filename suffix tag and remove it from the stem.
// e.g. "...HEVC-DemiHuman" → tag="DemiHuman", stem="...HEVC"
string? fileTag = null;
var fileSuffixMatch = FileSuffixTagRegex.Match(stemNoExt);
if (fileSuffixMatch.Success)
{
fileTag = fileSuffixMatch.Groups[1].Value;
stemNoExt = stemNoExt[..fileSuffixMatch.Index];
fileName = stemNoExt + ext;
}
// 2. Determine the release tag: filename suffix > folder tag.
string? tag = fileTag;
if (string.IsNullOrEmpty(tag) && !string.IsNullOrEmpty(folderName))
tag = ExtractReleaseTag(folderName);
// 3. Check for episode-only patterns and inject show name if needed.
if (!string.IsNullOrEmpty(folderName))
{
// Pattern A: untagged stem starts with S01E01 (e.g. "S01E01-Deep Blue.mkv")
if (EpisodeOnlyRegex.IsMatch(stemNoExt))
{
string showName = ExtractShowName(folderName);
if (!string.IsNullOrEmpty(showName))
fileName = showName + " " + fileName;
}
// Pattern B: file already carries [TAG] but episode number follows directly.
// e.g. "[WBDP] 03 - Deus Vult ..." → insert show name after the tag.
else if (!string.IsNullOrEmpty(tag))
{
string tagPfx = $"[{tag}] ";
if (stemNoExt.StartsWith(tagPfx, StringComparison.OrdinalIgnoreCase))
{
string afterTag = stemNoExt[tagPfx.Length..];
if (EpisodeStartRegex.IsMatch(afterTag))
{
string showName = ExtractShowName(folderName);
if (!string.IsNullOrEmpty(showName))
{
// Strip the tag, inject show name; tag is re-prepended in step 4.
fileName = showName + " " + fileName[tagPfx.Length..];
}
}
}
}
}
// 4. Prepend release tag if not already present.
if (!string.IsNullOrEmpty(tag))
{
string tagPrefix = $"[{tag}]";
if (!fileName.StartsWith(tagPrefix, StringComparison.OrdinalIgnoreCase))
fileName = tagPrefix + " " + fileName;
}
return fileName;
}
/// <summary>
/// Extracts the release tag string (without brackets) from a folder name.
/// Suffix pattern (<c>-TAG</c>) takes priority over prefix pattern
/// (<c>[TAG]</c>). Returns <c>null</c> when neither is present.
/// </summary>
public static string? ExtractReleaseTag(string folderName)
{
var suffixMatch = FolderSuffixTagRegex.Match(folderName);
if (suffixMatch.Success) return suffixMatch.Groups[1].Value;
var prefixMatch = PrefixTagRegex.Match(folderName);
if (prefixMatch.Success) return prefixMatch.Groups[1].Value;
return null;
}
/// <summary>
/// Derives the show name from a folder name by stripping any release tag
/// (prefix or suffix) and then:
/// <list type="bullet">
/// <item>If the remainder contains brackets (e.g. <c>[BD][1080p-FLAC]</c>),
/// returns the text that precedes the first bracket.</item>
/// <item>Otherwise splits on spaces and collects words up to the first
/// recognised metadata token (season, quality, source, codec, etc.).</item>
/// </list>
/// </summary>
public static string ExtractShowName(string folderName)
{
// Strip release tags first.
string name = FolderSuffixTagRegex.Replace(folderName, "").Trim();
name = PrefixTagRegex.Replace(name, "").Trim();
// Nothing left, or what remains immediately starts with a bracket — no show name.
if (string.IsNullOrEmpty(name) || name[0] == '[') return string.Empty;
// Bracket-style metadata: "The Saga of Tanya the Evil [BD][1080p-FLAC][HEVC]"
int bracketIdx = name.IndexOf('[');
if (bracketIdx > 0)
return name[..bracketIdx].Trim();
// Space-separated metadata: "Grand Blue Dreaming S01 1080p BD Remux FLAC"
var words = name.Split(' ', StringSplitOptions.RemoveEmptyEntries);
var showWords = new List<string>();
foreach (var word in words)
{
if (IsMetadataToken(word)) break;
showWords.Add(word);
}
return string.Join(" ", showWords).Trim();
}
private static bool IsMetadataToken(string token)
{
foreach (var pattern in MetadataPatterns)
if (pattern.IsMatch(token)) return true;
return false;
}
}
+7 -4
View File
@@ -144,7 +144,8 @@ public partial class ProgressWindow : FluentWindow
{ {
await semaphore.WaitAsync(ct); await semaphore.WaitAsync(ct);
var job = new JobProgressItem { FileName = file.FileName, FileSizeBytes = SafeFileLength(file.FilePath) }; string computedFileName = FileNameHelper.ComputeOutputFileName(file.FilePath);
var job = new JobProgressItem { FileName = computedFileName, FileSizeBytes = SafeFileLength(file.FilePath) };
job.PropertyChanged += (_, args) => job.PropertyChanged += (_, args) =>
{ {
if (args.PropertyName == nameof(JobProgressItem.MegabytesPerSecond)) if (args.PropertyName == nameof(JobProgressItem.MegabytesPerSecond))
@@ -157,9 +158,11 @@ public partial class ProgressWindow : FluentWindow
try try
{ {
string sourceDir = Path.GetDirectoryName(file.FilePath) ?? "";
string outputFilePath = overwritingInPlace string outputFilePath = overwritingInPlace
? file.FilePath ? Path.Combine(sourceDir, computedFileName)
: Path.Combine(_outputFolder, file.FileName); : Path.Combine(_outputFolder, computedFileName);
var videoIds = file.Tracks var videoIds = file.Tracks
.Where(t => t.Type == "video" && t.Copy) .Where(t => t.Type == "video" && t.Copy)
@@ -187,7 +190,7 @@ public partial class ProgressWindow : FluentWindow
progress, ct); progress, ct);
string tag = result.Success ? "[DONE]" : "[FAIL]"; string tag = result.Success ? "[DONE]" : "[FAIL]";
AppendLog($"{tag} {result.FileName} — {result.Message}"); AppendLog($"{tag} {Path.GetFileName(result.OutputFilePath)} — {result.Message}");
HistoryService.Add(new HistoryEntry HistoryService.Add(new HistoryEntry
{ {