Add an action to clear existing metadata.
This commit is contained in:
6 files changed
+62
-13
No files matched your search
+27
-10
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13771" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14092" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13771"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14092"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
@@ -15,7 +15,7 @@
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customView id="UlG-O3-eNc" userLabel="OptionsView">
|
||||
<rect key="frame" x="0.0" y="0.0" width="370" height="455"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="370" height="475"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<subviews>
|
||||
<button translatesAutoresizingMaskIntoConstraints="NO" id="zEH-aV-Tl7">
|
||||
@@ -32,14 +32,14 @@
|
||||
</binding>
|
||||
</connections>
|
||||
</button>
|
||||
<button toolTip="Search metadata online" translatesAutoresizingMaskIntoConstraints="NO" id="9GN-f6-r2j">
|
||||
<rect key="frame" x="110" y="429" width="105" height="18"/>
|
||||
<buttonCell key="cell" type="check" title="Fetch Metadata" bezelStyle="regularSquare" imagePosition="left" alignment="left" controlSize="small" state="on" inset="2" id="QNO-e1-WUJ">
|
||||
<button toolTip="Clear existing metadata" translatesAutoresizingMaskIntoConstraints="NO" id="9GN-f6-r2j">
|
||||
<rect key="frame" x="110" y="449" width="146" height="18"/>
|
||||
<buttonCell key="cell" type="check" title="Clear existing metadata" bezelStyle="regularSquare" imagePosition="left" alignment="left" controlSize="small" state="on" inset="2" id="QNO-e1-WUJ">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<binding destination="-2" name="value" keyPath="self.options.SBQueueMetadata" id="Erf-Bt-RUk">
|
||||
<binding destination="-2" name="value" keyPath="self.options.SBQueueClearExistingMetadata" id="3Vo-7M-Ssk">
|
||||
<dictionary key="options">
|
||||
<bool key="NSValidatesImmediately" value="YES"/>
|
||||
</dictionary>
|
||||
@@ -188,7 +188,7 @@
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="200" translatesAutoresizingMaskIntoConstraints="NO" id="S7L-mA-j3Y">
|
||||
<rect key="frame" x="18" y="431" width="89" height="14"/>
|
||||
<rect key="frame" x="18" y="451" width="89" height="14"/>
|
||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Add item:" id="9ls-xq-YGz">
|
||||
<font key="font" metaFont="smallSystemBold"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
@@ -546,6 +546,20 @@
|
||||
<binding destination="-2" name="value" keyPath="self.options.SBQueueSetOutputFilename" id="G0N-Gp-AQS"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button toolTip="Search metadata online" translatesAutoresizingMaskIntoConstraints="NO" id="s8r-Cf-VfB">
|
||||
<rect key="frame" x="110" y="431" width="105" height="18"/>
|
||||
<buttonCell key="cell" type="check" title="Fetch Metadata" bezelStyle="regularSquare" imagePosition="left" alignment="left" controlSize="small" state="on" inset="2" id="h5x-un-6cJ">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<binding destination="-2" name="value" keyPath="self.options.SBQueueMetadata" id="YHZ-ap-mNu">
|
||||
<dictionary key="options">
|
||||
<bool key="NSValidatesImmediately" value="YES"/>
|
||||
</dictionary>
|
||||
</binding>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="slL-2h-MPl" secondAttribute="trailing" constant="20" id="0EO-hK-q5e"/>
|
||||
@@ -557,6 +571,7 @@
|
||||
<constraint firstItem="s2g-Iz-52P" firstAttribute="top" secondItem="Pdq-s0-erT" secondAttribute="bottom" constant="4" id="5h8-Fg-jnN"/>
|
||||
<constraint firstItem="Ns9-7q-hsh" firstAttribute="leading" secondItem="bDo-OD-bck" secondAttribute="leading" id="5sA-0F-meJ"/>
|
||||
<constraint firstItem="muY-E0-hVI" firstAttribute="width" secondItem="vJ5-JB-k1m" secondAttribute="width" id="5tG-uE-aeE"/>
|
||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="s8r-Cf-VfB" secondAttribute="trailing" constant="20" id="63n-0D-Pbl"/>
|
||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="5rh-cM-iOg" secondAttribute="trailing" priority="750" constant="20" id="7Da-zR-5Y7"/>
|
||||
<constraint firstItem="ZVm-yi-3cE" firstAttribute="leading" secondItem="eTL-yP-QQ5" secondAttribute="trailing" constant="8" id="7T2-6l-HYr"/>
|
||||
<constraint firstItem="NhN-Lg-awX" firstAttribute="baseline" secondItem="DVM-Js-DwK" secondAttribute="baseline" id="8Cp-6o-kA4"/>
|
||||
@@ -610,6 +625,7 @@
|
||||
<constraint firstItem="s2g-Iz-52P" firstAttribute="baseline" secondItem="2Hf-2V-95U" secondAttribute="baseline" id="dUG-gL-yak"/>
|
||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="etc-K7-Atw" secondAttribute="trailing" constant="20" id="dkQ-8f-2fd"/>
|
||||
<constraint firstItem="08Q-2k-0Gb" firstAttribute="baseline" secondItem="Ns9-7q-hsh" secondAttribute="baseline" id="fG1-Oh-vZ3"/>
|
||||
<constraint firstItem="s8r-Cf-VfB" firstAttribute="top" secondItem="9GN-f6-r2j" secondAttribute="bottom" constant="6" id="fmf-zf-q4j"/>
|
||||
<constraint firstItem="TV6-Sk-Bqr" firstAttribute="leading" secondItem="ccd-Xn-Dj3" secondAttribute="leading" id="hnH-5m-uQi"/>
|
||||
<constraint firstItem="TV6-Sk-Bqr" firstAttribute="top" secondItem="ccd-Xn-Dj3" secondAttribute="bottom" constant="6" id="i86-G2-ukZ"/>
|
||||
<constraint firstItem="5rh-cM-iOg" firstAttribute="top" secondItem="ZVm-yi-3cE" secondAttribute="bottom" constant="4" id="iUq-0X-QIX"/>
|
||||
@@ -619,6 +635,7 @@
|
||||
<constraint firstItem="BWL-Nn-iGH" firstAttribute="leading" secondItem="bDo-OD-bck" secondAttribute="leading" constant="10" id="jVz-7g-q3T"/>
|
||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="Ce4-O7-Iu4" secondAttribute="trailing" constant="20" id="kcg-1f-F0u"/>
|
||||
<constraint firstItem="bDo-OD-bck" firstAttribute="leading" secondItem="eTL-yP-QQ5" secondAttribute="leading" id="lFc-KN-zLO"/>
|
||||
<constraint firstItem="ZVm-yi-3cE" firstAttribute="top" secondItem="s8r-Cf-VfB" secondAttribute="bottom" constant="8" id="lfE-fa-WVU"/>
|
||||
<constraint firstItem="Pdq-s0-erT" firstAttribute="leading" secondItem="etc-K7-Atw" secondAttribute="leading" id="ln6-S1-2dI"/>
|
||||
<constraint firstItem="KWg-Ak-bB6" firstAttribute="width" secondItem="86l-GG-SpO" secondAttribute="width" id="ls4-Ue-l3L"/>
|
||||
<constraint firstItem="ZZk-4j-Ji7" firstAttribute="leading" secondItem="swT-iM-shZ" secondAttribute="trailing" constant="9" id="mGV-1D-BO3"/>
|
||||
@@ -634,7 +651,7 @@
|
||||
<constraint firstItem="ZZk-4j-Ji7" firstAttribute="baseline" secondItem="swT-iM-shZ" secondAttribute="baseline" id="prq-pC-1Vf"/>
|
||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="86l-GG-SpO" secondAttribute="trailing" constant="20" id="qRH-fx-yda"/>
|
||||
<constraint firstItem="5rh-cM-iOg" firstAttribute="leading" secondItem="73q-gi-fe2" secondAttribute="trailing" constant="8" id="r5f-g8-Pns"/>
|
||||
<constraint firstItem="eTL-yP-QQ5" firstAttribute="top" secondItem="9GN-f6-r2j" secondAttribute="bottom" constant="8" id="rfs-O9-wMC"/>
|
||||
<constraint firstItem="s8r-Cf-VfB" firstAttribute="leading" secondItem="9GN-f6-r2j" secondAttribute="leading" id="r6R-Dz-3iB"/>
|
||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="08Q-2k-0Gb" secondAttribute="trailing" constant="54" id="rwm-CD-0kE"/>
|
||||
<constraint firstItem="2Hf-2V-95U" firstAttribute="leading" secondItem="Pdq-s0-erT" secondAttribute="leading" constant="22" id="scm-66-i3p"/>
|
||||
<constraint firstItem="MGZ-hB-jhx" firstAttribute="baseline" secondItem="Uoo-hZ-D1f" secondAttribute="baseline" id="tXr-4J-GsO"/>
|
||||
@@ -645,7 +662,7 @@
|
||||
<constraint firstItem="zEH-aV-Tl7" firstAttribute="top" secondItem="yI9-2a-q2a" secondAttribute="bottom" constant="6" id="yi7-mU-teZ"/>
|
||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="ccd-Xn-Dj3" secondAttribute="trailing" constant="20" id="zrg-ax-2rw"/>
|
||||
</constraints>
|
||||
<point key="canvasLocation" x="-182" y="64.5"/>
|
||||
<point key="canvasLocation" x="-182" y="74"/>
|
||||
</customView>
|
||||
<arrayController objectClassName="Preset" automaticallyPreparesContent="YES" id="vyv-na-Xpo" userLabel="Set Controller">
|
||||
<declaredKeys>
|
||||
|
||||
@@ -13,6 +13,27 @@ import Foundation
|
||||
// @objc var localizedDescription: String { get }
|
||||
//}
|
||||
|
||||
/// An action to remove existing metadata.
|
||||
@objc(SBQueueClearExistingMetadataAction) class QueueClearExistingMetadataAction: NSObject, SBQueueActionProtocol {
|
||||
|
||||
var localizedDescription: String { return NSLocalizedString("Clearing Metadata", comment: "Action localized description.") }
|
||||
override var description: String { return NSLocalizedString("Clear Metadata", comment: "Action description.") }
|
||||
|
||||
@objc override init() {}
|
||||
|
||||
func runAction(_ item: SBQueueItem) {
|
||||
if let metadata = item.mp4File?.metadata {
|
||||
let dataTypes: UInt = MP42MetadataItemDataType.string.rawValue | MP42MetadataItemDataType.stringArray.rawValue | MP42MetadataItemDataType.bool.rawValue | MP42MetadataItemDataType.integer.rawValue | MP42MetadataItemDataType.integerArray.rawValue | MP42MetadataItemDataType.date.rawValue | MP42MetadataItemDataType.image.rawValue
|
||||
|
||||
metadata.removeItems(metadata.metadataItemsFiltered(by: MP42MetadataItemDataType(rawValue: dataTypes)))
|
||||
}
|
||||
}
|
||||
|
||||
func encode(with aCoder: NSCoder) {}
|
||||
required init?(coder aDecoder: NSCoder) {}
|
||||
static var supportsSecureCoding: Bool { return true }
|
||||
}
|
||||
|
||||
/// An action that set a formatted file name.
|
||||
@objc(SBQueueSetOutputFilenameAction) class QueueSetOutputFilenameAction: NSObject, SBQueueActionProtocol {
|
||||
|
||||
|
||||
@@ -252,6 +252,10 @@ static void *SBQueueContex = &SBQueueContex;
|
||||
- (SBQueueItem *)createItemWithURL:(NSURL *)url {
|
||||
SBQueueItem *item = [SBQueueItem itemWithURL:url];
|
||||
|
||||
if ([self.options[SBQueueClearExistingMetadata] boolValue]) {
|
||||
[item addAction:[[SBQueueClearExistingMetadataAction alloc] init]];
|
||||
}
|
||||
|
||||
if ([(self.options)[SBQueueMetadata] boolValue]) {
|
||||
[item addAction:[[SBQueueMetadataAction alloc] initWithMovieLanguage:self.options[SBQueueMovieProviderLanguage]
|
||||
tvShowLanguage:self.options[SBQueueTVShowProviderLanguage]
|
||||
|
||||
@@ -459,7 +459,8 @@ bail:
|
||||
[SBQueueMetadataAction class], [SBQueueSubtitlesAction class],
|
||||
[SBQueueSetLanguageAction class], [SBQueueFixFallbacksAction class],
|
||||
[SBQueueClearTrackNameAction class], [SBQueueOrganizeGroupsAction class],
|
||||
[SBQueueColorSpaceAction class], [SBQueueSetOutputFilenameAction class], nil]
|
||||
[SBQueueColorSpaceAction class], [SBQueueSetOutputFilenameAction class],
|
||||
[SBQueueClearExistingMetadataAction class], nil]
|
||||
forKey:@"SBQueueItemActions"];
|
||||
|
||||
_status = [decoder decodeIntForKey:@"SBQueueItemStatus"];
|
||||
|
||||
@@ -28,6 +28,8 @@ extern NSString * const SBQueueFixTrackLanguageValue;
|
||||
extern NSString * const SBQueueApplyColorSpace;
|
||||
extern NSString * const SBQueueApplyColorSpaceValue;
|
||||
|
||||
extern NSString * const SBQueueClearExistingMetadata;
|
||||
|
||||
extern NSString * const SBQueueMovieProvider;
|
||||
extern NSString * const SBQueueTVShowProvider;
|
||||
extern NSString * const SBQueueMovieProviderLanguage;
|
||||
|
||||
@@ -30,6 +30,8 @@ NSString * const SBQueueApplyColorSpaceValue = @"SBQueueApplyColorSpaceValue";
|
||||
|
||||
NSString * const SBQueueDestination = @"SBQueueDestination";
|
||||
|
||||
NSString * const SBQueueClearExistingMetadata = @"SBQueueClearExistingMetadata";
|
||||
|
||||
NSString * const SBQueueMovieProvider = @"SBQueueMovieProvider";
|
||||
NSString * const SBQueueTVShowProvider = @"SBQueueTVShowProvider";
|
||||
NSString * const SBQueueMovieProviderLanguage = @"SBQueueMovieProviderLanguage";
|
||||
@@ -46,7 +48,7 @@ NSString * const SBQueueSetOutputFilename = @"SBQueueSetOutputFilename";
|
||||
if (self) {
|
||||
_options = [[NSMutableDictionary alloc] init];
|
||||
|
||||
NSArray<NSString *> *keys = @[SBQueueFileType, SBQueueOrganize, SBQueueFixTrackLanguage, SBQueueFixTrackLanguageValue, SBQueueApplyColorSpace, SBQueueApplyColorSpaceValue, SBQueueFixFallbacks, SBQueueClearTrackName, SBQueueMetadata, SBQueueSubtitles, SBQueueAutoStart, SBQueueOptimize, SBQueueShowDoneNotification, SBQueueMovieProvider, SBQueueTVShowProvider, SBQueueMovieProviderLanguage, SBQueueTVShowProviderLanguage, SBQueueProviderArtwork, SBQueueSetOutputFilename];
|
||||
NSArray<NSString *> *keys = @[SBQueueFileType, SBQueueOrganize, SBQueueFixTrackLanguage, SBQueueFixTrackLanguageValue, SBQueueApplyColorSpace, SBQueueApplyColorSpaceValue, SBQueueFixFallbacks, SBQueueClearTrackName, SBQueueMetadata, SBQueueSubtitles, SBQueueAutoStart, SBQueueOptimize, SBQueueShowDoneNotification, SBQueueMovieProvider, SBQueueTVShowProvider, SBQueueMovieProviderLanguage, SBQueueTVShowProviderLanguage, SBQueueProviderArtwork, SBQueueSetOutputFilename, SBQueueClearExistingMetadata];
|
||||
|
||||
[keys enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||
self.options[obj] = [[NSUserDefaults standardUserDefaults] valueForKey:obj];
|
||||
@@ -91,6 +93,8 @@ NSString * const SBQueueSetOutputFilename = @"SBQueueSetOutputFilename";
|
||||
SBQueueOptimize : @YES,
|
||||
SBQueueShowDoneNotification: @YES,
|
||||
|
||||
SBQueueClearExistingMetadata: @NO,
|
||||
|
||||
SBQueueMovieProvider : @"TheMovieDB",
|
||||
SBQueueTVShowProvider : @"TheTVDB",
|
||||
SBQueueMovieProviderLanguage : @"en",
|
||||
@@ -102,7 +106,7 @@ NSString * const SBQueueSetOutputFilename = @"SBQueueSetOutputFilename";
|
||||
* 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, SBQueueSetOutputFilename];
|
||||
NSArray<NSString *> *keys = @[SBQueueFileType, SBQueueOrganize, SBQueueFixTrackLanguage, SBQueueFixTrackLanguageValue, SBQueueApplyColorSpace, SBQueueApplyColorSpaceValue, SBQueueFixFallbacks, SBQueueClearTrackName, SBQueueMetadata, SBQueueSubtitles, SBQueueAutoStart, SBQueueShowDoneNotification, SBQueueOptimize, SBQueueMovieProvider, SBQueueTVShowProvider, SBQueueMovieProviderLanguage, SBQueueTVShowProviderLanguage, SBQueueProviderArtwork, SBQueueSetOutputFilename, SBQueueClearExistingMetadata];
|
||||
|
||||
[keys enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||
[[NSUserDefaults standardUserDefaults] setValue:self.options[obj] forKey:obj];
|
||||
|
||||
Reference in new issue
Block a user