Add SBQueueSetOutputFilenameAction action.
This commit is contained in:
6 files changed
+82
-30
No files matched your search
@@ -7,6 +7,14 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
private extension String {
|
||||
func condensingWhitespace() -> String {
|
||||
return self.components(separatedBy: .whitespacesAndNewlines)
|
||||
.filter { !$0.isEmpty }
|
||||
.joined(separator: " ")
|
||||
}
|
||||
}
|
||||
|
||||
extension MP42File {
|
||||
|
||||
enum TrackHDType : Int {
|
||||
@@ -95,6 +103,8 @@ extension MP42File {
|
||||
}
|
||||
}
|
||||
|
||||
name = name.trimmingCharacters(in: CharacterSet(charactersIn: ":/")).condensingWhitespace()
|
||||
|
||||
return name.isEmpty ? nil : name
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,27 @@ import Foundation
|
||||
// @objc var localizedDescription: String { get }
|
||||
//}
|
||||
|
||||
/// An action that set a formatted file name.
|
||||
@objc(SBQueueSetOutputFilenameAction) class QueueSetOutputFilenameAction: NSObject, SBQueueActionProtocol {
|
||||
|
||||
var localizedDescription: String { return NSLocalizedString("Setting Name", comment: "Action localized description.") }
|
||||
override var description: String { return NSLocalizedString("Set Name", comment: "Action description.") }
|
||||
|
||||
@objc override init() {}
|
||||
|
||||
func runAction(_ item: SBQueueItem) {
|
||||
if let formattedName = item.mp4File?.formattedFileName() {
|
||||
let pathExtension = item.destURL.pathExtension
|
||||
let destURL = item.destURL.deletingLastPathComponent().appendingPathComponent(formattedName).appendingPathExtension(pathExtension)
|
||||
item.destURL = destURL
|
||||
}
|
||||
}
|
||||
|
||||
func encode(with aCoder: NSCoder) {}
|
||||
required init?(coder aDecoder: NSCoder) {}
|
||||
static var supportsSecureCoding: Bool { return true }
|
||||
}
|
||||
|
||||
/// An action that search in the item source directory for additionals srt subtitles.
|
||||
@objc(SBQueueSubtitlesAction) class QueueSubtitlesAction : NSObject, SBQueueActionProtocol {
|
||||
|
||||
|
||||
@@ -263,6 +263,10 @@ static void *SBQueueContex = &SBQueueContex;
|
||||
preferredArtwork:[self.options[SBQueueProviderArtwork] unsignedIntegerValue]]];
|
||||
}
|
||||
|
||||
if ([(self.options)[SBQueueSetOutputFilename] boolValue]) {
|
||||
[item addAction:[[SBQueueSetOutputFilenameAction alloc] init]];
|
||||
}
|
||||
|
||||
if ([(self.options)[SBQueueSubtitles] boolValue]) {
|
||||
[item addAction:[[SBQueueSubtitlesAction alloc] init]];
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ extern NSString * const SBQueueMovieProviderLanguage;
|
||||
extern NSString * const SBQueueTVShowProviderLanguage;
|
||||
extern NSString * const SBQueueProviderArtwork;
|
||||
|
||||
extern NSString * const SBQueueSetOutputFilename;
|
||||
extern NSString * const SBQueueDestination;
|
||||
|
||||
@interface SBQueuePreferences : NSObject
|
||||
|
||||
@@ -37,6 +37,7 @@ NSString * const SBQueueTVShowProviderLanguage = @"SBQueueTVShowProviderLanguage
|
||||
NSString * const SBQueueProviderArtwork = @"SBQueueProviderArtwork";
|
||||
|
||||
NSString * const SBQueueSet = @"SBQueueSet";
|
||||
NSString * const SBQueueSetOutputFilename = @"SBQueueSetOutputFilename";
|
||||
|
||||
@implementation SBQueuePreferences
|
||||
|
||||
@@ -45,7 +46,7 @@ NSString * const SBQueueSet = @"SBQueueSet";
|
||||
if (self) {
|
||||
_options = [[NSMutableDictionary alloc] init];
|
||||
|
||||
NSArray *keys = @[SBQueueFileType, SBQueueOrganize, SBQueueFixTrackLanguage, SBQueueFixTrackLanguageValue, SBQueueApplyColorSpace, SBQueueApplyColorSpaceValue, SBQueueFixFallbacks, SBQueueClearTrackName, SBQueueMetadata, SBQueueSubtitles, SBQueueAutoStart, SBQueueOptimize, SBQueueShowDoneNotification, SBQueueMovieProvider, SBQueueTVShowProvider, SBQueueMovieProviderLanguage, SBQueueTVShowProviderLanguage, SBQueueProviderArtwork];
|
||||
NSArray<NSString *> *keys = @[SBQueueFileType, SBQueueOrganize, SBQueueFixTrackLanguage, SBQueueFixTrackLanguageValue, SBQueueApplyColorSpace, SBQueueApplyColorSpaceValue, SBQueueFixFallbacks, SBQueueClearTrackName, SBQueueMetadata, SBQueueSubtitles, SBQueueAutoStart, SBQueueOptimize, SBQueueShowDoneNotification, SBQueueMovieProvider, SBQueueTVShowProvider, SBQueueMovieProviderLanguage, SBQueueTVShowProviderLanguage, SBQueueProviderArtwork, SBQueueSetOutputFilename];
|
||||
|
||||
[keys enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||
self.options[obj] = [[NSUserDefaults standardUserDefaults] valueForKey:obj];
|
||||
@@ -84,6 +85,8 @@ NSString * const SBQueueSet = @"SBQueueSet";
|
||||
SBQueueApplyColorSpace: @NO,
|
||||
SBQueueApplyColorSpaceValue: @1,
|
||||
|
||||
SBQueueSetOutputFilename: @NO,
|
||||
|
||||
SBQueueAutoStart: @NO,
|
||||
SBQueueOptimize : @YES,
|
||||
SBQueueShowDoneNotification: @YES,
|
||||
@@ -99,7 +102,7 @@ NSString * const SBQueueSet = @"SBQueueSet";
|
||||
* Save the queue user defaults
|
||||
*/
|
||||
- (void)saveUserDefaults {
|
||||
NSArray<NSString *> *keys = @[SBQueueFileType, SBQueueOrganize, SBQueueFixTrackLanguage, SBQueueFixTrackLanguageValue, SBQueueApplyColorSpace, SBQueueApplyColorSpaceValue, SBQueueFixFallbacks, SBQueueClearTrackName, SBQueueMetadata, SBQueueSubtitles, SBQueueAutoStart, SBQueueShowDoneNotification, SBQueueOptimize, SBQueueMovieProvider, SBQueueTVShowProvider, SBQueueMovieProviderLanguage, SBQueueTVShowProviderLanguage, SBQueueProviderArtwork];
|
||||
NSArray<NSString *> *keys = @[SBQueueFileType, SBQueueOrganize, SBQueueFixTrackLanguage, SBQueueFixTrackLanguageValue, SBQueueApplyColorSpace, SBQueueApplyColorSpaceValue, SBQueueFixFallbacks, SBQueueClearTrackName, SBQueueMetadata, SBQueueSubtitles, SBQueueAutoStart, SBQueueShowDoneNotification, SBQueueOptimize, SBQueueMovieProvider, SBQueueTVShowProvider, SBQueueMovieProviderLanguage, SBQueueTVShowProviderLanguage, SBQueueProviderArtwork, SBQueueSetOutputFilename];
|
||||
|
||||
[keys enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||
[[NSUserDefaults standardUserDefaults] setValue:self.options[obj] forKey:obj];
|
||||
|
||||
Reference in new issue
Block a user