Import old filename format settings.
This commit is contained in:
5 files changed
+42
-16
No files matched your search
@@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14101" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14105" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<deployment identifier="macosx"/>
|
<deployment identifier="macosx"/>
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14101"/>
|
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14105"/>
|
||||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<objects>
|
<objects>
|
||||||
|
|||||||
@@ -73,9 +73,9 @@ extension MP42File {
|
|||||||
|
|
||||||
private func outputNameFormat(mediaKind: Int) -> [Token]? {
|
private func outputNameFormat(mediaKind: Int) -> [Token]? {
|
||||||
if mediaKind == MetadataResult.MediaKindType.tvShow.rawValue {
|
if mediaKind == MetadataResult.MediaKindType.tvShow.rawValue {
|
||||||
return UserDefaults.standard.tokenArray(forKey: "SBTVShowFormat")
|
return UserDefaults.standard.tokenArray(forKey: "SBTVShowFormatTokens")
|
||||||
} else if mediaKind == MetadataResult.MediaKindType.movie.rawValue {
|
} else if mediaKind == MetadataResult.MediaKindType.movie.rawValue {
|
||||||
return UserDefaults.standard.tokenArray(forKey: "SBMovieFormat")
|
return UserDefaults.standard.tokenArray(forKey: "SBMovieFormatTokens")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,13 +37,13 @@ class OutputPrefsViewController: NSViewController, NSTokenFieldDelegate {
|
|||||||
movieField.tokenizingCharacterSet = CharacterSet(charactersIn: "/")
|
movieField.tokenizingCharacterSet = CharacterSet(charactersIn: "/")
|
||||||
tvShowField.tokenizingCharacterSet = CharacterSet(charactersIn: "/")
|
tvShowField.tokenizingCharacterSet = CharacterSet(charactersIn: "/")
|
||||||
|
|
||||||
movieField.objectValue = UserDefaults.standard.tokenArray(forKey: "SBMovieFormat")
|
movieField.objectValue = UserDefaults.standard.tokenArray(forKey: "SBMovieFormatTokens")
|
||||||
tvShowField.objectValue = UserDefaults.standard.tokenArray(forKey: "SBTVShowFormat")
|
tvShowField.objectValue = UserDefaults.standard.tokenArray(forKey: "SBTVShowFormatTokens")
|
||||||
}
|
}
|
||||||
|
|
||||||
private func save() {
|
private func save() {
|
||||||
UserDefaults.standard.set(movieField.objectValue as! [Token], forKey: "SBMovieFormat")
|
UserDefaults.standard.set(movieField.objectValue as! [Token], forKey: "SBMovieFormatTokens")
|
||||||
UserDefaults.standard.set(tvShowField.objectValue as! [Token], forKey: "SBTVShowFormat")
|
UserDefaults.standard.set(tvShowField.objectValue as! [Token], forKey: "SBTVShowFormatTokens")
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Actions
|
// MARK: Actions
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Cocoa
|
import Cocoa
|
||||||
|
|
||||||
@objc(SBPrefsWindowController) class PrefsWindowController: NSWindowController {
|
class PrefsWindowController: NSWindowController {
|
||||||
|
|
||||||
public class func registerUserDefaults() {
|
public class func registerUserDefaults() {
|
||||||
let defaults = UserDefaults.standard
|
let defaults = UserDefaults.standard
|
||||||
@@ -19,12 +19,26 @@ import Cocoa
|
|||||||
let movieFormat = try? encoder.encode([Token(text: "{Name}")])
|
let movieFormat = try? encoder.encode([Token(text: "{Name}")])
|
||||||
let tvShowFormat = try? encoder.encode([Token(text: "{TV Show}"), Token(text: " s", isPlaceholder: false), Token(text: "{TV Season}"), Token(text: "e", isPlaceholder: false), Token(text: "{TV Episode #}")])
|
let tvShowFormat = try? encoder.encode([Token(text: "{TV Show}"), Token(text: " s", isPlaceholder: false), Token(text: "{TV Season}"), Token(text: "e", isPlaceholder: false), Token(text: "{TV Episode #}")])
|
||||||
|
|
||||||
// Migrate 1.2.9 DTS setting
|
if defaults.integer(forKey: "SBUpgradeCheck") < 1 {
|
||||||
if defaults.object(forKey: "SBAudioKeepDts") != nil {
|
// Migrate 1.2.9 DTS setting
|
||||||
if defaults.bool(forKey: "SBAudioKeepDts") {
|
if defaults.object(forKey: "SBAudioKeepDts") != nil {
|
||||||
defaults.set(2, forKey: "SBAudioDtsOptions")
|
if defaults.bool(forKey: "SBAudioKeepDts") {
|
||||||
|
defaults.set(2, forKey: "SBAudioDtsOptions")
|
||||||
|
}
|
||||||
|
defaults.removeObject(forKey: "SBAudioKeepDts")
|
||||||
}
|
}
|
||||||
defaults.removeObject(forKey: "SBAudioKeepDts")
|
|
||||||
|
// Migrate 1.4.8 filename format settings
|
||||||
|
let oldMovieFormat = defaults.tokenArrayFromOldStylePrefs(forKey: "SBMovieFormat")
|
||||||
|
if oldMovieFormat.isEmpty == false {
|
||||||
|
defaults.set(oldMovieFormat, forKey: "SBMovieFormatTokens")
|
||||||
|
}
|
||||||
|
let oldTvShowFormat = defaults.tokenArrayFromOldStylePrefs(forKey: "SBTVShowFormat")
|
||||||
|
if oldTvShowFormat.isEmpty == false {
|
||||||
|
defaults.set(oldTvShowFormat, forKey: "SBTVShowFormatTokens")
|
||||||
|
}
|
||||||
|
|
||||||
|
defaults.set(1, forKey: "SBUpgradeCheck")
|
||||||
}
|
}
|
||||||
|
|
||||||
let settings: [String: Any] = ["SBSaveFormat": "m4v",
|
let settings: [String: Any] = ["SBSaveFormat": "m4v",
|
||||||
@@ -43,8 +57,8 @@ import Cocoa
|
|||||||
"chaptersPreviewTrack": true,
|
"chaptersPreviewTrack": true,
|
||||||
"SBChaptersPreviewPosition": 0.5,
|
"SBChaptersPreviewPosition": 0.5,
|
||||||
|
|
||||||
"SBMovieFormat": movieFormat ?? "",
|
"SBMovieFormatTokens": movieFormat ?? "",
|
||||||
"SBTVShowFormat": tvShowFormat ?? "",
|
"SBTVShowFormatTokens": tvShowFormat ?? "",
|
||||||
"SBSetMovieFormat": false,
|
"SBSetMovieFormat": false,
|
||||||
"SBSetTVShowFormat": false,
|
"SBSetTVShowFormat": false,
|
||||||
|
|
||||||
|
|||||||
@@ -124,4 +124,16 @@ extension UserDefaults {
|
|||||||
self.set(jsonData, forKey: defaultName)
|
self.set(jsonData, forKey: defaultName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func tokenArrayFromOldStylePrefs(forKey defaultName: String) -> [Token] {
|
||||||
|
guard let strings = UserDefaults.standard.stringArray(forKey: defaultName) else { return [] }
|
||||||
|
var tokens: [Token] = Array()
|
||||||
|
|
||||||
|
for string in strings {
|
||||||
|
let token = Token(text: string, isPlaceholder: string.hasPrefix("{") && string.hasSuffix("}"))
|
||||||
|
tokens.append(token)
|
||||||
|
}
|
||||||
|
|
||||||
|
return tokens
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user