Load .sup sidecars in the queue's external-subtitle scan

QueueSubtitlesAction now also claims adjacent .sup files: MP42VobSubImporter
turns them into VobSub tracks just like dragging the file onto the window,
and the action mirrors that path's default — tx3g when
Prefs.subtitleConvertBitmap asks for it, subp passthrough otherwise.
Matroska items skip .sup, matching the remuxer's srt/ssa/ass-only addition
gate and the window's matroskaSubtitleExtensions list. Track→importer
ownership is strong, so the sup importer and its temp idx/sub pair survive
from the pre-action through the item's write.

Stamp the fork version 1.9.5mkv3.

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
Scott GarrettandClaude Code committed 2026-12-03 01:13:29 -05:00
1 parent ddf13e5a3a
commit 2a5f9968da
4 files changed
+28 -11

No files matched your search

+17 -5
View File
@@ -71,7 +71,7 @@ class QueueSetOutputFilenameAction: NSObject, QueueActionProtocol {
static var supportsSecureCoding: Bool { return true }
}
/// An action that search in the item source directory for additionals srt subtitles.
/// An action that search in the item source directory for additionals srt/ass/ssa and sup subtitles.
class QueueSubtitlesAction : NSObject, QueueActionProtocol {
var type: QueueActionType { return .pre }
@@ -80,13 +80,19 @@ class QueueSubtitlesAction : NSObject, QueueActionProtocol {
override init() {}
private func loadExternalSubtitles(url: URL) -> [MP42FileImporter] {
private func loadExternalSubtitles(url: URL, allowBitmap: Bool) -> [MP42FileImporter] {
let movieFilename = url.deletingPathExtension().lastPathComponent
var importers: [MP42FileImporter] = []
if let contents = try? FileManager.default.contentsOfDirectory(at: url.deletingLastPathComponent(), includingPropertiesForKeys: nil, options: [.skipsSubdirectoryDescendants, .skipsHiddenFiles, .skipsPackageDescendants]) {
for url in contents {
let ext = url.pathExtension.lowercased()
if ext == "srt" || ext == "ass" || ext == "ssa" {
// A .sup is claimed by MP42VobSubImporter (sup2vob → VobSub
// track), exactly like dragging the file onto the window.
// Matroska items must skip it: the remuxer only adds
// S_TEXT/UTF8 tracks, so it stays out of the window's
// matroskaSubtitleExtensions list too.
let isBitmap = (ext == "sup" && allowBitmap)
if ext == "srt" || ext == "ass" || ext == "ssa" || isBitmap {
let subtitleFilename = url.deletingPathExtension().lastPathComponent
if movieFilename.count <= subtitleFilename.count &&
subtitleFilename.hasPrefix(movieFilename) {
@@ -102,7 +108,7 @@ class QueueSubtitlesAction : NSObject, QueueActionProtocol {
}
func runAction(_ item: QueueItem) -> Bool {
let subtitlesImporters = loadExternalSubtitles(url: item.fileURL)
let subtitlesImporters = loadExternalSubtitles(url: item.fileURL, allowBitmap: item.isMatroska == false)
for importer in subtitlesImporters {
for track in importer.tracks {
@@ -111,7 +117,13 @@ class QueueSubtitlesAction : NSObject, QueueActionProtocol {
// the MP4 path converts text subs to tx3g at mux time; a
// Matroska remux ignores the settings and re-parses the text
// from track.URL as S_TEXT/UTF8 instead.
if trackNeedConversion(track.format), let subtitleTrack = track as? MP42SubtitleTrack {
// A .sup surfaces as a VobSub track, which needs no
// conversion; mimic the drop-on-window default (same rule as
// QueueItem.configureSubtitles): tx3g only when the user's
// bitmap-subtitles preference asks for it, else mux the
// bitmap track as-is (subp).
let convertBitmapToTx3g = track.format == kMP42SubtitleCodecType_VobSub && Prefs.subtitleConvertBitmap
if (trackNeedConversion(track.format) || convertBitmapToTx3g), let subtitleTrack = track as? MP42SubtitleTrack {
subtitleTrack.conversionSettings = MP42ConversionSettings.subtitlesConversion()
}
item.mp4File?.addTrack(track)