Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
89bba70ee1 | ||
|
|
3903fd475a |
+2
-2
@@ -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.9</Version>
|
<Version>1.0.11</Version>
|
||||||
<FileVersion>1.0.9.0</FileVersion>
|
<FileVersion>1.0.11.0</FileVersion>
|
||||||
<ApplicationIcon>Assets\app.ico</ApplicationIcon>
|
<ApplicationIcon>Assets\app.ico</ApplicationIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -149,6 +149,7 @@
|
|||||||
VirtualizingPanel.ScrollUnit="Pixel"
|
VirtualizingPanel.ScrollUnit="Pixel"
|
||||||
PreviewMouseWheel="SmoothList_PreviewMouseWheel"
|
PreviewMouseWheel="SmoothList_PreviewMouseWheel"
|
||||||
PreviewKeyDown="FileQueueList_PreviewKeyDown"
|
PreviewKeyDown="FileQueueList_PreviewKeyDown"
|
||||||
|
MouseDoubleClick="FileQueueList_MouseDoubleClick"
|
||||||
ItemContainerStyle="{StaticResource QueueListBoxItemStyle}"
|
ItemContainerStyle="{StaticResource QueueListBoxItemStyle}"
|
||||||
SelectionChanged="FileQueueList_SelectionChanged">
|
SelectionChanged="FileQueueList_SelectionChanged">
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
@@ -289,7 +290,7 @@
|
|||||||
GridLinesVisibility="None"
|
GridLinesVisibility="None"
|
||||||
VirtualizingPanel.ScrollUnit="Pixel"
|
VirtualizingPanel.ScrollUnit="Pixel"
|
||||||
PreviewMouseWheel="SmoothList_PreviewMouseWheel"
|
PreviewMouseWheel="SmoothList_PreviewMouseWheel"
|
||||||
PreviewKeyDown="TrackGrid_PreviewKeyDown"
|
MouseDoubleClick="TrackGrid_MouseDoubleClick"
|
||||||
ScrollViewer.HorizontalScrollBarVisibility="Auto"
|
ScrollViewer.HorizontalScrollBarVisibility="Auto"
|
||||||
ScrollViewer.VerticalScrollBarVisibility="Auto">
|
ScrollViewer.VerticalScrollBarVisibility="Auto">
|
||||||
<DataGrid.RowStyle>
|
<DataGrid.RowStyle>
|
||||||
|
|||||||
+28
-9
@@ -519,13 +519,6 @@ public partial class MainWindow : FluentWindow
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void FileQueueList_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
|
private void FileQueueList_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Key == System.Windows.Input.Key.Space)
|
|
||||||
{
|
|
||||||
OpenSelectedFileInDefaultPlayer();
|
|
||||||
e.Handled = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e.Key != System.Windows.Input.Key.Delete) return;
|
if (e.Key != System.Windows.Input.Key.Delete) return;
|
||||||
|
|
||||||
var selected = FileQueueList.SelectedItems.Cast<QueuedFileItem>().ToList();
|
var selected = FileQueueList.SelectedItems.Cast<QueuedFileItem>().ToList();
|
||||||
@@ -545,13 +538,39 @@ 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)
|
private void FileQueueList_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Key != System.Windows.Input.Key.Space) return;
|
|
||||||
OpenSelectedFileInDefaultPlayer();
|
OpenSelectedFileInDefaultPlayer();
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Same as <see cref="FileQueueList_MouseDoubleClick"/>, but for the track
|
||||||
|
/// table. Ignores double-clicks on the "Copy" checkbox column so toggling
|
||||||
|
/// it rapidly doesn't also launch the default player.
|
||||||
|
/// </summary>
|
||||||
|
private void TrackGrid_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.OriginalSource is DependencyObject source && FindAncestor<CheckBox>(source) != null) return;
|
||||||
|
OpenSelectedFileInDefaultPlayer();
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Walks up the visual tree from <paramref name="source"/> looking for an
|
||||||
|
/// ancestor (or the element itself) of type <typeparamref name="T"/>.
|
||||||
|
/// </summary>
|
||||||
|
private static T? FindAncestor<T>(DependencyObject source) where T : DependencyObject
|
||||||
|
{
|
||||||
|
var current = source;
|
||||||
|
while (current != null)
|
||||||
|
{
|
||||||
|
if (current is T typed) return typed;
|
||||||
|
current = System.Windows.Media.VisualTreeHelper.GetParent(current);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private void OpenSelectedFileInDefaultPlayer()
|
private void OpenSelectedFileInDefaultPlayer()
|
||||||
{
|
{
|
||||||
if (FileQueueList.SelectedItem is not QueuedFileItem item) return;
|
if (FileQueueList.SelectedItem is not QueuedFileItem item) return;
|
||||||
|
|||||||
@@ -67,6 +67,19 @@ public static class FileNameHelper
|
|||||||
new(@"^(HDR|SDR|10bit|8bit|HDR10|DV|DoVi)$", RegexOptions.IgnoreCase | RegexOptions.Compiled), // HDR / bit-depth
|
new(@"^(HDR|SDR|10bit|8bit|HDR10|DV|DoVi)$", RegexOptions.IgnoreCase | RegexOptions.Compiled), // HDR / bit-depth
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Whole-phrase fansub/release descriptor patterns, checked against an
|
||||||
|
// entire bracket's contents rather than word-by-word. Catches common
|
||||||
|
// multi-word descriptors (e.g. "Multiple Subtitle", "Dual Audio") whose
|
||||||
|
// individual words wouldn't otherwise match any MetadataPatterns entry,
|
||||||
|
// so they'd be mistaken for a release group name.
|
||||||
|
private static readonly Regex[] DescriptorPhrasePatterns =
|
||||||
|
[
|
||||||
|
new(@"^Multi(ple)?[\s-]?Sub(s|title|titles)?$", RegexOptions.IgnoreCase | RegexOptions.Compiled),
|
||||||
|
new(@"^(Dual|Multi)[\s-]?Audio$", RegexOptions.IgnoreCase | RegexOptions.Compiled),
|
||||||
|
new(@"^(Hard|Soft)[\s-]?sub(s)?$", RegexOptions.IgnoreCase | RegexOptions.Compiled),
|
||||||
|
new(@"^(Uncensored|Censored|Batch|Complete)$", RegexOptions.IgnoreCase | RegexOptions.Compiled),
|
||||||
|
];
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -95,6 +108,12 @@ public static class FileNameHelper
|
|||||||
string? folder = Path.GetDirectoryName(sourceFilePath);
|
string? folder = Path.GetDirectoryName(sourceFilePath);
|
||||||
string folderName = string.IsNullOrEmpty(folder) ? "" : (Path.GetFileName(folder) ?? "");
|
string folderName = string.IsNullOrEmpty(folder) ? "" : (Path.GetFileName(folder) ?? "");
|
||||||
|
|
||||||
|
// Capture the file's own pre-existing bracket prefix (if any) before any
|
||||||
|
// transformation below, so we never stack a second/different tag on top
|
||||||
|
// of a file that already carries its own release-group prefix.
|
||||||
|
var originalPrefixMatch = PrefixTagRegex.Match(stemNoExt);
|
||||||
|
string? originalPrefixTag = originalPrefixMatch.Success ? originalPrefixMatch.Groups[1].Value : null;
|
||||||
|
|
||||||
// 1. Extract in-filename suffix tag and remove it from the stem.
|
// 1. Extract in-filename suffix tag and remove it from the stem.
|
||||||
// e.g. "...x264-DemiHuman" → tag="DemiHuman", stem="...x264"
|
// e.g. "...x264-DemiHuman" → tag="DemiHuman", stem="...x264"
|
||||||
// Only fires when the word right before the dash is itself a
|
// Only fires when the word right before the dash is itself a
|
||||||
@@ -172,13 +191,21 @@ public static class FileNameHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Prepend release tag if not already present.
|
// 4. Prepend release tag if not already present. Skip when the file
|
||||||
|
// already carries its own (different) bracket prefix — never stack
|
||||||
|
// a second tag on top of an existing one.
|
||||||
if (!string.IsNullOrEmpty(tag))
|
if (!string.IsNullOrEmpty(tag))
|
||||||
|
{
|
||||||
|
bool differsFromOriginalTag = originalPrefixTag != null
|
||||||
|
&& !string.Equals(originalPrefixTag, tag, StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
if (!differsFromOriginalTag)
|
||||||
{
|
{
|
||||||
string tagPrefix = $"[{tag}]";
|
string tagPrefix = $"[{tag}]";
|
||||||
if (!fileName.StartsWith(tagPrefix, StringComparison.OrdinalIgnoreCase))
|
if (!fileName.StartsWith(tagPrefix, StringComparison.OrdinalIgnoreCase))
|
||||||
fileName = tagPrefix + " " + fileName;
|
fileName = tagPrefix + " " + fileName;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
@@ -258,7 +285,10 @@ public static class FileNameHelper
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private static bool IsMetadataBracket(string content)
|
private static bool IsMetadataBracket(string content)
|
||||||
{
|
{
|
||||||
var parts = content.Split(new[] { ' ', '-' }, StringSplitOptions.RemoveEmptyEntries);
|
string trimmed = content.Trim();
|
||||||
|
if (DescriptorPhrasePatterns.Any(p => p.IsMatch(trimmed))) return true;
|
||||||
|
|
||||||
|
var parts = trimmed.Split(new[] { ' ', '-' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
return parts.Length > 0 && parts.All(IsMetadataToken);
|
return parts.Length > 0 && parts.All(IsMetadataToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user