Convert SBMetadataResult to Swift.
This commit is contained in:
1 parent
aa20d18ded
commit
422e1c9853
28 files changed
+855
-1143
No files matched your search
+18
-15
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="16D25a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13168.3" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13168.3"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
@@ -113,7 +113,7 @@
|
||||
<accessibilityConnection property="title" destination="vJ5-JB-k1m" id="D3Y-SD-Lcc"/>
|
||||
</connections>
|
||||
</popUpButton>
|
||||
<textField verticalHuggingPriority="750" preferredMaxLayoutWidth="200" translatesAutoresizingMaskIntoConstraints="NO" id="vJ5-JB-k1m">
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="200" translatesAutoresizingMaskIntoConstraints="NO" id="vJ5-JB-k1m">
|
||||
<rect key="frame" x="111" y="102" width="62" height="14"/>
|
||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Location:" id="17e-9u-rVn">
|
||||
<font key="font" metaFont="smallSystemBold"/>
|
||||
@@ -141,7 +141,7 @@
|
||||
<binding destination="-2" name="selectedValue" keyPath="self.options.SBQueueFileType" id="abl-Kk-Yhw"/>
|
||||
</connections>
|
||||
</popUpButton>
|
||||
<textField verticalHuggingPriority="750" preferredMaxLayoutWidth="200" translatesAutoresizingMaskIntoConstraints="NO" id="muY-E0-hVI">
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="200" translatesAutoresizingMaskIntoConstraints="NO" id="muY-E0-hVI">
|
||||
<rect key="frame" x="111" y="82" width="62" height="14"/>
|
||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="File Type:" id="UbR-KJ-8iR">
|
||||
<font key="font" metaFont="smallSystemBold"/>
|
||||
@@ -149,7 +149,7 @@
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField verticalHuggingPriority="750" preferredMaxLayoutWidth="200" translatesAutoresizingMaskIntoConstraints="NO" id="NhN-Lg-awX">
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="200" translatesAutoresizingMaskIntoConstraints="NO" id="NhN-Lg-awX">
|
||||
<rect key="frame" x="111" y="121" width="62" height="14"/>
|
||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Apply Set:" id="9gt-mI-zIV">
|
||||
<font key="font" metaFont="smallSystemBold"/>
|
||||
@@ -157,7 +157,7 @@
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField verticalHuggingPriority="750" preferredMaxLayoutWidth="200" translatesAutoresizingMaskIntoConstraints="NO" id="eTL-yP-QQ5">
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="200" translatesAutoresizingMaskIntoConstraints="NO" id="eTL-yP-QQ5">
|
||||
<rect key="frame" x="123" y="402" width="48" height="14"/>
|
||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Movies:" id="W6m-cd-JMe">
|
||||
<font key="font" metaFont="smallSystemBold"/>
|
||||
@@ -168,7 +168,7 @@
|
||||
<binding destination="-2" name="enabled" keyPath="self.options.SBQueueMetadata" id="2eU-MV-o1B"/>
|
||||
</connections>
|
||||
</textField>
|
||||
<textField verticalHuggingPriority="750" preferredMaxLayoutWidth="200" translatesAutoresizingMaskIntoConstraints="NO" id="bDo-OD-bck">
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="200" translatesAutoresizingMaskIntoConstraints="NO" id="bDo-OD-bck">
|
||||
<rect key="frame" x="123" y="356" width="63" height="14"/>
|
||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="TV Shows:" id="PCe-Pw-D2s">
|
||||
<font key="font" metaFont="smallSystemBold"/>
|
||||
@@ -179,7 +179,7 @@
|
||||
<binding destination="-2" name="enabled" keyPath="self.options.SBQueueMetadata" id="Xd6-EH-Zdj"/>
|
||||
</connections>
|
||||
</textField>
|
||||
<textField verticalHuggingPriority="750" preferredMaxLayoutWidth="250" translatesAutoresizingMaskIntoConstraints="NO" id="Uoo-hZ-D1f">
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="250" translatesAutoresizingMaskIntoConstraints="NO" id="Uoo-hZ-D1f">
|
||||
<rect key="frame" x="18" y="45" width="89" height="14"/>
|
||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Global options:" id="NBN-VA-pg2">
|
||||
<font key="font" metaFont="smallSystemBold"/>
|
||||
@@ -187,7 +187,7 @@
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField verticalHuggingPriority="750" preferredMaxLayoutWidth="200" translatesAutoresizingMaskIntoConstraints="NO" id="S7L-mA-j3Y">
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="200" translatesAutoresizingMaskIntoConstraints="NO" id="S7L-mA-j3Y">
|
||||
<rect key="frame" x="18" y="423" 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"/>
|
||||
@@ -275,7 +275,7 @@
|
||||
</binding>
|
||||
</connections>
|
||||
</popUpButton>
|
||||
<textField verticalHuggingPriority="750" preferredMaxLayoutWidth="200" translatesAutoresizingMaskIntoConstraints="NO" id="BWL-Nn-iGH">
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="200" translatesAutoresizingMaskIntoConstraints="NO" id="BWL-Nn-iGH">
|
||||
<rect key="frame" x="133" y="336" width="63" height="14"/>
|
||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Language:" id="1dC-y4-0rx">
|
||||
<font key="font" metaFont="smallSystemBold"/>
|
||||
@@ -286,7 +286,7 @@
|
||||
<binding destination="-2" name="enabled" keyPath="self.options.SBQueueMetadata" id="A11-N0-4xV"/>
|
||||
</connections>
|
||||
</textField>
|
||||
<textField verticalHuggingPriority="750" preferredMaxLayoutWidth="200" translatesAutoresizingMaskIntoConstraints="NO" id="Ns9-7q-hsh">
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="200" translatesAutoresizingMaskIntoConstraints="NO" id="Ns9-7q-hsh">
|
||||
<rect key="frame" x="123" y="309" width="54" height="14"/>
|
||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Artwork:" id="1HP-Np-D97">
|
||||
<font key="font" metaFont="smallSystemBold"/>
|
||||
@@ -322,7 +322,7 @@
|
||||
</binding>
|
||||
</connections>
|
||||
</popUpButton>
|
||||
<textField verticalHuggingPriority="750" preferredMaxLayoutWidth="200" translatesAutoresizingMaskIntoConstraints="NO" id="73q-gi-fe2">
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="200" translatesAutoresizingMaskIntoConstraints="NO" id="73q-gi-fe2">
|
||||
<rect key="frame" x="133" y="382" width="63" height="14"/>
|
||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Language:" id="VkG-jW-ibO">
|
||||
<font key="font" metaFont="smallSystemBold"/>
|
||||
@@ -386,7 +386,7 @@
|
||||
</binding>
|
||||
</connections>
|
||||
</button>
|
||||
<textField verticalHuggingPriority="750" preferredMaxLayoutWidth="200" translatesAutoresizingMaskIntoConstraints="NO" id="swT-iM-shZ">
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="200" translatesAutoresizingMaskIntoConstraints="NO" id="swT-iM-shZ">
|
||||
<rect key="frame" x="133" y="189" width="63" height="14"/>
|
||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Language:" id="GBM-Sa-9GJ">
|
||||
<font key="font" metaFont="smallSystemBold"/>
|
||||
@@ -472,6 +472,9 @@
|
||||
<menuItem title="Season" tag="3" id="mps-yj-l7z">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
<menuItem title="Season Square" tag="4" id="Aaf-km-GUP">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</popUpButtonCell>
|
||||
@@ -495,7 +498,7 @@
|
||||
</binding>
|
||||
</connections>
|
||||
</button>
|
||||
<textField verticalHuggingPriority="750" preferredMaxLayoutWidth="200" translatesAutoresizingMaskIntoConstraints="NO" id="2Hf-2V-95U">
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="200" translatesAutoresizingMaskIntoConstraints="NO" id="2Hf-2V-95U">
|
||||
<rect key="frame" x="133" y="154" width="76" height="14"/>
|
||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Color Space:" id="tMS-Tg-pPf">
|
||||
<font key="font" metaFont="smallSystemBold"/>
|
||||
@@ -526,8 +529,8 @@
|
||||
</popUpButtonCell>
|
||||
<connections>
|
||||
<accessibilityConnection property="title" destination="2Hf-2V-95U" id="Eze-Wq-wVA"/>
|
||||
<binding destination="-2" name="enabled" keyPath="self.options.SBQueueApplyColorSpace" id="XuE-t2-UYJ"/>
|
||||
<binding destination="-2" name="selectedTag" keyPath="options.SBQueueApplyColorSpaceValue" id="7tY-4O-RMF"/>
|
||||
<binding destination="-2" name="enabled" keyPath="self.options.SBQueueApplyColorSpace" id="XuE-t2-UYJ"/>
|
||||
</connections>
|
||||
</popUpButton>
|
||||
</subviews>
|
||||
|
||||
@@ -17,11 +17,11 @@ private class ArtworkImageObject : NSObject {
|
||||
private var data: Data?
|
||||
private var version: Int
|
||||
private var cancelled: Bool
|
||||
fileprivate let source: RemoteImage
|
||||
fileprivate let source: Artwork
|
||||
private let queue: DispatchQueue
|
||||
private weak var delegate: ArtworkImageObjectDelegate?
|
||||
|
||||
init(artwork: RemoteImage, delegate: ArtworkImageObjectDelegate) {
|
||||
init(artwork: Artwork, delegate: ArtworkImageObjectDelegate) {
|
||||
self.source = artwork
|
||||
self.delegate = delegate
|
||||
self.version = 0
|
||||
@@ -103,7 +103,7 @@ private class ArtworkImageObject : NSObject {
|
||||
}
|
||||
|
||||
public protocol ArtworkSelectorControllerDelegate: AnyObject {
|
||||
func didSelect(artworks: [RemoteImage])
|
||||
func didSelect(artworks: [Artwork])
|
||||
}
|
||||
|
||||
public class ArtworkSelectorController: NSWindowController, ArtworkImageObjectDelegate {
|
||||
@@ -113,15 +113,15 @@ public class ArtworkSelectorController: NSWindowController, ArtworkImageObjectDe
|
||||
@IBOutlet var addArtworkButton: NSButton!
|
||||
@IBOutlet var loadMoreArtworkButton: NSButton!
|
||||
|
||||
private var artworksUnloaded: [RemoteImage]
|
||||
private var artworksUnloaded: [Artwork]
|
||||
private var artworks: [ArtworkImageObject]
|
||||
private let initialSize: CGSize?
|
||||
private let type: MetadataSearch.Kind
|
||||
private let type: MetadataType
|
||||
|
||||
private weak var delegate: ArtworkSelectorControllerDelegate?
|
||||
|
||||
// MARK: - Init
|
||||
init(artworks: [RemoteImage], size: CGSize? = nil, type: MetadataSearch.Kind, delegate: ArtworkSelectorControllerDelegate) {
|
||||
init(artworks: [Artwork], size: CGSize? = nil, type: MetadataType, delegate: ArtworkSelectorControllerDelegate) {
|
||||
self.delegate = delegate
|
||||
self.initialSize = size
|
||||
self.artworksUnloaded = artworks
|
||||
@@ -155,7 +155,7 @@ public class ArtworkSelectorController: NSWindowController, ArtworkImageObjectDe
|
||||
|
||||
loadMoreArtworks(count: 8)
|
||||
|
||||
if let defaultType = UserDefaults.standard.string(forKey: "SBArtworkSelectorDefault|\(type.rawValue)") {
|
||||
if let defaultType = UserDefaults.standard.string(forKey: "SBArtworkSelectorDefault|\(type.description)") {
|
||||
selectArtwork(type: defaultType)
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ public class ArtworkSelectorController: NSWindowController, ArtworkImageObjectDe
|
||||
let endIndex = artworksUnloaded.count < count ? artworksUnloaded.count : count
|
||||
artworks.append(contentsOf: artworksUnloaded[0 ..< endIndex].map { ArtworkImageObject(artwork: $0, delegate: self) })
|
||||
artworksUnloaded.removeFirst(endIndex)
|
||||
loadMoreArtworkButton.isEnabled = artworksUnloaded.count > 0
|
||||
loadMoreArtworkButton.isEnabled = artworksUnloaded.isEmpty == false
|
||||
imageBrowser.reloadData()
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ public class ArtworkSelectorController: NSWindowController, ArtworkImageObjectDe
|
||||
let index = artworks.index(of: artwork) {
|
||||
selectArtwork(at: index)
|
||||
}
|
||||
else if artworksUnloaded.count > 0 {
|
||||
else if artworksUnloaded.isEmpty == false {
|
||||
for (index, artwork) in artworksUnloaded.enumerated() {
|
||||
if artwork.type == type {
|
||||
let offset = artworks.count
|
||||
@@ -236,9 +236,9 @@ public class ArtworkSelectorController: NSWindowController, ArtworkImageObjectDe
|
||||
}
|
||||
|
||||
override public func imageBrowserSelectionDidChange(_ aBrowser: IKImageBrowserView!) {
|
||||
addArtworkButton.isEnabled = aBrowser.selectionIndexes().count > 0
|
||||
addArtworkButton.isEnabled = aBrowser.selectionIndexes().isEmpty == false
|
||||
if let artwork = selectedArtworks().first {
|
||||
UserDefaults.standard.set(artwork.source.type, forKey: "SBArtworkSelectorDefault|\(type.rawValue)")
|
||||
UserDefaults.standard.set(artwork.source.type, forKey: "SBArtworkSelectorDefault|\(type.description)")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import Cocoa
|
||||
|
||||
private enum ChapterSearchState {
|
||||
case none
|
||||
case searching(task: MetadataSearchTask)
|
||||
case searching(task: Runnable)
|
||||
case completed(results: [ChapterResult], selectedResult: ChapterResult)
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ import Cocoa
|
||||
|
||||
updateUI()
|
||||
|
||||
if searchTerm.count > 0 { searchForResults(self) }
|
||||
if searchTerm.isEmpty == false { searchForResults(self) }
|
||||
}
|
||||
|
||||
private func searchDone(results: [ChapterResult]) {
|
||||
@@ -175,7 +175,7 @@ import Cocoa
|
||||
}
|
||||
|
||||
private func updateSearchButtonVisibility() {
|
||||
searchButton.isEnabled = searchTitle.stringValue.count > 0 ? true : false
|
||||
searchButton.isEnabled = searchTitle.stringValue.isEmpty ? false : true
|
||||
}
|
||||
|
||||
override func controlTextDidChange(_ obj: Notification) {
|
||||
|
||||
@@ -72,7 +72,7 @@ public struct ChapterDB : ChapterService {
|
||||
chapters.append(chapter)
|
||||
}
|
||||
|
||||
if chapters.count > 0 {
|
||||
if chapters.isEmpty == false {
|
||||
let result = ChapterResult(title: title, duration: duration, confimations: confirmations, chapters: chapters)
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -14,10 +14,10 @@ public protocol ChapterService {
|
||||
public enum ChapterSearch {
|
||||
case movieSeach(service: ChapterService, title: String, duration: UInt64)
|
||||
|
||||
public func search(completionHandler: @escaping ([ChapterResult]) -> Void) -> MetadataSearchTask {
|
||||
public func search(completionHandler: @escaping ([ChapterResult]) -> Void) -> Runnable {
|
||||
switch self {
|
||||
case let .movieSeach(service, title, duration):
|
||||
return MetadataSearchInternalTask(search: service.search(title: title, duration: duration),
|
||||
return RunnableTask(search: service.search(title: title, duration: duration),
|
||||
completionHandler: completionHandler)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,82 +7,57 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
public protocol MetadataSearchTask {
|
||||
@discardableResult func runAsync() -> MetadataSearchTask
|
||||
@discardableResult func run() -> MetadataSearchTask
|
||||
func cancel()
|
||||
}
|
||||
/// Wrapper for Objc compatibility
|
||||
@objc public class SBMetadataImporter : NSObject {
|
||||
|
||||
class MetadataSearchInternalTask<T> : MetadataSearchTask {
|
||||
|
||||
private var queue: DispatchQueue
|
||||
private var cancelled: Bool = false
|
||||
private let search: () -> T
|
||||
private let completionHandler: (T) -> Void
|
||||
|
||||
init(search: @escaping @autoclosure () -> T, completionHandler: @escaping (T) -> Void) {
|
||||
self.search = search
|
||||
self.completionHandler = completionHandler
|
||||
self.queue = DispatchQueue(label: "SearchTaskQueue")
|
||||
}
|
||||
|
||||
@discardableResult public func runAsync() -> MetadataSearchTask {
|
||||
DispatchQueue.global(priority: .background).async {
|
||||
self.run()
|
||||
}
|
||||
return self
|
||||
}
|
||||
|
||||
@discardableResult public func run() -> MetadataSearchTask {
|
||||
let results = self.search()
|
||||
queue.sync {
|
||||
if self.cancelled == false {
|
||||
self.completionHandler(results)
|
||||
}
|
||||
}
|
||||
return self
|
||||
}
|
||||
|
||||
public func cancel() {
|
||||
queue.sync {
|
||||
self.cancelled = true
|
||||
@objc public static var movieProviders: [String] {
|
||||
get {
|
||||
return MetadataSearch.movieProviders
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public protocol MetadataSearchCancelToken {
|
||||
func cancel()
|
||||
var sessionTask: URLSessionTask? { get set }
|
||||
}
|
||||
|
||||
// MARK: - Image
|
||||
|
||||
extension Array where Element == RemoteImage {
|
||||
func toClass() -> [SBRemoteImage] {
|
||||
return self.map { $0.toClass() }
|
||||
@objc public static var tvProviders: [String] {
|
||||
get {
|
||||
return MetadataSearch.tvProviders
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension SBRemoteImage {
|
||||
func toStruct() -> RemoteImage {
|
||||
return RemoteImage(url: self.url, thumbURL: self.thumbURL, service: self.service, type: self.type)
|
||||
@objc public static func languages(provider: String) -> [String] {
|
||||
return MetadataSearch.service(name: provider).languages
|
||||
}
|
||||
}
|
||||
|
||||
extension Array where Element == SBRemoteImage {
|
||||
func toStruct() -> [RemoteImage] {
|
||||
return self.map { $0.toStruct() }
|
||||
@objc public static func languageType(provider: String) -> LanguageType {
|
||||
return MetadataSearch.service(name: provider).languageType
|
||||
}
|
||||
}
|
||||
|
||||
public struct RemoteImage {
|
||||
let url: URL
|
||||
let thumbURL: URL
|
||||
let service: String
|
||||
let type: String
|
||||
@objc public static func defaultLanguage(provider: String) -> String {
|
||||
return MetadataSearch.service(name: provider).defaultLanguage
|
||||
}
|
||||
|
||||
public func toClass() -> SBRemoteImage {
|
||||
return SBRemoteImage(url: url, thumbURL: thumbURL, service: service, type: type)
|
||||
@objc public static func importer(provider: String) -> SBMetadataImporter {
|
||||
return SBMetadataImporter(provider: provider)
|
||||
}
|
||||
|
||||
private let service: MetadataService
|
||||
|
||||
@objc init(provider: String) {
|
||||
service = MetadataSearch.service(name: provider)
|
||||
}
|
||||
|
||||
init(service: MetadataService) {
|
||||
self.service = service
|
||||
}
|
||||
|
||||
@objc public var languageType: LanguageType {
|
||||
get {
|
||||
return service.languageType
|
||||
}
|
||||
}
|
||||
|
||||
@objc public var languages: [String] {
|
||||
get {
|
||||
return service.languages
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +98,7 @@ private func parseAnimeFilename(_ filename: String) -> FilenameInfo? {
|
||||
let seriesName = (filename as NSString).substring(with: seriesNameRange)
|
||||
let episode = Int((filename as NSString).substring(with: episodeRange))
|
||||
|
||||
if seriesName.count > 0 {
|
||||
if seriesName.isEmpty == false {
|
||||
result = FilenameInfo.tvShow(seriesName: seriesName, season: 1, episode: episode)
|
||||
}
|
||||
}
|
||||
@@ -152,7 +127,7 @@ private func parseFilename(_ filename: String) -> FilenameInfo? {
|
||||
guard let outputString = String(data: outputData, encoding: .utf8) else { return nil }
|
||||
let lines = outputString.components(separatedBy: "\n")
|
||||
|
||||
if lines.count > 0 {
|
||||
if lines.isEmpty == false {
|
||||
if lines.first == "tv" && lines.count >= 4 {
|
||||
let newSeriesName = lines[1].replacingOccurrences(of: ".", with: " ")
|
||||
return FilenameInfo.tvShow(seriesName: newSeriesName, season: Int(lines[2]), episode: Int(lines[3]))
|
||||
|
||||
@@ -38,11 +38,11 @@ public protocol MetadataService {
|
||||
|
||||
var name: String { get }
|
||||
|
||||
func search(TVSeries: String, language: String, season: Int?, episode: Int?) -> [SBMetadataResult]
|
||||
func loadTVMetadata(_ metadata: SBMetadataResult, language: String) -> SBMetadataResult
|
||||
func search(TVSeries: String, language: String, season: Int?, episode: Int?) -> [MetadataResult]
|
||||
func loadTVMetadata(_ metadata: MetadataResult, language: String) -> MetadataResult
|
||||
|
||||
func search(movie: String, language: String) -> [SBMetadataResult]
|
||||
func loadMovieMetadata(_ metadata: SBMetadataResult, language: String) -> SBMetadataResult
|
||||
func search(movie: String, language: String) -> [MetadataResult]
|
||||
func loadMovieMetadata(_ metadata: MetadataResult, language: String) -> MetadataResult
|
||||
|
||||
}
|
||||
|
||||
@@ -55,48 +55,57 @@ public protocol MetadataNameService {
|
||||
public enum MetadataNameSearch {
|
||||
case tvNameSearch(service: MetadataNameService, tvSeries: String, language: String)
|
||||
|
||||
public func search(completionHandler: @escaping ([String]) -> Void) -> MetadataSearchTask {
|
||||
public func search(completionHandler: @escaping ([String]) -> Void) -> Runnable {
|
||||
switch self {
|
||||
case let .tvNameSearch(service, tvSeries, language):
|
||||
return MetadataSearchInternalTask(search: service.search(TVSeries: tvSeries, language: language),
|
||||
return RunnableTask(search: service.search(TVSeries: tvSeries, language: language),
|
||||
completionHandler: completionHandler)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public enum MetadataType : Int, CustomStringConvertible {
|
||||
public var description: String {
|
||||
switch self {
|
||||
case .movie:
|
||||
return "Movie"
|
||||
case .tvShow:
|
||||
return "TV"
|
||||
}
|
||||
}
|
||||
|
||||
case movie
|
||||
case tvShow
|
||||
}
|
||||
|
||||
public enum MetadataSearch {
|
||||
case movieSeach(service: MetadataService, movie: String, language: String)
|
||||
case tvSearch(service: MetadataService, tvSeries: String, season: Int?, episode: Int?, language: String)
|
||||
|
||||
public func search(completionHandler: @escaping ([SBMetadataResult]) -> Void) -> MetadataSearchTask {
|
||||
public func search(completionHandler: @escaping ([MetadataResult]) -> Void) -> Runnable {
|
||||
switch self {
|
||||
case let .movieSeach(service, movie, language):
|
||||
return MetadataSearchInternalTask(search: service.search(movie: movie, language: language),
|
||||
return RunnableTask(search: service.search(movie: movie, language: language),
|
||||
completionHandler: completionHandler)
|
||||
case let .tvSearch(service, tvSeries, season, episode, language):
|
||||
return MetadataSearchInternalTask(search: service.search(TVSeries: tvSeries, language: language, season: season, episode: episode),
|
||||
return RunnableTask(search: service.search(TVSeries: tvSeries, language: language, season: season, episode: episode),
|
||||
completionHandler: completionHandler)
|
||||
}
|
||||
}
|
||||
|
||||
public func loadAdditionalMetadata(_ metadata: SBMetadataResult, completionHandler: @escaping (SBMetadataResult) -> Void) -> MetadataSearchTask {
|
||||
public func loadAdditionalMetadata(_ metadata: MetadataResult, completionHandler: @escaping (MetadataResult) -> Void) -> Runnable {
|
||||
switch self {
|
||||
case let .movieSeach(service, _, language):
|
||||
return MetadataSearchInternalTask(search: service.loadMovieMetadata(metadata, language: language),
|
||||
return RunnableTask(search: service.loadMovieMetadata(metadata, language: language),
|
||||
completionHandler: completionHandler)
|
||||
case let .tvSearch(service, _, _, _, language):
|
||||
return MetadataSearchInternalTask(search: service.loadTVMetadata(metadata, language: language),
|
||||
return RunnableTask(search: service.loadTVMetadata(metadata, language: language),
|
||||
completionHandler: completionHandler)
|
||||
}
|
||||
}
|
||||
|
||||
public enum Kind: String {
|
||||
case movie = "Movie"
|
||||
case tvShow = "TV"
|
||||
}
|
||||
|
||||
public var type: Kind {
|
||||
public var type: MetadataType {
|
||||
get {
|
||||
switch self {
|
||||
case .movieSeach:
|
||||
@@ -144,14 +153,14 @@ extension MetadataSearch {
|
||||
}
|
||||
}
|
||||
|
||||
public static func defaultLanguage(service: MetadataService, type: Kind) -> String {
|
||||
let language = UserDefaults.standard.string(forKey: "SBMetadataPreference|\(type.rawValue)|\(service.name)|Language") ?? service.defaultLanguage
|
||||
public static func defaultLanguage(service: MetadataService, type: MetadataType) -> String {
|
||||
let language = UserDefaults.standard.string(forKey: "SBMetadataPreference|\(type.description)|\(service.name)|Language") ?? service.defaultLanguage
|
||||
return service.languageType.displayName(language: language)
|
||||
}
|
||||
|
||||
public static func setDefaultLanguage(_ language: String, service: MetadataService, type: Kind) {
|
||||
public static func setDefaultLanguage(_ language: String, service: MetadataService, type: MetadataType) {
|
||||
let extendedLanguage = service.languageType.extendedTag(displayName: language)
|
||||
UserDefaults.standard.set(extendedLanguage, forKey: "SBMetadataPreference|\(type.rawValue)|\(service.name)|Language")
|
||||
UserDefaults.standard.set(extendedLanguage, forKey: "SBMetadataPreference|\(type.description)|\(service.name)|Language")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,259 @@
|
||||
//
|
||||
// MetadataResult.swift
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 08/08/2017.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
// MARK: - Image
|
||||
|
||||
public struct Artwork {
|
||||
let url: URL
|
||||
let thumbURL: URL
|
||||
let service: String
|
||||
let type: String
|
||||
}
|
||||
|
||||
private let localizedKeys: [MetadataResult.Key: String] = [
|
||||
.name : NSLocalizedString("Name", comment: "nil"),
|
||||
.composer : NSLocalizedString("Composer", comment: "nil"),
|
||||
.genre : NSLocalizedString("Genre", comment: "nil"),
|
||||
.releaseDate : NSLocalizedString("Release Date", comment: "nil"),
|
||||
.description : NSLocalizedString("Description", comment: "nil"),
|
||||
.longDescription : NSLocalizedString("Long Description", comment: "nil"),
|
||||
.rating : NSLocalizedString("Rating", comment: "nil"),
|
||||
.studio : NSLocalizedString("Studio", comment: "nil"),
|
||||
.cast : NSLocalizedString("Cast", comment: "nil"),
|
||||
.director : NSLocalizedString("Director", comment: "nil"),
|
||||
.producers : NSLocalizedString("Producers", comment: "nil"),
|
||||
.screenwriters : NSLocalizedString("Screenwriters", comment: "nil"),
|
||||
.executiveProducer: NSLocalizedString("Executive Producer", comment: "nil"),
|
||||
.copyright : NSLocalizedString("Copyright", comment: "nil"),
|
||||
|
||||
.contentID : NSLocalizedString("contentID", comment: "nil"),
|
||||
.artistID : NSLocalizedString("artistID", comment: "nil"),
|
||||
.playlistID : NSLocalizedString("playlistID", comment: "nil"),
|
||||
.iTunesCountry : NSLocalizedString("iTunes Country", comment: "nil"),
|
||||
.iTunesURL : NSLocalizedString("iTunes URL", comment: "nil"),
|
||||
|
||||
.seriesName : NSLocalizedString("Series Name", comment: "nil"),
|
||||
.seriesDescription: NSLocalizedString("Series Description", comment: "nil"),
|
||||
.trackNumber : NSLocalizedString("Track #", comment: "nil"),
|
||||
.diskNumber : NSLocalizedString("Disk #", comment: "nil"),
|
||||
.episodeNumber : NSLocalizedString("Episode #", comment: "nil"),
|
||||
.episodeID : NSLocalizedString("Episode ID", comment: "nil"),
|
||||
.season : NSLocalizedString("Season", comment: "nil"),
|
||||
.network : NSLocalizedString("Network", comment: "nil"),
|
||||
|
||||
.serviceSeriesID : NSLocalizedString("Service ID", comment: "nil"),
|
||||
.serviceEpisodeID : NSLocalizedString("Service ID", comment: "nil")
|
||||
]
|
||||
|
||||
@objc(SBMetadataResult) public class MetadataResult : NSObject {
|
||||
|
||||
public enum Key: String {
|
||||
// Common Keys
|
||||
case name = "{Name}"
|
||||
case composer = "{Composer}"
|
||||
case genre = "{Genre}"
|
||||
case releaseDate = "{Release Date}"
|
||||
case description = "{Description}"
|
||||
case longDescription = "{Long Description}"
|
||||
case rating = "{Rating}"
|
||||
case studio = "{Studio}"
|
||||
case cast = "{Cast}"
|
||||
case director = "{Director}"
|
||||
case producers = "{Producers}"
|
||||
case screenwriters = "{Screenwriters}"
|
||||
case executiveProducer = "{Executive Producer}"
|
||||
case copyright = "{Copyright}"
|
||||
|
||||
case mediaKind = "{MediaKind}"
|
||||
case contentRating = "{ContentRating}"
|
||||
|
||||
// iTunes Keys
|
||||
case contentID = "{contentID}"
|
||||
case artistID = "{artistID}"
|
||||
case playlistID = "{playlistID}"
|
||||
case iTunesCountry = "{iTunes Country}"
|
||||
case iTunesURL = "{iTunes URL}"
|
||||
|
||||
// TV Show Keys
|
||||
case seriesName = "{Series Name}"
|
||||
case seriesDescription = "{Series Description}"
|
||||
case trackNumber = "{Track #}"
|
||||
case diskNumber = "{Disk #}"
|
||||
case episodeNumber = "{Episode #}"
|
||||
case episodeID = "{Episode ID}"
|
||||
case season = "{Season}"
|
||||
case network = "{Network}"
|
||||
|
||||
//
|
||||
case serviceSeriesID = "ServiceSeriesID"
|
||||
case serviceEpisodeID = "ServiceEpisodeID"
|
||||
|
||||
fileprivate static var movieKeys: [Key] {
|
||||
return [.name,
|
||||
.composer,
|
||||
.genre,
|
||||
.releaseDate,
|
||||
.description,
|
||||
.longDescription,
|
||||
.rating,
|
||||
.studio,
|
||||
.cast,
|
||||
.director,
|
||||
.producers,
|
||||
.screenwriters,
|
||||
.executiveProducer,
|
||||
.copyright,
|
||||
.contentID,
|
||||
.artistID]
|
||||
}
|
||||
|
||||
fileprivate static var tvShowKeys: [Key] {
|
||||
return [.name,
|
||||
.seriesName,
|
||||
.composer,
|
||||
.genre,
|
||||
.releaseDate,
|
||||
|
||||
.trackNumber,
|
||||
.diskNumber,
|
||||
.episodeNumber,
|
||||
.network,
|
||||
.episodeID,
|
||||
.season,
|
||||
|
||||
.description,
|
||||
.longDescription,
|
||||
.seriesDescription,
|
||||
|
||||
.rating,
|
||||
.studio,
|
||||
.cast,
|
||||
.director,
|
||||
.producers,
|
||||
.screenwriters,
|
||||
.executiveProducer,
|
||||
.copyright,
|
||||
.contentID,
|
||||
.artistID,
|
||||
.playlistID,
|
||||
.iTunesCountry]
|
||||
}
|
||||
|
||||
public var localizedDisplayName: String {
|
||||
return localizedKeys[self] ?? "Null"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@objc public static var movieKeys: [String] {
|
||||
return Key.movieKeys.map { $0.rawValue }
|
||||
}
|
||||
|
||||
@objc public static var tvShowKeys: [String] {
|
||||
return Key.tvShowKeys.map { $0.rawValue }
|
||||
}
|
||||
|
||||
@objc static func localizedDisplayName(key: String) -> String {
|
||||
return Key(rawValue: key)?.localizedDisplayName ?? key
|
||||
}
|
||||
|
||||
private var dictionary: [Key:Any]
|
||||
|
||||
@objc public var mediaKind: Int
|
||||
public var contentRating: Int
|
||||
public var remoteArtworks: [Artwork]
|
||||
public var artworks: [MP42Image]
|
||||
|
||||
override init() {
|
||||
self.dictionary = Dictionary()
|
||||
self.remoteArtworks = Array()
|
||||
self.artworks = Array()
|
||||
self.mediaKind = 0
|
||||
self.contentRating = 0
|
||||
}
|
||||
|
||||
subscript(key: Key) -> Any? {
|
||||
get {
|
||||
return dictionary[key]
|
||||
}
|
||||
set (newValue) {
|
||||
dictionary[key] = newValue
|
||||
}
|
||||
}
|
||||
|
||||
lazy var orderedKeys: [Key] = {
|
||||
let sortedKeys = self.mediaKind == 9 ? Key.movieKeys : Key.tvShowKeys
|
||||
return Array(dictionary.keys).sorted(by: { (key1: Key, key2: Key) -> Bool in
|
||||
if let index1 = sortedKeys.index(of: key1), let index2 = sortedKeys.index(of: key2) {
|
||||
return index1 < index2
|
||||
}
|
||||
return key1 != Key.serviceSeriesID && key1 != Key.serviceEpisodeID
|
||||
})
|
||||
}()
|
||||
|
||||
public var count: Int {
|
||||
return dictionary.count
|
||||
}
|
||||
|
||||
public func merge(result: MetadataResult) {
|
||||
dictionary.merge(result.dictionary) { (_, new) in new }
|
||||
}
|
||||
|
||||
private func isToken(_ string: String) -> Bool {
|
||||
return string.hasPrefix("{}") && string.hasSuffix("}") && string.count > 2
|
||||
}
|
||||
|
||||
@objc public func mappedMetadata(to map: MetadataResultMap, keepEmptyKeys: Bool) -> MP42Metadata {
|
||||
let metadata = MP42Metadata()
|
||||
|
||||
for item in map.items {
|
||||
var result = ""
|
||||
for component in item.value {
|
||||
if let key = Key(rawValue: component) {
|
||||
if let value = dictionary[key] {
|
||||
result.append("\(value)")
|
||||
}
|
||||
}
|
||||
else {
|
||||
result.append(component)
|
||||
}
|
||||
}
|
||||
|
||||
let metadataItem = MP42MetadataItem(identifier: item.key,
|
||||
value: result as NSCopying & NSObjectProtocol,
|
||||
dataType: .unspecified, extendedLanguageTag: nil)
|
||||
if result.isEmpty == false || keepEmptyKeys {
|
||||
metadata.addItem(metadataItem)
|
||||
}
|
||||
}
|
||||
|
||||
for artwork in artworks {
|
||||
let metadataItem = MP42MetadataItem(identifier: MP42MetadataKeyCoverArt,value: artwork,
|
||||
dataType: .image, extendedLanguageTag: nil)
|
||||
metadata.addItem(metadataItem)
|
||||
}
|
||||
|
||||
let mediaKind = MP42MetadataItem(identifier: MP42MetadataKeyMediaKind,
|
||||
value: NSNumber(value: self.mediaKind),
|
||||
dataType: .integer,
|
||||
extendedLanguageTag: nil)
|
||||
metadata.addItem(mediaKind)
|
||||
|
||||
if contentRating > 0 || keepEmptyKeys {
|
||||
let contentRating = MP42MetadataItem(identifier: MP42MetadataKeyContentRating,
|
||||
value: NSNumber(value: self.contentRating),
|
||||
dataType: .integer,
|
||||
extendedLanguageTag: nil)
|
||||
metadata.addItem(contentRating)
|
||||
}
|
||||
|
||||
return metadata
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
//
|
||||
// MetadataResultMap.swift
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 09/08/2017.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
@objc(SBMetadataResultMapItem) public class MetadataResultMapItem : NSObject, NSSecureCoding {
|
||||
|
||||
@objc public let key: String
|
||||
@objc public var value: [String]
|
||||
@objc public var localizedKeyDisplayName: String { return localizedMetadataKeyName(key) }
|
||||
|
||||
@objc public init(key: String, value: [String]) {
|
||||
self.key = key
|
||||
self.value = value
|
||||
}
|
||||
|
||||
// MARK: NSSecureCoding
|
||||
|
||||
public static var supportsSecureCoding: Bool { return true }
|
||||
|
||||
public func encode(with aCoder: NSCoder) {
|
||||
aCoder.encode(key, forKey: "key")
|
||||
aCoder.encode(value, forKey: "value")
|
||||
}
|
||||
|
||||
required public init?(coder aDecoder: NSCoder) {
|
||||
guard let key = aDecoder.decodeObject(of: NSString.self, forKey: "key") as String?,
|
||||
let value = aDecoder.decodeObject(of: [NSArray.self, NSString.self], forKey: "value") as? [String]
|
||||
else { return nil }
|
||||
self.key = key
|
||||
self.value = value
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@objc(SBMetadataResultMap) public class MetadataResultMap : NSObject, NSSecureCoding {
|
||||
|
||||
@objc public static var movieDefaultMap: MetadataResultMap {
|
||||
let items = [ MetadataResultMapItem(key: MP42MetadataKeyName, value:[MetadataResult.Key.name.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyArtist, value:[MetadataResult.Key.director.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyComposer, value:[MetadataResult.Key.composer.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyUserGenre, value:[MetadataResult.Key.genre.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyReleaseDate, value:[MetadataResult.Key.releaseDate.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyDescription, value:[MetadataResult.Key.description.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyLongDescription, value:[MetadataResult.Key.longDescription.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyRating, value:[MetadataResult.Key.rating.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyStudio, value:[MetadataResult.Key.studio.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyCast, value:[MetadataResult.Key.cast.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyDirector, value:[MetadataResult.Key.director.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyProducer, value:[MetadataResult.Key.producers.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyScreenwriters, value:[MetadataResult.Key.screenwriters.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyCopyright, value:[MetadataResult.Key.copyright.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyContentID, value:[MetadataResult.Key.contentID.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyAccountCountry, value:[MetadataResult.Key.iTunesCountry.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyExecProducer, value:[MetadataResult.Key.executiveProducer.rawValue])]
|
||||
|
||||
return MetadataResultMap(items: items, type: .movie)
|
||||
}
|
||||
|
||||
@objc public static var tvShowDefaultMap: MetadataResultMap {
|
||||
let items = [MetadataResultMapItem(key: MP42MetadataKeyName, value:[MetadataResult.Key.name.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyArtist, value:[MetadataResult.Key.seriesName.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyAlbumArtist, value:[MetadataResult.Key.seriesName.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyAlbum, value:[MetadataResult.Key.seriesName.rawValue, ", Season ", MetadataResult.Key.season.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyComposer, value:[MetadataResult.Key.composer.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyUserGenre, value:[MetadataResult.Key.genre.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyReleaseDate, value:[MetadataResult.Key.releaseDate.rawValue]),
|
||||
|
||||
MetadataResultMapItem(key: MP42MetadataKeyTrackNumber, value:[MetadataResult.Key.trackNumber.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyDiscNumber, value:[MetadataResult.Key.diskNumber.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyTVShow, value:[MetadataResult.Key.seriesName.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyTVEpisodeNumber, value:[MetadataResult.Key.episodeNumber.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyTVNetwork, value:[MetadataResult.Key.network.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyTVEpisodeID, value:[MetadataResult.Key.episodeID.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyTVSeason, value:[MetadataResult.Key.season.rawValue]),
|
||||
|
||||
MetadataResultMapItem(key: MP42MetadataKeyDescription, value:[MetadataResult.Key.description.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyLongDescription, value:[MetadataResult.Key.longDescription.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeySeriesDescription, value:[MetadataResult.Key.seriesDescription.rawValue]),
|
||||
|
||||
MetadataResultMapItem(key: MP42MetadataKeyRating, value:[MetadataResult.Key.rating.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyStudio, value:[MetadataResult.Key.studio.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyCast, value:[MetadataResult.Key.cast.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyDirector, value:[MetadataResult.Key.director.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyProducer, value:[MetadataResult.Key.producers.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyScreenwriters, value:[MetadataResult.Key.screenwriters.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyExecProducer, value:[MetadataResult.Key.executiveProducer.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyCopyright, value:[MetadataResult.Key.copyright.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyContentID, value:[MetadataResult.Key.contentID.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyArtistID, value:[MetadataResult.Key.artistID.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyPlaylistID, value:[MetadataResult.Key.playlistID.rawValue]),
|
||||
MetadataResultMapItem(key: MP42MetadataKeyAccountCountry, value:[MetadataResult.Key.iTunesCountry.rawValue])]
|
||||
|
||||
return MetadataResultMap(items: items, type: .tvShow)
|
||||
}
|
||||
|
||||
@objc public var items: [MetadataResultMapItem]
|
||||
public let type: MetadataType
|
||||
|
||||
init(items: [MetadataResultMapItem], type: MetadataType) {
|
||||
self.items = items
|
||||
self.type = type
|
||||
}
|
||||
|
||||
// MARK: NSSecureCoding
|
||||
|
||||
public static var supportsSecureCoding: Bool { return true }
|
||||
|
||||
public func encode(with aCoder: NSCoder) {
|
||||
aCoder.encode(items, forKey: "items")
|
||||
aCoder.encode(Int32(type.rawValue), forKey: "type")
|
||||
}
|
||||
|
||||
required public init?(coder aDecoder: NSCoder) {
|
||||
guard let items = aDecoder.decodeObject(of: [NSArray.self, MetadataResultMapItem.self], forKey: "items") as? [MetadataResultMapItem],
|
||||
let type = MetadataType(rawValue: Int(aDecoder.decodeInt32(forKey: "type")))
|
||||
else { return nil }
|
||||
self.items = items
|
||||
self.type = type
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@objc extension UserDefaults {
|
||||
|
||||
@objc func map(forKey defaultName: String) -> MetadataResultMap? {
|
||||
guard let data = self.data(forKey: defaultName) else { return nil }
|
||||
|
||||
let unarchiver = NSKeyedUnarchiver(forReadingWith: data)
|
||||
unarchiver.requiresSecureCoding = true
|
||||
|
||||
return unarchiver.decodeObject(of: MetadataResultMap.self, forKey: NSKeyedArchiveRootObjectKey)
|
||||
}
|
||||
|
||||
@objc(setMap:forKey:) func set(_ map: MetadataResultMap, forKey defaultName: String) {
|
||||
let data = NSKeyedArchiver.archivedData(withRootObject: map)
|
||||
self.set(data, forKey: defaultName)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
//
|
||||
// SBMetadataImporter.swift
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 27/07/2017.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
@objc public class SBMetadataImporter : NSObject {
|
||||
|
||||
@objc public static var movieProviders: [String] {
|
||||
get {
|
||||
return MetadataSearch.movieProviders
|
||||
}
|
||||
}
|
||||
|
||||
@objc public static var tvProviders: [String] {
|
||||
get {
|
||||
return MetadataSearch.tvProviders
|
||||
}
|
||||
}
|
||||
|
||||
@objc public static func languages(provider: String) -> [String] {
|
||||
return MetadataSearch.service(name: provider).languages
|
||||
}
|
||||
|
||||
@objc public static func languageType(provider: String) -> LanguageType {
|
||||
return MetadataSearch.service(name: provider).languageType
|
||||
}
|
||||
|
||||
@objc public static func defaultLanguage(provider: String) -> String {
|
||||
return MetadataSearch.service(name: provider).defaultLanguage
|
||||
}
|
||||
|
||||
@objc public static func importer(provider: String) -> SBMetadataImporter {
|
||||
return SBMetadataImporter(provider: provider)
|
||||
}
|
||||
|
||||
private let service: MetadataService
|
||||
|
||||
@objc init(provider: String) {
|
||||
service = MetadataSearch.service(name: provider)
|
||||
}
|
||||
|
||||
init(service: MetadataService) {
|
||||
self.service = service
|
||||
}
|
||||
|
||||
@objc public var languageType: LanguageType {
|
||||
get {
|
||||
return service.languageType
|
||||
}
|
||||
}
|
||||
|
||||
@objc public var languages: [String] {
|
||||
get {
|
||||
return service.languages
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
//
|
||||
// SBMetadataResult.h
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 17/02/16.
|
||||
//
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class MP42Image;
|
||||
@class MP42Metadata;
|
||||
@class SBMetadataResultMap;
|
||||
|
||||
// Common Keys
|
||||
extern NSString *const SBMetadataResultName;
|
||||
extern NSString *const SBMetadataResultComposer;
|
||||
extern NSString *const SBMetadataResultGenre;
|
||||
extern NSString *const SBMetadataResultReleaseDate;
|
||||
extern NSString *const SBMetadataResultDescription;
|
||||
extern NSString *const SBMetadataResultLongDescription;
|
||||
extern NSString *const SBMetadataResultRating;
|
||||
extern NSString *const SBMetadataResultStudio;
|
||||
extern NSString *const SBMetadataResultCast;
|
||||
extern NSString *const SBMetadataResultDirector;
|
||||
extern NSString *const SBMetadataResultProducers;
|
||||
extern NSString *const SBMetadataResultScreenwriters;
|
||||
extern NSString *const SBMetadataResultExecutiveProducer;
|
||||
extern NSString *const SBMetadataResultCopyright;
|
||||
|
||||
// iTunes Keys
|
||||
extern NSString *const SBMetadataResultContentID;
|
||||
extern NSString *const SBMetadataResultArtistID;
|
||||
extern NSString *const SBMetadataResultPlaylistID;
|
||||
extern NSString *const SBMetadataResultITunesCountry;
|
||||
extern NSString *const SBMetadataResultITunesURL;
|
||||
|
||||
// TV Show Keys
|
||||
extern NSString *const SBMetadataResultSeriesName;
|
||||
extern NSString *const SBMetadataResultSeriesDescription;
|
||||
extern NSString *const SBMetadataResultTrackNumber;
|
||||
extern NSString *const SBMetadataResultDiskNumber;
|
||||
extern NSString *const SBMetadataResultEpisodeNumber;
|
||||
extern NSString *const SBMetadataResultEpisodeID;
|
||||
extern NSString *const SBMetadataResultSeason;
|
||||
extern NSString *const SBMetadataResultNetwork;
|
||||
|
||||
@interface SBRemoteImage : NSObject
|
||||
|
||||
+ (instancetype)remoteImageWithURL:(NSURL *)fullSizeURL thumbURL:(NSURL *)thumbURL service:(NSString *)service type:(NSString *)kind;
|
||||
|
||||
@property (nonatomic, readonly) NSURL *URL;
|
||||
@property (nonatomic, readonly) NSURL *thumbURL;
|
||||
@property (nonatomic, readonly) NSString *service;
|
||||
@property (nonatomic, readonly) NSString *type;
|
||||
|
||||
@end
|
||||
|
||||
@interface SBMetadataResult : NSObject
|
||||
|
||||
+ (NSArray<NSString *> *)movieKeys;
|
||||
+ (NSArray<NSString *> *)tvShowKeys;
|
||||
+ (NSString *)localizedDisplayNameForKey:(NSString *)key;
|
||||
|
||||
- (void)merge:(SBMetadataResult *)aObject;
|
||||
|
||||
- (void)removeTagForKey:(NSString *)aKey;
|
||||
- (void)setTag:(id)value forKey:(NSString *)key;
|
||||
|
||||
- (nullable id)objectForKeyedSubscript:(NSString *)key;
|
||||
- (void)setObject:(nullable id)obj forKeyedSubscript:(NSString *)key;
|
||||
|
||||
- (NSArray<NSString *> *)orderedKeys;
|
||||
|
||||
@property (nonatomic, readonly) NSMutableDictionary<NSString *, id> *tags;
|
||||
|
||||
@property (nonatomic, readwrite) uint8_t mediaKind;
|
||||
@property (nonatomic, readwrite) uint8_t contentRating;
|
||||
|
||||
@property (nonatomic, readonly) NSMutableArray<MP42Image *> *artworks;
|
||||
|
||||
@property (nonatomic, readwrite, nullable) NSArray<SBRemoteImage *> *remoteArtworks;
|
||||
|
||||
- (MP42Metadata *)mappedTo:(SBMetadataResultMap *)map keepEmptyKeys:(BOOL)keep;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -1,306 +0,0 @@
|
||||
//
|
||||
// SBMetadataResult.m
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 17/02/16.
|
||||
//
|
||||
//
|
||||
|
||||
#import "SBMetadataResult.h"
|
||||
#import "SBMetadataResultMap.h"
|
||||
#import <MP42Foundation/MP42Metadata.h>
|
||||
|
||||
// Common Keys
|
||||
NSString *const SBMetadataResultName = @"{Name}";
|
||||
NSString *const SBMetadataResultComposer = @"{Composer}";
|
||||
NSString *const SBMetadataResultGenre = @"{Genre}";
|
||||
NSString *const SBMetadataResultReleaseDate = @"{Release Date}";
|
||||
NSString *const SBMetadataResultDescription = @"{Description}";
|
||||
NSString *const SBMetadataResultLongDescription = @"{Long Description}";
|
||||
NSString *const SBMetadataResultRating = @"{Rating}";
|
||||
NSString *const SBMetadataResultStudio = @"{Studio}";
|
||||
NSString *const SBMetadataResultCast = @"{Cast}";
|
||||
NSString *const SBMetadataResultDirector = @"{Director}";
|
||||
NSString *const SBMetadataResultProducers = @"{Producers}";
|
||||
NSString *const SBMetadataResultScreenwriters = @"{Screenwriters}";
|
||||
NSString *const SBMetadataResultExecutiveProducer = @"{Executive Producer}";
|
||||
NSString *const SBMetadataResultCopyright = @"{Copyright}";
|
||||
|
||||
// iTunes Keys
|
||||
NSString *const SBMetadataResultContentID = @"{contentID}";
|
||||
NSString *const SBMetadataResultArtistID = @"{artistID}";
|
||||
NSString *const SBMetadataResultPlaylistID = @"{playlistID}";
|
||||
NSString *const SBMetadataResultITunesCountry = @"{iTunes Country}";
|
||||
NSString *const SBMetadataResultITunesURL = @"{iTunes URL}";
|
||||
|
||||
// TV Show Keys
|
||||
NSString *const SBMetadataResultSeriesName = @"{Series Name}";
|
||||
NSString *const SBMetadataResultSeriesDescription = @"{Series Description}";
|
||||
NSString *const SBMetadataResultTrackNumber = @"{Track #}";
|
||||
NSString *const SBMetadataResultDiskNumber = @"{Disk #}";
|
||||
NSString *const SBMetadataResultEpisodeNumber = @"{Episode #}";
|
||||
NSString *const SBMetadataResultEpisodeID = @"{Episode ID}";
|
||||
NSString *const SBMetadataResultSeason = @"{Season}";
|
||||
NSString *const SBMetadataResultNetwork = @"{Network}";
|
||||
|
||||
@implementation SBRemoteImage
|
||||
|
||||
- (instancetype)initWithURL:(NSURL *)fullSizeURL thumbURL:(NSURL *)thumbURL service:(NSString *)service type:(NSString *)type
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
_URL = fullSizeURL;
|
||||
_thumbURL = thumbURL;
|
||||
_service = service;
|
||||
_type = type;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)remoteImageWithURL:(NSURL *)fullSizeURL thumbURL:(NSURL *)thumbURL service:(NSString *)service type:(NSString *)type
|
||||
{
|
||||
return [[self alloc] initWithURL:fullSizeURL thumbURL:thumbURL service:service type:type];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface SBMetadataResult ()
|
||||
{
|
||||
NSArray<NSString *> *_orderedKeys;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation SBMetadataResult
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
_tags = [[NSMutableDictionary alloc] init];
|
||||
_artworks = [[NSMutableArray alloc] init];
|
||||
_remoteArtworks = [[NSArray alloc] init];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (NSArray<NSString *> *)movieKeys
|
||||
{
|
||||
return @[SBMetadataResultName,
|
||||
SBMetadataResultComposer,
|
||||
SBMetadataResultGenre,
|
||||
SBMetadataResultReleaseDate,
|
||||
SBMetadataResultDescription,
|
||||
SBMetadataResultLongDescription,
|
||||
SBMetadataResultRating,
|
||||
SBMetadataResultStudio,
|
||||
SBMetadataResultCast,
|
||||
SBMetadataResultDirector,
|
||||
SBMetadataResultProducers,
|
||||
SBMetadataResultScreenwriters,
|
||||
SBMetadataResultExecutiveProducer,
|
||||
SBMetadataResultCopyright,
|
||||
SBMetadataResultContentID,
|
||||
SBMetadataResultITunesCountry];
|
||||
}
|
||||
|
||||
+ (NSArray<NSString *> *)tvShowKeys
|
||||
{
|
||||
return @[SBMetadataResultName,
|
||||
SBMetadataResultSeriesName,
|
||||
SBMetadataResultComposer,
|
||||
SBMetadataResultGenre,
|
||||
SBMetadataResultReleaseDate,
|
||||
|
||||
SBMetadataResultTrackNumber,
|
||||
SBMetadataResultDiskNumber,
|
||||
SBMetadataResultEpisodeNumber,
|
||||
SBMetadataResultNetwork,
|
||||
SBMetadataResultEpisodeID,
|
||||
SBMetadataResultSeason,
|
||||
|
||||
SBMetadataResultDescription,
|
||||
SBMetadataResultLongDescription,
|
||||
SBMetadataResultSeriesDescription,
|
||||
|
||||
SBMetadataResultRating,
|
||||
SBMetadataResultStudio,
|
||||
SBMetadataResultCast,
|
||||
SBMetadataResultDirector,
|
||||
SBMetadataResultProducers,
|
||||
SBMetadataResultScreenwriters,
|
||||
SBMetadataResultExecutiveProducer,
|
||||
SBMetadataResultCopyright,
|
||||
SBMetadataResultContentID,
|
||||
SBMetadataResultArtistID,
|
||||
SBMetadataResultPlaylistID,
|
||||
SBMetadataResultITunesCountry];
|
||||
}
|
||||
|
||||
static NSDictionary<NSString *, NSString *> *localizedKeys;
|
||||
|
||||
+ (NSString *)localizedDisplayNameForKey:(NSString *)key
|
||||
{
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
localizedKeys = @{
|
||||
SBMetadataResultName: NSLocalizedString(@"Name", nil),
|
||||
SBMetadataResultComposer: NSLocalizedString(@"Composer", nil),
|
||||
SBMetadataResultGenre: NSLocalizedString(@"Genre", nil),
|
||||
SBMetadataResultReleaseDate: NSLocalizedString(@"Release Date", nil),
|
||||
SBMetadataResultDescription: NSLocalizedString(@"Description", nil),
|
||||
SBMetadataResultLongDescription: NSLocalizedString(@"Long Description", nil),
|
||||
SBMetadataResultRating: NSLocalizedString(@"Rating", nil),
|
||||
SBMetadataResultStudio: NSLocalizedString(@"Studio", nil),
|
||||
SBMetadataResultCast: NSLocalizedString(@"Cast", nil),
|
||||
SBMetadataResultDirector: NSLocalizedString(@"Director", nil),
|
||||
SBMetadataResultProducers: NSLocalizedString(@"Producers", nil),
|
||||
SBMetadataResultScreenwriters: NSLocalizedString(@"Screenwriters", nil),
|
||||
SBMetadataResultExecutiveProducer: NSLocalizedString(@"Executive Producer", nil),
|
||||
SBMetadataResultCopyright: NSLocalizedString(@"Copyright", nil),
|
||||
|
||||
SBMetadataResultContentID: NSLocalizedString(@"contentID", nil),
|
||||
SBMetadataResultArtistID: NSLocalizedString(@"artistID", nil),
|
||||
SBMetadataResultPlaylistID: NSLocalizedString(@"playlistID", nil),
|
||||
SBMetadataResultITunesCountry: NSLocalizedString(@"iTunes Country", nil),
|
||||
SBMetadataResultITunesURL: NSLocalizedString(@"iTunes URL", nil),
|
||||
|
||||
SBMetadataResultSeriesName: NSLocalizedString(@"Series Name", nil),
|
||||
SBMetadataResultSeriesDescription: NSLocalizedString(@"Series Description", nil),
|
||||
SBMetadataResultTrackNumber: NSLocalizedString(@"Track #", nil),
|
||||
SBMetadataResultDiskNumber: NSLocalizedString(@"Disk #", nil),
|
||||
SBMetadataResultEpisodeNumber: NSLocalizedString(@"Episode #", nil),
|
||||
SBMetadataResultEpisodeID: NSLocalizedString(@"Episode ID", nil),
|
||||
SBMetadataResultSeason: NSLocalizedString(@"Season", nil),
|
||||
SBMetadataResultNetwork: NSLocalizedString(@"Network", nil),
|
||||
};
|
||||
});
|
||||
|
||||
NSString *localizedString = localizedKeys[key];
|
||||
return localizedString ? localizedString : key;
|
||||
|
||||
}
|
||||
|
||||
- (void)merge:(SBMetadataResult *)metadata
|
||||
{
|
||||
[_tags addEntriesFromDictionary:metadata.tags];
|
||||
|
||||
for (MP42Image *artwork in metadata.artworks) {
|
||||
[_artworks addObject:artwork];
|
||||
}
|
||||
|
||||
_mediaKind = metadata.mediaKind;
|
||||
_contentRating = metadata.contentRating;
|
||||
}
|
||||
|
||||
- (void)removeTagForKey:(NSString *)aKey
|
||||
{
|
||||
[_tags removeObjectForKey:aKey];
|
||||
}
|
||||
|
||||
- (void)setTag:(id)value forKey:(NSString *)key
|
||||
{
|
||||
_tags[key] = value;
|
||||
}
|
||||
|
||||
- (id)objectForKeyedSubscript:(NSString *)key
|
||||
{
|
||||
return _tags[key];
|
||||
}
|
||||
|
||||
- (void)setObject:(nullable id)obj forKeyedSubscript:(NSString *)key
|
||||
{
|
||||
if (obj == nil) {
|
||||
[self removeTagForKey:key];
|
||||
}
|
||||
else {
|
||||
[self setTag:obj forKey:key];
|
||||
}
|
||||
}
|
||||
|
||||
static NSInteger sortFunction (id ldict, id rdict, void *context) {
|
||||
NSComparisonResult rc;
|
||||
|
||||
NSInteger right = [(__bridge NSArray*) context indexOfObject:rdict];
|
||||
NSInteger left = [(__bridge NSArray*) context indexOfObject:ldict];
|
||||
|
||||
if (right < left) {
|
||||
rc = NSOrderedDescending;
|
||||
}
|
||||
else {
|
||||
rc = NSOrderedAscending;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
- (NSArray<NSString *> *)orderedKeys
|
||||
{
|
||||
if (_orderedKeys == nil) {
|
||||
NSArray<NSString *> *sortKeys = self.mediaKind == 9 ? [SBMetadataResult movieKeys] : [SBMetadataResult tvShowKeys];
|
||||
_orderedKeys = [self.tags.allKeys sortedArrayUsingFunction:sortFunction context:(__bridge void * _Nullable)sortKeys];
|
||||
}
|
||||
return _orderedKeys;
|
||||
}
|
||||
|
||||
- (MP42Metadata *)mappedTo:(SBMetadataResultMap *)map keepEmptyKeys:(BOOL)keep
|
||||
{
|
||||
MP42Metadata *metadata = [[MP42Metadata alloc] init];
|
||||
|
||||
for (SBMetadataResultMapItem *item in map.items) {
|
||||
NSMutableString *result = [NSMutableString string];
|
||||
for (NSString *component in item.value) {
|
||||
if ([component hasPrefix:@"{"] && [component hasSuffix:@"}"] && component.length > 2) {
|
||||
id value = _tags[component];
|
||||
if ([value isKindOfClass:[NSString class]] && [value length]) {
|
||||
[result appendString:value];
|
||||
}
|
||||
else if ([value isKindOfClass:[NSNumber class]]) {
|
||||
[result appendString:[value stringValue]];
|
||||
}
|
||||
}
|
||||
else {
|
||||
[result appendString:component];
|
||||
}
|
||||
}
|
||||
|
||||
MP42MetadataItem *metadataItem = [MP42MetadataItem metadataItemWithIdentifier:item.key
|
||||
value:result
|
||||
dataType:MP42MetadataItemDataTypeUnspecified
|
||||
extendedLanguageTag:nil];
|
||||
|
||||
if (result.length) {
|
||||
[metadata addMetadataItem:metadataItem];
|
||||
}
|
||||
else if (keep) {
|
||||
[metadata addMetadataItem:metadataItem];
|
||||
}
|
||||
}
|
||||
|
||||
for (MP42Image *artwork in self.artworks) {
|
||||
MP42MetadataItem *metadataItem = [MP42MetadataItem metadataItemWithIdentifier:MP42MetadataKeyCoverArt
|
||||
value:(id)artwork
|
||||
dataType:MP42MetadataItemDataTypeImage
|
||||
extendedLanguageTag:nil];
|
||||
[metadata addMetadataItem:metadataItem];
|
||||
}
|
||||
|
||||
MP42MetadataItem *mediaKind = [MP42MetadataItem metadataItemWithIdentifier:MP42MetadataKeyMediaKind
|
||||
value:@(self.mediaKind)
|
||||
dataType:MP42MetadataItemDataTypeInteger
|
||||
extendedLanguageTag:nil];
|
||||
[metadata addMetadataItem:mediaKind];
|
||||
|
||||
if (self.contentRating || keep) {
|
||||
MP42MetadataItem *contentRating = [MP42MetadataItem metadataItemWithIdentifier:MP42MetadataKeyContentRating
|
||||
value:@(self.contentRating)
|
||||
dataType:MP42MetadataItemDataTypeInteger
|
||||
extendedLanguageTag:nil];
|
||||
[metadata addMetadataItem:contentRating];
|
||||
}
|
||||
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -33,21 +33,21 @@ public struct TheMovieDB: MetadataService {
|
||||
|
||||
// MARK: - Movie Search
|
||||
|
||||
private func metadata(forMoviePartialResult result: TMDBMovieSearchResult, language: String?) -> SBMetadataResult {
|
||||
let metadata = SBMetadataResult()
|
||||
private func metadata(forMoviePartialResult result: TMDBMovieSearchResult, language: String?) -> MetadataResult {
|
||||
let metadata = MetadataResult()
|
||||
|
||||
metadata.mediaKind = 9; // movie
|
||||
|
||||
metadata["TheMovieDB ID"] = result.id
|
||||
metadata[SBMetadataResultName] = result.title
|
||||
metadata[SBMetadataResultReleaseDate] = result.release_date
|
||||
metadata[SBMetadataResultDescription] = result.overview
|
||||
metadata[SBMetadataResultLongDescription] = result.overview;
|
||||
metadata[.serviceSeriesID] = result.id
|
||||
metadata[.name] = result.title
|
||||
metadata[.releaseDate] = result.release_date
|
||||
metadata[.description] = result.overview
|
||||
metadata[.longDescription] = result.overview;
|
||||
|
||||
return metadata
|
||||
}
|
||||
|
||||
public func search(movie: String, language: String) -> [SBMetadataResult] {
|
||||
public func search(movie: String, language: String) -> [MetadataResult] {
|
||||
let results = session.search(movie: movie, language: language)
|
||||
return results.map { metadata(forMoviePartialResult: $0, language: nil) }
|
||||
}
|
||||
@@ -58,14 +58,14 @@ public struct TheMovieDB: MetadataService {
|
||||
guard let items = items else { return nil }
|
||||
if items.count == 0 { return nil }
|
||||
return items.flatMap { (t: TMDBTuple) -> String? in return t.name }
|
||||
.reduce("", { (s1: String, s2: String) -> String in return s1 + (s1.count > 0 ? ", " : "") + s2 })
|
||||
.reduce("", { (s1: String, s2: String) -> String in return s1 + (s1.isEmpty ? "" : ", ") + s2 })
|
||||
}
|
||||
|
||||
private func cleanList(cast: [TMDBCast]?) -> String? {
|
||||
guard let cast = cast else { return nil }
|
||||
if cast.count == 0 { return nil }
|
||||
return cast.flatMap { (t: TMDBCast) -> String? in return t.name }
|
||||
.reduce("", { (s1: String, s2: String) -> String in return s1 + (s1.count > 0 ? ", " : "") + s2 })
|
||||
.reduce("", { (s1: String, s2: String) -> String in return s1 + (s1.isEmpty ? "" : ", ") + s2 })
|
||||
}
|
||||
|
||||
private func cleanList(crew: [TMDBCrew]?, job: String ) -> String? {
|
||||
@@ -73,7 +73,7 @@ public struct TheMovieDB: MetadataService {
|
||||
let found = crew.filter { (c: TMDBCrew) -> Bool in return c.job == job }
|
||||
if found.count == 0 { return nil }
|
||||
return found.flatMap { $0.name }
|
||||
.reduce("", { $0 + ($0.count > 0 ? ", " : "") + $1 })
|
||||
.reduce("", { $0 + ($0.isEmpty ? "" : ", " ) + $1 })
|
||||
}
|
||||
|
||||
private func cleanList(crew: [TMDBCrew]?, department: String ) -> String? {
|
||||
@@ -81,24 +81,23 @@ public struct TheMovieDB: MetadataService {
|
||||
let found = crew.filter { (c: TMDBCrew) -> Bool in return c.department == department }
|
||||
if found.count == 0 { return nil }
|
||||
return found.flatMap { $0.name }
|
||||
.reduce("", { $0 + ($0.count > 0 ? ", " : "") + $1 })
|
||||
.reduce("", { $0 + ($0.isEmpty ? "" : ", ") + $1 })
|
||||
}
|
||||
|
||||
// MARK: - Movie metadata loading
|
||||
|
||||
private func loadArtwork(filePath: String, baseURL: String, thumbSize: String, kind: String) -> RemoteImage? {
|
||||
private func loadArtwork(filePath: String, baseURL: String, thumbSize: String, kind: String) -> Artwork? {
|
||||
guard let url = URL(string: baseURL + "original" + filePath),
|
||||
let thumbURL = URL(string: baseURL + thumbSize + filePath) else { return nil }
|
||||
return RemoteImage(url: url, thumbURL: thumbURL, service: self.name, type: kind)
|
||||
return Artwork(url: url, thumbURL: thumbURL, service: self.name, type: kind)
|
||||
}
|
||||
|
||||
private func loadMovieArtworks(result: TMDBMovie) -> [RemoteImage] {
|
||||
var artworks: [RemoteImage] = Array()
|
||||
private func loadMovieArtworks(result: TMDBMovie) -> [Artwork] {
|
||||
var artworks: [Artwork] = Array()
|
||||
|
||||
// add iTunes artwork
|
||||
if let title = result.title, let iTunesMetadata = iTunesStore.quickiTunesSearch(movieName: title),
|
||||
let iTunesArtwork = iTunesMetadata.remoteArtworks {
|
||||
artworks.append(contentsOf: iTunesArtwork.toStruct())
|
||||
if let title = result.title, let iTunesMetadata = iTunesStore.quickiTunesSearch(movieName: title) {
|
||||
artworks.append(contentsOf: iTunesMetadata.remoteArtworks)
|
||||
}
|
||||
|
||||
// Add TheMovieDB artworks
|
||||
@@ -125,42 +124,42 @@ public struct TheMovieDB: MetadataService {
|
||||
return artworks
|
||||
}
|
||||
|
||||
private func metadata(forResult result: TMDBMovie, language: String?) -> SBMetadataResult {
|
||||
let metadata = SBMetadataResult()
|
||||
private func metadata(forResult result: TMDBMovie, language: String?) -> MetadataResult {
|
||||
let metadata = MetadataResult()
|
||||
|
||||
metadata.mediaKind = 9; // movie
|
||||
|
||||
metadata[SBMetadataResultName] = result.title
|
||||
metadata[SBMetadataResultReleaseDate] = result.release_date
|
||||
metadata[SBMetadataResultDescription] = result.overview
|
||||
metadata[SBMetadataResultLongDescription] = result.overview
|
||||
metadata[.name] = result.title
|
||||
metadata[.releaseDate] = result.release_date
|
||||
metadata[.description] = result.overview
|
||||
metadata[.longDescription] = result.overview
|
||||
|
||||
metadata[SBMetadataResultGenre] = cleanList(items: result.genres)
|
||||
metadata[SBMetadataResultStudio] = cleanList(items: result.production_companies)
|
||||
metadata[SBMetadataResultCast] = cleanList(cast: result.casts?.cast)
|
||||
metadata[SBMetadataResultDirector] = cleanList(crew: result.casts?.crew, job: "Director")
|
||||
metadata[SBMetadataResultProducers] = cleanList(crew: result.casts?.crew, job: "Producer")
|
||||
metadata[SBMetadataResultExecutiveProducer] = cleanList(crew: result.casts?.crew, job: "Executive Producer")
|
||||
metadata[SBMetadataResultScreenwriters] = cleanList(crew: result.casts?.crew, department: "Writing")
|
||||
metadata[SBMetadataResultComposer] = cleanList(crew: result.casts?.crew, job: "Original Music Composer")
|
||||
metadata[.genre] = cleanList(items: result.genres)
|
||||
metadata[.studio] = cleanList(items: result.production_companies)
|
||||
metadata[.cast] = cleanList(cast: result.casts?.cast)
|
||||
metadata[.director] = cleanList(crew: result.casts?.crew, job: "Director")
|
||||
metadata[.producers] = cleanList(crew: result.casts?.crew, job: "Producer")
|
||||
metadata[.executiveProducer] = cleanList(crew: result.casts?.crew, job: "Executive Producer")
|
||||
metadata[.screenwriters] = cleanList(crew: result.casts?.crew, department: "Writing")
|
||||
metadata[.composer] = cleanList(crew: result.casts?.crew, job: "Original Music Composer")
|
||||
|
||||
if let releases = result.releases {
|
||||
for release in releases.countries {
|
||||
if release.iso_3166_1 == "US" {
|
||||
metadata[SBMetadataResultRating] = MP42Ratings.defaultManager.ratingStringForiTunesCountry("USA",
|
||||
media: "movie",
|
||||
ratingString: release.certification)
|
||||
metadata[.rating] = MP42Ratings.defaultManager.ratingStringForiTunesCountry("USA",
|
||||
media: "movie",
|
||||
ratingString: release.certification)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
metadata.remoteArtworks = loadMovieArtworks(result: result).toClass()
|
||||
metadata.remoteArtworks = loadMovieArtworks(result: result)
|
||||
|
||||
return metadata
|
||||
}
|
||||
|
||||
public func loadMovieMetadata(_ partialMetadata: SBMetadataResult, language: String) -> SBMetadataResult {
|
||||
guard let movieID = partialMetadata["TheMovieDB ID"] as? Int,
|
||||
public func loadMovieMetadata(_ partialMetadata: MetadataResult, language: String) -> MetadataResult {
|
||||
guard let movieID = partialMetadata[.serviceSeriesID] as? Int,
|
||||
let result = session.fetch(movieID: movieID, language: language)
|
||||
else { return partialMetadata }
|
||||
|
||||
@@ -185,7 +184,7 @@ public struct TheMovieDB: MetadataService {
|
||||
let series = session.search(series: seriesName, language: language)
|
||||
let filteredSeries = series.filter { match(series: $0, name: seriesName) }.map { $0.id }
|
||||
|
||||
if filteredSeries.count > 0 {
|
||||
if filteredSeries.isEmpty == false {
|
||||
return filteredSeries
|
||||
}
|
||||
else if let firstItemsID = series.first?.id {
|
||||
@@ -196,8 +195,8 @@ public struct TheMovieDB: MetadataService {
|
||||
}
|
||||
}
|
||||
|
||||
private func loadTVShowArtworks(result: TMDBSeries) -> [RemoteImage] {
|
||||
var artworks: [RemoteImage] = Array()
|
||||
private func loadTVShowArtworks(result: TMDBSeries) -> [Artwork] {
|
||||
var artworks: [Artwork] = Array()
|
||||
|
||||
// Add TheMovieDB artworks
|
||||
if let config = session.fetchConfiguration()?.images,
|
||||
@@ -209,7 +208,7 @@ public struct TheMovieDB: MetadataService {
|
||||
for image in images {
|
||||
if let url = URL(string: imageBaseURL + "original" + image.file_path),
|
||||
let thumbURL = URL(string: imageBaseURL + posterThumbnailSize + image.file_path) {
|
||||
let remoteImage = RemoteImage(url: url, thumbURL: thumbURL, service: self.name, type: "poster")
|
||||
let remoteImage = Artwork(url: url, thumbURL: thumbURL, service: self.name, type: "poster")
|
||||
artworks.append(remoteImage)
|
||||
}
|
||||
}
|
||||
@@ -219,14 +218,14 @@ public struct TheMovieDB: MetadataService {
|
||||
let posterPath = result.poster_path,
|
||||
let url = URL(string: imageBaseURL + "original" + posterPath),
|
||||
let thumbURL = URL(string: imageBaseURL + posterThumbnailSize + posterPath) {
|
||||
let remoteImage = RemoteImage(url: url, thumbURL: thumbURL, service: self.name, type: "poster")
|
||||
let remoteImage = Artwork(url: url, thumbURL: thumbURL, service: self.name, type: "poster")
|
||||
artworks.append(remoteImage)
|
||||
}
|
||||
|
||||
if let backdropPath = result.backdrop_path,
|
||||
let url = URL(string: imageBaseURL + "original" + backdropPath),
|
||||
let thumbURL = URL(string: imageBaseURL + backdropThumbnailSize + backdropPath) {
|
||||
let remoteImage = RemoteImage(url: url, thumbURL: thumbURL, service: self.name, type: "backdrop")
|
||||
let remoteImage = Artwork(url: url, thumbURL: thumbURL, service: self.name, type: "backdrop")
|
||||
artworks.append(remoteImage)
|
||||
}
|
||||
}
|
||||
@@ -234,64 +233,64 @@ public struct TheMovieDB: MetadataService {
|
||||
return artworks
|
||||
}
|
||||
|
||||
private func metadata(forTVResult result: TMDBEpisode, info: TMDBSeries) -> SBMetadataResult {
|
||||
let metadata = SBMetadataResult()
|
||||
private func metadata(forTVResult result: TMDBEpisode, info: TMDBSeries) -> MetadataResult {
|
||||
let metadata = MetadataResult()
|
||||
|
||||
metadata.mediaKind = 10; // tv
|
||||
|
||||
// TV Show Info
|
||||
metadata["TheMovieDB Series ID"] = info.id
|
||||
metadata[SBMetadataResultSeriesName] = info.name
|
||||
metadata[SBMetadataResultSeriesDescription] = info.overview
|
||||
metadata[SBMetadataResultGenre] = cleanList(items: info.genres)
|
||||
metadata[SBMetadataResultNetwork] = cleanList(items: info.networks)
|
||||
metadata[.serviceSeriesID] = info.id
|
||||
metadata[.seriesName] = info.name
|
||||
metadata[.seriesDescription] = info.overview
|
||||
metadata[.genre] = cleanList(items: info.genres)
|
||||
metadata[.network] = cleanList(items: info.networks)
|
||||
|
||||
// Episode Info
|
||||
metadata["TheMovieDB Episodes ID"] = result.id
|
||||
metadata[SBMetadataResultName] = result.name
|
||||
metadata[SBMetadataResultReleaseDate] = result.air_date
|
||||
metadata[SBMetadataResultDescription] = result.overview
|
||||
metadata[SBMetadataResultLongDescription] = result.overview;
|
||||
metadata[.serviceEpisodeID] = result.id
|
||||
metadata[.name] = result.name
|
||||
metadata[.releaseDate] = result.air_date
|
||||
metadata[.description] = result.overview
|
||||
metadata[.longDescription] = result.overview;
|
||||
|
||||
metadata[SBMetadataResultSeason] = result.season_number
|
||||
metadata[SBMetadataResultEpisodeID] = String(format: "%d%02d", result.season_number ?? 0, result.episode_number ?? 0)
|
||||
metadata[SBMetadataResultEpisodeNumber] = result.episode_number
|
||||
metadata[SBMetadataResultTrackNumber] = result.episode_number
|
||||
metadata[.season] = result.season_number
|
||||
metadata[.episodeID] = String(format: "%d%02d", result.season_number ?? 0, result.episode_number ?? 0)
|
||||
metadata[.episodeNumber] = result.episode_number
|
||||
metadata[.trackNumber] = result.episode_number
|
||||
|
||||
let cast = cleanList(cast: info.credits?.cast)
|
||||
let guests = cleanList(cast: result.guest_stars)
|
||||
if let cast = cast, let guests = guests {
|
||||
metadata[SBMetadataResultCast] = cast + ", " + guests
|
||||
metadata[.cast] = cast + ", " + guests
|
||||
}
|
||||
else if let cast = cast {
|
||||
metadata[SBMetadataResultCast] = cast
|
||||
metadata[.cast] = cast
|
||||
}
|
||||
else if let guests = guests {
|
||||
metadata[SBMetadataResultCast] = guests
|
||||
metadata[.cast] = guests
|
||||
}
|
||||
|
||||
metadata[SBMetadataResultStudio] = cleanList(items: info.production_companies)
|
||||
metadata[SBMetadataResultDirector] = cleanList(crew: result.crew, job: "Director")
|
||||
metadata[SBMetadataResultProducers] = cleanList(crew: result.crew, job: "Producer")
|
||||
metadata[SBMetadataResultExecutiveProducer] = cleanList(crew: result.crew, job: "Executive Producer")
|
||||
metadata[SBMetadataResultScreenwriters] = cleanList(crew: result.crew, department: "Writing")
|
||||
metadata[SBMetadataResultComposer] = cleanList(crew: result.crew, job: "Original Music Composer")
|
||||
metadata[.studio] = cleanList(items: info.production_companies)
|
||||
metadata[.director] = cleanList(crew: result.crew, job: "Director")
|
||||
metadata[.producers] = cleanList(crew: result.crew, job: "Producer")
|
||||
metadata[.executiveProducer] = cleanList(crew: result.crew, job: "Executive Producer")
|
||||
metadata[.screenwriters] = cleanList(crew: result.crew, department: "Writing")
|
||||
metadata[.composer] = cleanList(crew: result.crew, job: "Original Music Composer")
|
||||
|
||||
if let ratings = info.content_ratings?.results {
|
||||
let USRating = ratings.filter { $0.iso_3166_1 == "US" }.flatMap { $0.rating }
|
||||
if let rating = USRating.first {
|
||||
metadata[SBMetadataResultRating] = MP42Ratings.defaultManager.ratingStringForiTunesCountry("USA",
|
||||
metadata[.rating] = MP42Ratings.defaultManager.ratingStringForiTunesCountry("USA",
|
||||
media: "TV",
|
||||
ratingString: rating)
|
||||
}
|
||||
}
|
||||
|
||||
metadata.remoteArtworks = loadTVShowArtworks(result: info).toClass()
|
||||
metadata.remoteArtworks = loadTVShowArtworks(result: info)
|
||||
|
||||
return metadata
|
||||
}
|
||||
|
||||
private func loadEpisodes(seriesID: Int, info: TMDBSeries, season: Int?, episode: Int?, language: String) -> [SBMetadataResult] {
|
||||
private func loadEpisodes(seriesID: Int, info: TMDBSeries, season: Int?, episode: Int?, language: String) -> [MetadataResult] {
|
||||
let episodes = session.fetch(episodeForSeriesID: seriesID, season: season, episode: episode, language: language)
|
||||
|
||||
let filteredEpisodes = episodes.filter {
|
||||
@@ -302,13 +301,13 @@ public struct TheMovieDB: MetadataService {
|
||||
return filteredEpisodes.map { metadata(forTVResult: $0, info: info) }
|
||||
}
|
||||
|
||||
public func search(TVSeries: String, language: String, season: Int?, episode: Int?) -> [SBMetadataResult] {
|
||||
public func search(TVSeries: String, language: String, season: Int?, episode: Int?) -> [MetadataResult] {
|
||||
let seriesIDs: [Int] = {
|
||||
let result = self.searchIDs(seriesName: TVSeries, language: language)
|
||||
return result.count > 0 ? result : self.searchIDs(seriesName: TVSeries, language: defaultLanguage)
|
||||
return result.isEmpty ? self.searchIDs(seriesName: TVSeries, language: defaultLanguage) : result
|
||||
}()
|
||||
|
||||
var results: [SBMetadataResult] = Array()
|
||||
var results: [MetadataResult] = Array()
|
||||
|
||||
for id in seriesIDs {
|
||||
guard let info = session.fetch(seriesID: id, language: language) else { continue }
|
||||
@@ -319,11 +318,11 @@ public struct TheMovieDB: MetadataService {
|
||||
return results
|
||||
}
|
||||
|
||||
public func loadTVMetadata(_ metadata: SBMetadataResult, language: String) -> SBMetadataResult {
|
||||
var artworks: [RemoteImage] = Array()
|
||||
public func loadTVMetadata(_ metadata: MetadataResult, language: String) -> MetadataResult {
|
||||
var artworks: [Artwork] = Array()
|
||||
|
||||
if let seriesID = metadata["TheMovieDB Series ID"] as? Int, let episodeID = metadata["TheMovieDB Episodes ID"] as? Int,
|
||||
let season = metadata[SBMetadataResultSeason] as? Int {
|
||||
if let seriesID = metadata[.serviceSeriesID] as? Int, let episodeID = metadata[.serviceEpisodeID] as? Int,
|
||||
let season = metadata[.season] as? Int {
|
||||
|
||||
let seasonImages = session.fetch(imagesForSeriesID: seriesID, season: String(season), language: language)
|
||||
let episodeImages = session.fetch(imagesForSeriesID: seriesID, episodeID: episodeID, season: String(season), language: language)
|
||||
@@ -338,20 +337,17 @@ public struct TheMovieDB: MetadataService {
|
||||
|
||||
}
|
||||
|
||||
if let existingArtworks = metadata.remoteArtworks {
|
||||
artworks.append(contentsOf: existingArtworks.toStruct())
|
||||
}
|
||||
artworks.append(contentsOf: metadata.remoteArtworks)
|
||||
|
||||
// add iTunes artwork
|
||||
if let name = metadata[SBMetadataResultSeriesName] as? String,
|
||||
if let name = metadata[.seriesName] as? String,
|
||||
let iTunesMetadata = iTunesStore.quickiTunesSearch(tvSeriesName: name,
|
||||
seasonNum: metadata[SBMetadataResultSeason] as? Int,
|
||||
episodeNum: metadata[SBMetadataResultEpisodeNumber] as? Int),
|
||||
let iTunesArtwork = iTunesMetadata.remoteArtworks {
|
||||
artworks.insert(contentsOf: iTunesArtwork.toStruct(), at: 0)
|
||||
seasonNum: metadata[.season] as? Int,
|
||||
episodeNum: metadata[.episodeNumber] as? Int) {
|
||||
artworks.insert(contentsOf: iTunesMetadata.remoteArtworks, at: 0)
|
||||
}
|
||||
|
||||
metadata.remoteArtworks = artworks.toClass()
|
||||
metadata.remoteArtworks = artworks
|
||||
|
||||
return metadata
|
||||
}
|
||||
|
||||
@@ -66,9 +66,9 @@ public struct TheTVDB : MetadataService, MetadataNameService {
|
||||
|
||||
private func searchIDs(seriesName: String, language: String) -> [Int] {
|
||||
let series = session.fetch(series: seriesName, language: language)
|
||||
let filteredSeries = series.filter { $0.status.count > 0 && match(series: $0, name: seriesName) }.map { $0.id }
|
||||
let filteredSeries = series.filter { $0.status.isEmpty == false && match(series: $0, name: seriesName) }.map { $0.id }
|
||||
|
||||
if filteredSeries.count > 0 {
|
||||
if filteredSeries.isEmpty == false {
|
||||
return filteredSeries
|
||||
}
|
||||
else if let firstItemsID = series.first?.id {
|
||||
@@ -82,18 +82,18 @@ public struct TheTVDB : MetadataService, MetadataNameService {
|
||||
// MARK: - Helpers
|
||||
|
||||
private func cleanList(actors: [TVDBActor]) -> String {
|
||||
return actors.map { $0.name } .reduce("", { $0 + ($0.count > 0 ? ", " : "") + $1 })
|
||||
return actors.map { $0.name } .reduce("", { $0 + ($0.isEmpty ? "" : ", ") + $1 })
|
||||
}
|
||||
|
||||
private func cleanList(names: [String]) -> String {
|
||||
return names.reduce("", { $0 + ($0.count > 0 ? ", " : "") + $1 })
|
||||
return names.reduce("", { $0 + ($0.isEmpty ? "" : ", ") + $1 })
|
||||
}
|
||||
|
||||
private func areInIncreasingOrder(ep1: SBMetadataResult, ep2: SBMetadataResult) -> Bool {
|
||||
guard let v1 = ep1[SBMetadataResultEpisodeNumber] as? Int,
|
||||
let v2 = ep2[SBMetadataResultEpisodeNumber] as? Int,
|
||||
let s1 = ep1[SBMetadataResultSeason] as? Int,
|
||||
let s2 = ep2[SBMetadataResultSeason] as? Int
|
||||
private func areInIncreasingOrder(ep1: MetadataResult, ep2: MetadataResult) -> Bool {
|
||||
guard let v1 = ep1[.episodeNumber] as? Int,
|
||||
let v2 = ep2[.episodeNumber] as? Int,
|
||||
let s1 = ep1[.season] as? Int,
|
||||
let s2 = ep2[.season] as? Int
|
||||
else { return false }
|
||||
|
||||
if s1 == s2 {
|
||||
@@ -104,40 +104,40 @@ public struct TheTVDB : MetadataService, MetadataNameService {
|
||||
}
|
||||
}
|
||||
|
||||
private func merge(episode: TVDBEpisode, info: TVDBSeriesInfo, actors: [TVDBActor]) -> SBMetadataResult {
|
||||
let result = SBMetadataResult()
|
||||
private func merge(episode: TVDBEpisode, info: TVDBSeriesInfo, actors: [TVDBActor]) -> MetadataResult {
|
||||
let result = MetadataResult()
|
||||
|
||||
result.mediaKind = 10
|
||||
|
||||
// TV Show Info
|
||||
result["TheTVDB Series ID"] = info.id
|
||||
result[SBMetadataResultSeriesName] = info.seriesName
|
||||
result[SBMetadataResultSeriesDescription] = info.overview
|
||||
result[SBMetadataResultGenre] = cleanList(names: info.genre)
|
||||
result[SBMetadataResultNetwork] = info.network
|
||||
result[.serviceSeriesID] = info.id
|
||||
result[.seriesName] = info.seriesName
|
||||
result[.seriesDescription] = info.overview
|
||||
result[.genre] = cleanList(names: info.genre)
|
||||
result[.network] = info.network
|
||||
|
||||
// Episode Info
|
||||
result["TheTVDB Episodes ID"] = episode.id
|
||||
result[SBMetadataResultName] = episode.episodeName
|
||||
result[SBMetadataResultReleaseDate] = episode.firstAired
|
||||
result[SBMetadataResultDescription] = episode.overview
|
||||
result[SBMetadataResultLongDescription] = episode.overview
|
||||
result[.serviceEpisodeID] = episode.id
|
||||
result[.name] = episode.episodeName
|
||||
result[.releaseDate] = episode.firstAired
|
||||
result[.description] = episode.overview
|
||||
result[.longDescription] = episode.overview
|
||||
|
||||
result[SBMetadataResultSeason] = episode.airedSeason
|
||||
result[.season] = episode.airedSeason
|
||||
|
||||
result[SBMetadataResultEpisodeID] = String(format: "%d%02d", episode.airedSeason, episode.airedEpisodeNumber)
|
||||
result[SBMetadataResultEpisodeNumber] = episode.airedEpisodeNumber
|
||||
result[SBMetadataResultTrackNumber] = episode.airedEpisodeNumber
|
||||
result[.episodeID] = String(format: "%d%02d", episode.airedSeason, episode.airedEpisodeNumber)
|
||||
result[.episodeNumber] = episode.airedEpisodeNumber
|
||||
result[.trackNumber] = episode.airedEpisodeNumber
|
||||
|
||||
// Rating
|
||||
if let rating = info.rating, rating.count > 0 {
|
||||
result[SBMetadataResultRating] = MP42Ratings.defaultManager.ratingStringForiTunesCountry("USA",
|
||||
media: "TV",
|
||||
ratingString: rating)
|
||||
result[.rating] = MP42Ratings.defaultManager.ratingStringForiTunesCountry("USA",
|
||||
media: "TV",
|
||||
ratingString: rating)
|
||||
}
|
||||
|
||||
// Actors
|
||||
result[SBMetadataResultCast] = cleanList(actors: actors)
|
||||
result[.cast] = cleanList(actors: actors)
|
||||
|
||||
// TheTVDB does not provide the following fields normally associated with TV shows in SBMetadataResult:
|
||||
// "Copyright", "Comments", "Producers", "Artist"
|
||||
@@ -145,7 +145,7 @@ public struct TheTVDB : MetadataService, MetadataNameService {
|
||||
return result
|
||||
}
|
||||
|
||||
private func loadEpisodes(info: TVDBSeriesInfo, actors: [TVDBActor], season: Int?, episode: Int?, language: String) -> [SBMetadataResult] {
|
||||
private func loadEpisodes(info: TVDBSeriesInfo, actors: [TVDBActor], season: Int?, episode: Int?, language: String) -> [MetadataResult] {
|
||||
let episodes = session.fetch(episodeForSeriesID: info.id, season: season, episode: episode, language: language)
|
||||
let filteredEpisodes = episodes.filter {
|
||||
(season != nil ? $0.airedSeason == season : true) &&
|
||||
@@ -164,21 +164,21 @@ public struct TheTVDB : MetadataService, MetadataNameService {
|
||||
static let seriesInfo = NilValues(rawValue: 2)
|
||||
}
|
||||
|
||||
private func checkMissingValues(results: [SBMetadataResult]) -> NilValues {
|
||||
private func checkMissingValues(results: [MetadataResult]) -> NilValues {
|
||||
|
||||
var options: NilValues = []
|
||||
|
||||
for result in results {
|
||||
if result[SBMetadataResultSeriesName] == nil {
|
||||
if result[.seriesName] == nil {
|
||||
options.insert(.seriesInfo)
|
||||
}
|
||||
if result[SBMetadataResultName] == nil {
|
||||
if result[.name] == nil {
|
||||
options.insert(.episodesInfo)
|
||||
}
|
||||
if result[SBMetadataResultLongDescription] == nil {
|
||||
if result[.longDescription] == nil {
|
||||
options.insert(.episodesInfo)
|
||||
}
|
||||
if result[SBMetadataResultSeriesDescription] == nil {
|
||||
if result[.seriesDescription] == nil {
|
||||
options.insert(.seriesInfo)
|
||||
}
|
||||
}
|
||||
@@ -186,50 +186,50 @@ public struct TheTVDB : MetadataService, MetadataNameService {
|
||||
return options
|
||||
}
|
||||
|
||||
private func merge(enResults: [SBMetadataResult], results: [SBMetadataResult]) {
|
||||
private func merge(enResults: [MetadataResult], results: [MetadataResult]) {
|
||||
if enResults.count != results.count { return }
|
||||
|
||||
for (index, result) in results.enumerated() {
|
||||
let enResult = enResults[index]
|
||||
|
||||
if result[SBMetadataResultSeriesName] == nil {
|
||||
result[SBMetadataResultSeriesName] = enResult[SBMetadataResultSeriesName]
|
||||
if result[.seriesName] == nil {
|
||||
result[.seriesName] = enResult[.seriesName]
|
||||
}
|
||||
if result[SBMetadataResultName] == nil {
|
||||
result[SBMetadataResultName] = enResult[SBMetadataResultName]
|
||||
if result[.name] == nil {
|
||||
result[.name] = enResult[.name]
|
||||
}
|
||||
if result[SBMetadataResultLongDescription] == nil {
|
||||
result[SBMetadataResultLongDescription] = enResult[SBMetadataResultLongDescription]
|
||||
result[SBMetadataResultDescription] = enResult[SBMetadataResultDescription]
|
||||
if result[.longDescription] == nil {
|
||||
result[.longDescription] = enResult[.longDescription]
|
||||
result[.description] = enResult[.description]
|
||||
}
|
||||
if result[SBMetadataResultSeriesDescription] == nil {
|
||||
result[SBMetadataResultSeriesDescription] = enResult[SBMetadataResultSeriesDescription]
|
||||
if result[.seriesDescription] == nil {
|
||||
result[.seriesDescription] = enResult[.seriesDescription]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func merge(info: TVDBSeriesInfo, results: [SBMetadataResult]) {
|
||||
private func merge(info: TVDBSeriesInfo, results: [MetadataResult]) {
|
||||
let name = info.seriesName
|
||||
for result in results {
|
||||
result[SBMetadataResultSeriesName] = name
|
||||
result[.seriesName] = name
|
||||
}
|
||||
|
||||
if let overview = info.overview {
|
||||
for result in results {
|
||||
result[SBMetadataResultSeriesDescription] = overview
|
||||
result[.seriesDescription] = overview
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - TV Search
|
||||
|
||||
public func search(TVSeries: String, language: String, season: Int?, episode: Int?) -> [SBMetadataResult] {
|
||||
public func search(TVSeries: String, language: String, season: Int?, episode: Int?) -> [MetadataResult] {
|
||||
let seriesIDs: [Int] = {
|
||||
let result = self.searchIDs(seriesName: TVSeries, language: language)
|
||||
return result.count > 0 ? result : self.searchIDs(seriesName: TVSeries, language: defaultLanguage)
|
||||
return result.isEmpty ? self.searchIDs(seriesName: TVSeries, language: defaultLanguage) : result
|
||||
}()
|
||||
|
||||
var results: [SBMetadataResult] = Array()
|
||||
var results: [MetadataResult] = Array()
|
||||
|
||||
for id in seriesIDs {
|
||||
guard let info: TVDBSeriesInfo = {
|
||||
@@ -263,26 +263,26 @@ public struct TheTVDB : MetadataService, MetadataNameService {
|
||||
|
||||
// MARK: - Additional metadata
|
||||
|
||||
private func loadiTunesArtwork(_ metadata: SBMetadataResult) -> [RemoteImage] {
|
||||
guard let name = metadata[SBMetadataResultSeriesName] as? String,
|
||||
let seasonNum = metadata[SBMetadataResultSeason] as? Int,
|
||||
let episodeNum = metadata[SBMetadataResultEpisodeNumber] as? Int,
|
||||
private func loadiTunesArtwork(_ metadata: MetadataResult) -> [Artwork] {
|
||||
guard let name = metadata[.seriesName] as? String,
|
||||
let seasonNum = metadata[.season] as? Int,
|
||||
let episodeNum = metadata[.episodeNumber] as? Int,
|
||||
let result = iTunesStore.quickiTunesSearch(tvSeriesName: name, seasonNum: seasonNum, episodeNum: episodeNum)
|
||||
else { return [] }
|
||||
|
||||
return result.remoteArtworks?.toStruct() ?? []
|
||||
return result.remoteArtworks
|
||||
}
|
||||
|
||||
private func loadSquareTVArtwork(_ metadata: SBMetadataResult) -> [RemoteImage] {
|
||||
guard let seasonNum = metadata[SBMetadataResultSeason] as? Int,
|
||||
let seriesId = metadata["TheTVDB Series ID"] as? Int
|
||||
private func loadSquareTVArtwork(_ metadata: MetadataResult) -> [Artwork] {
|
||||
guard let seasonNum = metadata[.season] as? Int,
|
||||
let seriesId = metadata[.serviceSeriesID] as? Int
|
||||
else { return [] }
|
||||
|
||||
return SquaredTVArt().search(theTVDBSeriesId: seriesId, season: seasonNum)
|
||||
}
|
||||
|
||||
private func loadTVArtwork(seriesID: Int, type: TVDBArtworkType, season: String, language: String) -> [RemoteImage] {
|
||||
var artworks: [RemoteImage] = Array()
|
||||
private func loadTVArtwork(seriesID: Int, type: TVDBArtworkType, season: String, language: String) -> [Artwork] {
|
||||
var artworks: [Artwork] = Array()
|
||||
let images: [TVDBImage] = {
|
||||
var result = session.fetch(images: seriesID, type: type, language: language)
|
||||
if result.count == 0 || language != defaultLanguage {
|
||||
@@ -303,39 +303,39 @@ public struct TheTVDB : MetadataService, MetadataNameService {
|
||||
}
|
||||
|
||||
if selected {
|
||||
artworks.append(RemoteImage(url: fileURL, thumbURL: thumbURL, service: self.name, type: type.rawValue))
|
||||
artworks.append(Artwork(url: fileURL, thumbURL: thumbURL, service: self.name, type: type.rawValue))
|
||||
}
|
||||
}
|
||||
return artworks
|
||||
}
|
||||
|
||||
public func loadTVMetadata(_ metadata: SBMetadataResult, language: String) -> SBMetadataResult {
|
||||
guard let id = metadata["TheTVDB Episodes ID"] as? Int else { return metadata }
|
||||
guard let seriesId = metadata["TheTVDB Series ID"] as? Int else { return metadata }
|
||||
public func loadTVMetadata(_ metadata: MetadataResult, language: String) -> MetadataResult {
|
||||
guard let id = metadata[.serviceEpisodeID] as? Int else { return metadata }
|
||||
guard let seriesId = metadata[.serviceSeriesID] as? Int else { return metadata }
|
||||
|
||||
var artworks: [RemoteImage] = Array()
|
||||
var artworks: [Artwork] = Array()
|
||||
|
||||
if let info = session.fetch(episodeInfo: id, language: language) {
|
||||
metadata[SBMetadataResultDirector] = cleanList(names: info.directors)
|
||||
metadata[SBMetadataResultScreenwriters] = cleanList(names: info.writers)
|
||||
metadata[.director] = cleanList(names: info.directors)
|
||||
metadata[.screenwriters] = cleanList(names: info.writers)
|
||||
|
||||
let guests = cleanList(names: info.guestStars)
|
||||
if let actors = metadata[SBMetadataResultCast] as? String {
|
||||
if let actors = metadata[.cast] as? String {
|
||||
if actors.count > 0 && guests.count > 0 {
|
||||
metadata[SBMetadataResultCast] = actors + ", " + guests
|
||||
metadata[.cast] = actors + ", " + guests
|
||||
}
|
||||
} else if guests.count > 0 {
|
||||
metadata[SBMetadataResultCast] = guests
|
||||
metadata[.cast] = guests
|
||||
}
|
||||
|
||||
if let filename = info.filename, let url = URL(string: TheTVDB.bannerPath + filename) {
|
||||
artworks.append(RemoteImage(url: url, thumbURL: url, service: self.name, type: "episode"))
|
||||
artworks.append(Artwork(url: url, thumbURL: url, service: self.name, type: "episode"))
|
||||
}
|
||||
}
|
||||
|
||||
// Get additionals images
|
||||
if let season = metadata[SBMetadataResultSeason] as? Int {
|
||||
var iTunesImage = [RemoteImage](), squareTVArt = [RemoteImage](), seasonImages = [RemoteImage](), posterImages = [RemoteImage]()
|
||||
if let season = metadata[.season] as? Int {
|
||||
var iTunesImage = [Artwork](), squareTVArt = [Artwork](), seasonImages = [Artwork](), posterImages = [Artwork]()
|
||||
let group = DispatchGroup()
|
||||
DispatchQueue.global(priority: .default).async(group: group) {
|
||||
iTunesImage = self.loadiTunesArtwork(metadata)
|
||||
@@ -357,18 +357,18 @@ public struct TheTVDB : MetadataService, MetadataNameService {
|
||||
artworks.append(contentsOf: posterImages)
|
||||
}
|
||||
|
||||
metadata.remoteArtworks = artworks.toClass()
|
||||
metadata.remoteArtworks = artworks
|
||||
|
||||
return metadata
|
||||
}
|
||||
|
||||
// MARK: - Unimplemented movie search
|
||||
|
||||
public func search(movie: String, language: String) -> [SBMetadataResult] {
|
||||
public func search(movie: String, language: String) -> [MetadataResult] {
|
||||
return []
|
||||
}
|
||||
|
||||
public func loadMovieMetadata(_ metadata: SBMetadataResult, language: String) -> SBMetadataResult {
|
||||
public func loadMovieMetadata(_ metadata: MetadataResult, language: String) -> MetadataResult {
|
||||
return metadata
|
||||
}
|
||||
}
|
||||
@@ -129,7 +129,7 @@ final public class TheTVDBService {
|
||||
|
||||
public var languages: [String] {
|
||||
get {
|
||||
if let result = savedLanguages, result.data.count > 0 {
|
||||
if let result = savedLanguages, result.data.isEmpty == false {
|
||||
return result.data
|
||||
}
|
||||
else if let result = fetchLanguages() {
|
||||
|
||||
@@ -76,12 +76,12 @@ public struct iTunesStore: MetadataService {
|
||||
|
||||
// MARK: - Quick iTunes search for metadata
|
||||
|
||||
public static func quickiTunesSearch(tvSeriesName: String, seasonNum: Int?, episodeNum: Int?) -> SBMetadataResult? {
|
||||
public static func quickiTunesSearch(tvSeriesName: String, seasonNum: Int?, episodeNum: Int?) -> MetadataResult? {
|
||||
guard let language = UserDefaults.standard.string(forKey: "SBMetadataPreference|TV|iTunes Store|Language") else { return nil }
|
||||
return iTunesStore().search(TVSeries: tvSeriesName, language: language, season: seasonNum, episode: episodeNum).first
|
||||
}
|
||||
|
||||
public static func quickiTunesSearch(movieName: String) -> SBMetadataResult? {
|
||||
public static func quickiTunesSearch(movieName: String) -> MetadataResult? {
|
||||
guard let language = UserDefaults.standard.string(forKey: "SBMetadataPreference|Movie|iTunes Store|Language") else { return nil }
|
||||
return iTunesStore().search(movie: movieName, language: language).first
|
||||
}
|
||||
@@ -157,11 +157,11 @@ public struct iTunesStore: MetadataService {
|
||||
|
||||
// MARK: - Helpers
|
||||
|
||||
private func areInIncreasingOrder(ep1: SBMetadataResult, ep2: SBMetadataResult) -> Bool {
|
||||
guard let v1 = ep1[SBMetadataResultEpisodeNumber] as? Int,
|
||||
let v2 = ep2[SBMetadataResultEpisodeNumber] as? Int,
|
||||
let s1 = ep1[SBMetadataResultSeason] as? Int,
|
||||
let s2 = ep2[SBMetadataResultSeason] as? Int
|
||||
private func areInIncreasingOrder(ep1: MetadataResult, ep2: MetadataResult) -> Bool {
|
||||
guard let v1 = ep1[.episodeNumber] as? Int,
|
||||
let v2 = ep2[.episodeNumber] as? Int,
|
||||
let s1 = ep1[.season] as? Int,
|
||||
let s2 = ep2[.season] as? Int
|
||||
else { return false }
|
||||
|
||||
if s1 == s2 {
|
||||
@@ -172,7 +172,7 @@ public struct iTunesStore: MetadataService {
|
||||
}
|
||||
}
|
||||
|
||||
private func artwork(url: URL?, isTVShow: Bool) -> RemoteImage? {
|
||||
private func artwork(url: URL?, isTVShow: Bool) -> Artwork? {
|
||||
guard let regex = try? NSRegularExpression(pattern: "(\\{.*?\\})", options: [.caseInsensitive]),
|
||||
let url = url else { return nil }
|
||||
|
||||
@@ -186,7 +186,7 @@ public struct iTunesStore: MetadataService {
|
||||
|
||||
if let artworkURL = URL(string: text),
|
||||
let artworkFullSizeURL = URL(string: text.replacingOccurrences(of: "100x100bb", with: replacement)) {
|
||||
return RemoteImage(url:artworkFullSizeURL, thumbURL: artworkURL, service: self.name, type: "")
|
||||
return Artwork(url:artworkFullSizeURL, thumbURL: artworkURL, service: self.name, type: "")
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -270,7 +270,7 @@ public struct iTunesStore: MetadataService {
|
||||
return nil
|
||||
}
|
||||
|
||||
public func search(TVSeries: String, language: String, season: Int?, episode: Int?) -> [SBMetadataResult] {
|
||||
public func search(TVSeries: String, language: String, season: Int?, episode: Int?) -> [MetadataResult] {
|
||||
guard let store = iTunesStore.store(language: language) else { return [] }
|
||||
|
||||
// Determine artistId/collectionId
|
||||
@@ -288,11 +288,11 @@ public struct iTunesStore: MetadataService {
|
||||
var filteredResults = results.results.filter { $0.wrapperType == "track" } .map { metadata(forTVResult: $0, store: store) }
|
||||
|
||||
if let season = season {
|
||||
filteredResults = filteredResults.filter { $0[SBMetadataResultSeason] as! Int == season }
|
||||
filteredResults = filteredResults.filter { $0[.season] as! Int == season }
|
||||
}
|
||||
|
||||
if let episode = episode {
|
||||
filteredResults = filteredResults.filter { $0[SBMetadataResultEpisodeNumber] as! Int == episode }
|
||||
filteredResults = filteredResults.filter { $0[.episodeNumber] as! Int == episode }
|
||||
}
|
||||
|
||||
return filteredResults.sorted(by: areInIncreasingOrder)
|
||||
@@ -301,25 +301,25 @@ public struct iTunesStore: MetadataService {
|
||||
return []
|
||||
}
|
||||
|
||||
private func metadata(forTVResult result: Track, store: Store) -> SBMetadataResult {
|
||||
let metadata = SBMetadataResult()
|
||||
private func metadata(forTVResult result: Track, store: Store) -> MetadataResult {
|
||||
let metadata = MetadataResult()
|
||||
|
||||
metadata.mediaKind = 10 // TV show
|
||||
|
||||
metadata[SBMetadataResultName] = result.trackName
|
||||
metadata[SBMetadataResultReleaseDate] = result.releaseDate
|
||||
metadata[SBMetadataResultDescription] = result.shortDescription
|
||||
metadata[SBMetadataResultLongDescription] = result.longDescription
|
||||
metadata[SBMetadataResultSeriesName] = result.artistName
|
||||
metadata[SBMetadataResultGenre] = result.primaryGenreName
|
||||
metadata[.name] = result.trackName
|
||||
metadata[.releaseDate] = result.releaseDate
|
||||
metadata[.description] = result.shortDescription
|
||||
metadata[.longDescription] = result.longDescription
|
||||
metadata[.seriesName] = result.artistName
|
||||
metadata[.genre] = result.primaryGenreName
|
||||
|
||||
metadata[SBMetadataResultEpisodeNumber] = result.trackNumber
|
||||
metadata[.episodeNumber] = result.trackNumber
|
||||
if let trackNumber = result.trackNumber, let trackCount = result.trackCount {
|
||||
metadata[SBMetadataResultTrackNumber] = "\(trackNumber)/\(trackCount)"
|
||||
metadata[.trackNumber] = "\(trackNumber)/\(trackCount)"
|
||||
}
|
||||
metadata[SBMetadataResultDiskNumber] = "1/1"
|
||||
metadata[SBMetadataResultArtistID] = result.artistId
|
||||
metadata[SBMetadataResultPlaylistID] = result.collectionId
|
||||
metadata[.diskNumber] = "1/1"
|
||||
metadata[.artistID] = result.artistId
|
||||
metadata[.playlistID] = result.collectionId
|
||||
|
||||
if let s = result.collectionName?.lowercased() {
|
||||
var separated = s.components(separatedBy: ", \(store.season)")
|
||||
@@ -334,21 +334,21 @@ public struct iTunesStore: MetadataService {
|
||||
let trackCount = result.trackCount ?? 1
|
||||
let season = separated.count > 1 ? Int(separated[1].trimmingCharacters(in: CharacterSet.whitespaces)) ?? 1 : trackCount > 1 ? 1 : 0
|
||||
|
||||
metadata[SBMetadataResultSeason] = season
|
||||
metadata[.season] = season
|
||||
if let trackNumber = result.trackNumber {
|
||||
metadata[SBMetadataResultEpisodeID] = String(format:"%d%02d", season, trackNumber)
|
||||
metadata[.episodeID] = String(format:"%d%02d", season, trackNumber)
|
||||
}
|
||||
}
|
||||
|
||||
if let contentAdvisoryRating = result.contentAdvisoryRating {
|
||||
metadata[SBMetadataResultRating] = MP42Ratings.defaultManager.ratingStringForiTunesCountry(store.country,
|
||||
metadata[.rating] = MP42Ratings.defaultManager.ratingStringForiTunesCountry(store.country,
|
||||
media: metadata.mediaKind == 9 ? "movie" : "TV",
|
||||
ratingString: contentAdvisoryRating)
|
||||
}
|
||||
|
||||
metadata[SBMetadataResultITunesCountry] = store.storeCode
|
||||
metadata[SBMetadataResultITunesURL] = result.trackViewUrl
|
||||
metadata[SBMetadataResultContentID] = result.trackId
|
||||
metadata[.iTunesCountry] = store.storeCode
|
||||
metadata[.iTunesURL] = result.trackViewUrl
|
||||
metadata[.contentID] = result.trackId
|
||||
|
||||
if result.trackExplicitness == "explicit" {
|
||||
metadata.contentRating = 4
|
||||
@@ -358,7 +358,7 @@ public struct iTunesStore: MetadataService {
|
||||
}
|
||||
|
||||
if let artwork = artwork(url: result.artworkUrl100, isTVShow: true) {
|
||||
metadata.remoteArtworks = [artwork].toClass()
|
||||
metadata.remoteArtworks = [artwork]
|
||||
}
|
||||
|
||||
return metadata
|
||||
@@ -366,7 +366,7 @@ public struct iTunesStore: MetadataService {
|
||||
|
||||
// MARK: - Search for movie metadata
|
||||
|
||||
public func search(movie: String, language: String) -> [SBMetadataResult] {
|
||||
public func search(movie: String, language: String) -> [MetadataResult] {
|
||||
guard let store = iTunesStore.store(language: language),
|
||||
let url = URL(string: "https://itunes.apple.com/search?country=\(store.country2)&lang=\(store.language2)&term=\(movie.urlEncoded())&entity=movie&limit=150"),
|
||||
let results = sendJSONRequest(url: url, type: Wrapper<Track>.self)
|
||||
@@ -376,27 +376,27 @@ public struct iTunesStore: MetadataService {
|
||||
return filteredResults.map { metadata(forMoviePartialResult: $0, store: store) }
|
||||
}
|
||||
|
||||
private func metadata(forMoviePartialResult result: Track, store: Store) -> SBMetadataResult {
|
||||
let metadata = SBMetadataResult()
|
||||
private func metadata(forMoviePartialResult result: Track, store: Store) -> MetadataResult {
|
||||
let metadata = MetadataResult()
|
||||
|
||||
metadata.mediaKind = 9 // movie
|
||||
|
||||
metadata[SBMetadataResultName] = result.trackName
|
||||
metadata[SBMetadataResultReleaseDate] = result.releaseDate
|
||||
metadata[SBMetadataResultDescription] = result.longDescription
|
||||
metadata[SBMetadataResultLongDescription] = result.longDescription
|
||||
metadata[SBMetadataResultDirector] = result.artistName
|
||||
metadata[SBMetadataResultGenre] = result.primaryGenreName
|
||||
metadata[.name] = result.trackName
|
||||
metadata[.releaseDate] = result.releaseDate
|
||||
metadata[.description] = result.longDescription
|
||||
metadata[.longDescription] = result.longDescription
|
||||
metadata[.director] = result.artistName
|
||||
metadata[.genre] = result.primaryGenreName
|
||||
|
||||
if let contentAdvisoryRating = result.contentAdvisoryRating {
|
||||
metadata[SBMetadataResultRating] = MP42Ratings.defaultManager.ratingStringForiTunesCountry(store.country,
|
||||
metadata[.rating] = MP42Ratings.defaultManager.ratingStringForiTunesCountry(store.country,
|
||||
media: metadata.mediaKind == 9 ? "movie" : "TV",
|
||||
ratingString: contentAdvisoryRating)
|
||||
}
|
||||
|
||||
metadata[SBMetadataResultITunesCountry] = store.storeCode
|
||||
metadata[SBMetadataResultITunesURL] = result.trackViewUrl
|
||||
metadata[SBMetadataResultContentID] = result.trackId
|
||||
metadata[.iTunesCountry] = store.storeCode
|
||||
metadata[.iTunesURL] = result.trackViewUrl
|
||||
metadata[.contentID] = result.trackId
|
||||
|
||||
if result.trackExplicitness == "explicit" {
|
||||
metadata.contentRating = 4
|
||||
@@ -406,7 +406,7 @@ public struct iTunesStore: MetadataService {
|
||||
}
|
||||
|
||||
if let artwork = artwork(url: result.artworkUrl100, isTVShow: false) {
|
||||
metadata.remoteArtworks = [artwork].toClass()
|
||||
metadata.remoteArtworks = [artwork]
|
||||
}
|
||||
|
||||
return metadata
|
||||
@@ -414,14 +414,14 @@ public struct iTunesStore: MetadataService {
|
||||
|
||||
// MARK: - Load additional metadata
|
||||
|
||||
public func loadTVMetadata(_ metadata: SBMetadataResult, language: String) -> SBMetadataResult {
|
||||
public func loadTVMetadata(_ metadata: MetadataResult, language: String) -> MetadataResult {
|
||||
guard let store = iTunesStore.store(language: language),
|
||||
let playlistID = metadata[SBMetadataResultPlaylistID] as? Int,
|
||||
let playlistID = metadata[.playlistID] as? Int,
|
||||
let url = URL(string: "https://itunes.apple.com/lookup?country=\(store.country2)&lang=\(store.language2.lowercased())&id=\(playlistID)")
|
||||
else { return metadata }
|
||||
|
||||
if let results = sendJSONRequest(url: url, type: Wrapper<Collection>.self) {
|
||||
metadata[SBMetadataResultSeriesDescription] = results.results.first?.longDescription
|
||||
metadata[.seriesDescription] = results.results.first?.longDescription
|
||||
}
|
||||
|
||||
return metadata
|
||||
@@ -441,17 +441,17 @@ public struct iTunesStore: MetadataService {
|
||||
return []
|
||||
}
|
||||
|
||||
public func loadMovieMetadata(_ metadata: SBMetadataResult, language: String) -> SBMetadataResult {
|
||||
public func loadMovieMetadata(_ metadata: MetadataResult, language: String) -> MetadataResult {
|
||||
guard let store = iTunesStore.store(language: language),
|
||||
let url = metadata[SBMetadataResultITunesURL] as? URL,
|
||||
let url = metadata[.iTunesURL] as? URL,
|
||||
let data = URLSession.data(from: url),
|
||||
let xml = try? XMLDocument(data: data, options: .documentTidyHTML)
|
||||
else { return metadata }
|
||||
|
||||
metadata[SBMetadataResultCast] = read(type: store.actor, in: xml).joined(separator: ", ")
|
||||
metadata[SBMetadataResultDirector] = read(type: store.director, in: xml).joined(separator: ", ")
|
||||
metadata[SBMetadataResultProducers] = read(type: store.producer, in: xml).joined(separator: ", ")
|
||||
metadata[SBMetadataResultScreenwriters] = read(type: store.screenwriter, in: xml).joined(separator: ", ")
|
||||
metadata[.cast] = read(type: store.actor, in: xml).joined(separator: ", ")
|
||||
metadata[.director] = read(type: store.director, in: xml).joined(separator: ", ")
|
||||
metadata[.producers] = read(type: store.producer, in: xml).joined(separator: ", ")
|
||||
metadata[.screenwriters] = read(type: store.screenwriter, in: xml).joined(separator: ", ")
|
||||
|
||||
if let nodes = try? xml.nodes(forXPath: "//li[@class='copyright']") {
|
||||
for node in nodes {
|
||||
@@ -464,7 +464,7 @@ public struct iTunesStore: MetadataService {
|
||||
range: copyright.startIndex ..< copyright.endIndex, locale: nil) {
|
||||
copyright.removeSubrange(range)
|
||||
}
|
||||
metadata[SBMetadataResultCopyright] = copyright
|
||||
metadata[.copyright] = copyright
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
import Cocoa
|
||||
|
||||
@objc(SBMetadataSearchControllerDelegate) protocol MetadataSearchControllerDelegate {
|
||||
func didSelect(metadata: SBMetadataResult)
|
||||
func didSelect(metadata: MetadataResult)
|
||||
}
|
||||
|
||||
@objc(SBMetadataSearchController) class MetadataSearchController: NSWindowController, NSTableViewDataSource, NSTableViewDelegate, NSComboBoxDelegate, NSComboBoxDataSource, NSTextFieldDelegate, ArtworkSelectorControllerDelegate {
|
||||
@@ -43,15 +43,15 @@ import Cocoa
|
||||
// MARK: - ComboBox
|
||||
|
||||
private var tvSeriesNameSearchArray: [String]
|
||||
private var nameSearchTask: MetadataSearchTask?
|
||||
private var nameSearchTask: Runnable?
|
||||
|
||||
// MARK: UI State
|
||||
private enum MetadataSearchState {
|
||||
case none
|
||||
case searching(search: MetadataSearch, task: MetadataSearchTask)
|
||||
case completed(search: MetadataSearch, results: [SBMetadataResult], selectedResult: SBMetadataResult)
|
||||
case additionalSearch(search: MetadataSearch, result: SBMetadataResult, task: MetadataSearchTask)
|
||||
case closing(search: MetadataSearch, result: SBMetadataResult)
|
||||
case searching(search: MetadataSearch, task: Runnable)
|
||||
case completed(search: MetadataSearch, results: [MetadataResult], selectedResult: MetadataResult)
|
||||
case additionalSearch(search: MetadataSearch, result: MetadataResult, task: Runnable)
|
||||
case closing(search: MetadataSearch, result: MetadataResult)
|
||||
}
|
||||
|
||||
private var state: MetadataSearchState
|
||||
@@ -143,7 +143,7 @@ import Cocoa
|
||||
popUpButton.removeAllItems()
|
||||
popUpButton.addItems(withTitles: service.languages.map { service.languageType.displayName(language: $0) })
|
||||
|
||||
let type: MetadataSearch.Kind = popUpButton == movieLanguage ? .movie : .tvShow
|
||||
let type: MetadataType = popUpButton == movieLanguage ? .movie : .tvShow
|
||||
|
||||
popUpButton.selectItem(withTitle: MetadataSearch.defaultLanguage(service: service, type: type))
|
||||
|
||||
@@ -213,7 +213,7 @@ import Cocoa
|
||||
func comboBoxSelectionDidChange(_ notification: Notification) {
|
||||
let index = tvSeriesName.indexOfSelectedItem
|
||||
if index > -1, let dataSource = tvSeriesName.dataSource,
|
||||
let name = dataSource.comboBox?(tvSeriesName, objectValueForItemAt: index) as? String, name.count > 0 {
|
||||
let name = dataSource.comboBox?(tvSeriesName, objectValueForItemAt: index) as? String, name.isEmpty == false {
|
||||
tvSeriesName.stringValue = name
|
||||
updateSearchButtonVisibility()
|
||||
}
|
||||
@@ -268,7 +268,7 @@ import Cocoa
|
||||
}
|
||||
}
|
||||
|
||||
private func searchDone(search: MetadataSearch, results: [SBMetadataResult]) {
|
||||
private func searchDone(search: MetadataSearch, results: [MetadataResult]) {
|
||||
DispatchQueue.main.async {
|
||||
if let first = results.first {
|
||||
self.state = .completed(search: search, results: results, selectedResult: first)
|
||||
@@ -291,43 +291,43 @@ import Cocoa
|
||||
updateUI()
|
||||
}
|
||||
|
||||
private func loadDone(search: MetadataSearch, result: SBMetadataResult) {
|
||||
private func loadDone(search: MetadataSearch, result: MetadataResult) {
|
||||
DispatchQueue.main.async {
|
||||
self.state = .closing(search: search, result: result)
|
||||
if let artworks = result.remoteArtworks, artworks.count > 0 {
|
||||
self.selectArtwork(artworks: artworks.toStruct(), type: search.type)
|
||||
if result.remoteArtworks.isEmpty {
|
||||
self.addMetadata()
|
||||
}
|
||||
else {
|
||||
self.addMetadata()
|
||||
self.selectArtwork(artworks: result.remoteArtworks, type: search.type)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func selectArtwork(artworks: [RemoteImage], type: MetadataSearch.Kind) {
|
||||
private func selectArtwork(artworks: [Artwork], type: MetadataType) {
|
||||
let artworkSelectorController = ArtworkSelectorController(artworks: artworks, size: window?.frame.size,
|
||||
type: type, delegate: self)
|
||||
window?.beginSheet(artworkSelectorController.window!, completionHandler: nil)
|
||||
artworkSelector = artworkSelectorController
|
||||
}
|
||||
|
||||
func didSelect(artworks: [RemoteImage]) {
|
||||
func didSelect(artworks: [Artwork]) {
|
||||
window?.endSheet((artworkSelector?.window)!)
|
||||
load(artworks: artworks)
|
||||
}
|
||||
|
||||
private func load(artworks: [RemoteImage]) {
|
||||
private func load(artworks: [Artwork]) {
|
||||
switch state {
|
||||
case .closing(_, let result):
|
||||
|
||||
DispatchQueue.global(priority: .background).async {
|
||||
for artwork in artworks {
|
||||
if let data = URLSession.data(from: artwork.url) {
|
||||
result.artworks.add(MP42Image(data: data, type: MP42_ART_JPEG))
|
||||
result.artworks.append(MP42Image(data: data, type: MP42_ART_JPEG))
|
||||
}
|
||||
// Hack, download smaller iTunes version if big iTunes version is not available
|
||||
else if artwork.service == iTunesStore().name,
|
||||
let data = URLSession.data(from: artwork.url.deletingPathExtension().appendingPathExtension("600x600bb.jpg")) {
|
||||
result.artworks.add(MP42Image(data: data, type: MP42_ART_JPEG))
|
||||
result.artworks.append(MP42Image(data: data, type: MP42_ART_JPEG))
|
||||
}
|
||||
}
|
||||
DispatchQueue.main.async {
|
||||
@@ -343,7 +343,7 @@ import Cocoa
|
||||
switch state {
|
||||
case .closing(let search, let result):
|
||||
if search.type == .tvShow {
|
||||
if let title = result[SBMetadataResultSeriesName] as? String {
|
||||
if let title = result[.seriesName] as? String {
|
||||
var previousTVSeries = MetadataSearchController.recentSearches()
|
||||
if previousTVSeries.contains(title) == false {
|
||||
previousTVSeries.append(title)
|
||||
@@ -456,22 +456,22 @@ import Cocoa
|
||||
}
|
||||
|
||||
private func updateSearchButtonVisibility() {
|
||||
if movieName.stringValue.count > 0 {
|
||||
searchMovieButton.isEnabled = true
|
||||
}
|
||||
else {
|
||||
if movieName.stringValue.isEmpty {
|
||||
searchMovieButton.isEnabled = false
|
||||
}
|
||||
if tvSeriesName.stringValue.count > 0 {
|
||||
if tvSeasonNum.stringValue.count == 0 && tvEpisodeNum.stringValue.count > 0 {
|
||||
else {
|
||||
searchMovieButton.isEnabled = true
|
||||
}
|
||||
if tvSeriesName.stringValue.isEmpty {
|
||||
searchTvButton.isEnabled = false
|
||||
}
|
||||
else {
|
||||
if tvSeasonNum.stringValue.isEmpty && tvEpisodeNum.stringValue.isEmpty == false {
|
||||
searchTvButton.isEnabled = false
|
||||
} else {
|
||||
searchTvButton.isEnabled = true
|
||||
}
|
||||
}
|
||||
else {
|
||||
searchTvButton.isEnabled = false
|
||||
}
|
||||
}
|
||||
|
||||
override func controlTextDidChange(_ obj: Notification) {
|
||||
@@ -507,7 +507,7 @@ import Cocoa
|
||||
else if tableView == metadataTable {
|
||||
switch state {
|
||||
case .completed(_, _, let result):
|
||||
return result.tags.count
|
||||
return result.count
|
||||
default:
|
||||
break
|
||||
}
|
||||
@@ -522,13 +522,13 @@ import Cocoa
|
||||
let result = results[row]
|
||||
switch search.type {
|
||||
case .tvShow:
|
||||
if let season = result[SBMetadataResultSeason] as? Int,
|
||||
let episode = result[SBMetadataResultEpisodeNumber] as? Int,
|
||||
let title = result[SBMetadataResultName] as? String {
|
||||
if let season = result[.season] as? Int,
|
||||
let episode = result[.episodeNumber] as? Int,
|
||||
let title = result[.name] as? String {
|
||||
return "\(season)x\(episode) - \(title)"
|
||||
}
|
||||
case .movie:
|
||||
if let title = result[SBMetadataResultName] as? String {
|
||||
if let title = result[.name] as? String {
|
||||
return title
|
||||
}
|
||||
}
|
||||
@@ -539,9 +539,9 @@ import Cocoa
|
||||
else if tableView == metadataTable {
|
||||
switch state {
|
||||
case .completed(_, _, let result):
|
||||
let key = result.orderedKeys()[row]
|
||||
let key = result.orderedKeys[row]
|
||||
if tableColumn?.identifier.rawValue == "name" {
|
||||
return SBMetadataResult.localizedDisplayName(forKey: key).boldMonospacedAttributedString()
|
||||
return key.localizedDisplayName.boldMonospacedAttributedString()
|
||||
}
|
||||
else if tableColumn?.identifier.rawValue == "value" {
|
||||
return result[key]
|
||||
|
||||
@@ -7,6 +7,54 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
public protocol Runnable {
|
||||
@discardableResult func runAsync() -> Runnable
|
||||
@discardableResult func run() -> Runnable
|
||||
func cancel()
|
||||
}
|
||||
|
||||
public protocol CancellableToken {
|
||||
func cancel()
|
||||
var sessionTask: URLSessionTask? { get set }
|
||||
}
|
||||
|
||||
class RunnableTask<T> : Runnable {
|
||||
|
||||
private var queue: DispatchQueue
|
||||
private var cancelled: Bool = false
|
||||
private let search: () -> T
|
||||
private let completionHandler: (T) -> Void
|
||||
|
||||
init(search: @escaping @autoclosure () -> T, completionHandler: @escaping (T) -> Void) {
|
||||
self.search = search
|
||||
self.completionHandler = completionHandler
|
||||
self.queue = DispatchQueue(label: "SearchTaskQueue")
|
||||
}
|
||||
|
||||
@discardableResult public func runAsync() -> Runnable {
|
||||
DispatchQueue.global(priority: .background).async {
|
||||
self.run()
|
||||
}
|
||||
return self
|
||||
}
|
||||
|
||||
@discardableResult public func run() -> Runnable {
|
||||
let results = self.search()
|
||||
queue.sync {
|
||||
if self.cancelled == false {
|
||||
self.completionHandler(results)
|
||||
}
|
||||
}
|
||||
return self
|
||||
}
|
||||
|
||||
public func cancel() {
|
||||
queue.sync {
|
||||
self.cancelled = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - URL Utilities
|
||||
|
||||
private let allowedChars: CharacterSet = {
|
||||
|
||||
@@ -12,6 +12,7 @@ import Foundation
|
||||
case iTunes
|
||||
case Episode
|
||||
case Season
|
||||
case SeasonSquare
|
||||
}
|
||||
|
||||
/// An actions that fetches metadata online.
|
||||
@@ -38,7 +39,7 @@ import Foundation
|
||||
self.preferredArtwork = preferredArtwork
|
||||
}
|
||||
|
||||
private func indexOfArtwork(type: QueueMetadataActionPreferredArtwork, provider: String, artworks: [RemoteImage]) -> Int? {
|
||||
private func indexOfArtwork(type: QueueMetadataActionPreferredArtwork, provider: String, artworks: [Artwork]) -> Int? {
|
||||
|
||||
var artworkService: String = ""
|
||||
var artworkType: String = ""
|
||||
@@ -71,8 +72,8 @@ import Foundation
|
||||
return MP42Image(data: data, type: MP42_ART_JPEG)
|
||||
}
|
||||
|
||||
private func searchMetadata(info: FilenameInfo) -> SBMetadataResult? {
|
||||
var metadata: SBMetadataResult? = nil
|
||||
private func searchMetadata(info: FilenameInfo) -> MetadataResult? {
|
||||
var metadata: MetadataResult? = nil
|
||||
|
||||
switch info {
|
||||
case let .movie(title):
|
||||
@@ -101,7 +102,8 @@ import Foundation
|
||||
guard let info = url.lastPathComponent.parsedAsFilename(),
|
||||
let metadata = searchMetadata(info: info) else { return nil }
|
||||
|
||||
if let artworks = metadata.remoteArtworks?.toStruct(), artworks.count > 0 {
|
||||
let artworks = metadata.remoteArtworks
|
||||
if artworks.isEmpty == false {
|
||||
let index: Int = {
|
||||
if let index = self.indexOfArtwork(type: self.preferredArtwork,
|
||||
provider: info.isMovie ? self.movieProvider : self.tvShowProvider,
|
||||
@@ -121,14 +123,14 @@ import Foundation
|
||||
let artworkURL = artworks[index].url
|
||||
|
||||
if let artwork = load(artworkURL: artworkURL) {
|
||||
metadata.artworks.add(artwork)
|
||||
metadata.artworks.append(artwork)
|
||||
}
|
||||
}
|
||||
|
||||
let defaults = UserDefaults.standard
|
||||
if let map = metadata.mediaKind == 9 ? defaults.sb_resultMap(forKey: "SBMetadataMovieResultMap")
|
||||
: defaults.sb_resultMap(forKey: "SBMetadataTvShowResultMap") {
|
||||
return metadata.mapped(to: map, keepEmptyKeys: false)
|
||||
if let map = metadata.mediaKind == 9 ? defaults.map(forKey: "SBMetadataMovieResultMap")
|
||||
: defaults.map(forKey: "SBMetadataTvShowResultMap") {
|
||||
return metadata.mappedMetadata(to: map, keepEmptyKeys: false)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -21,9 +21,6 @@
|
||||
#import "SBChapterViewController.h"
|
||||
#import "SBMultiSelectViewController.h"
|
||||
|
||||
#import "SBMetadataResult.h"
|
||||
#import "SBMetadataResultMap.h"
|
||||
|
||||
#import <MP42Foundation/MP42File.h>
|
||||
#import <MP42Foundation/MP42FileImporter.h>
|
||||
#import <MP42Foundation/MP42Languages.h>
|
||||
@@ -861,9 +858,9 @@ static NSDictionary *_detailMonospacedAttr;
|
||||
if (metadataToBeImported) {
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
SBMetadataResultMap *map = metadataToBeImported.mediaKind == 9 ?
|
||||
[defaults SB_resultMapForKey:@"SBMetadataMovieResultMap"] : [defaults SB_resultMapForKey:@"SBMetadataTvShowResultMap"];
|
||||
[defaults mapForKey:@"SBMetadataMovieResultMap"] : [defaults mapForKey:@"SBMetadataTvShowResultMap"];
|
||||
BOOL keepEmptyKeys = [defaults boolForKey:@"SBMetadataKeepEmptyAnnotations"];
|
||||
MP42Metadata *mappedMetadata = [metadataToBeImported mappedTo:map keepEmptyKeys:keepEmptyKeys];
|
||||
MP42Metadata *mappedMetadata = [metadataToBeImported mappedMetadataTo:map keepEmptyKeys:keepEmptyKeys];
|
||||
|
||||
[self.mp4.metadata mergeMetadata:mappedMetadata];
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
|
||||
#import "SBMetadataPrefsViewController.h"
|
||||
|
||||
#import "SBMetadataResult.h"
|
||||
#import "SBMetadataResultMap.h"
|
||||
#import "Subler-Swift.h"
|
||||
|
||||
#import <MP42Foundation/MP42Metadata.h>
|
||||
|
||||
static void *SBMetadataPrefsViewControllerContex = &SBMetadataPrefsViewControllerContex;
|
||||
@@ -62,8 +62,8 @@ static void *SBMetadataPrefsViewControllerContex = &SBMetadataPrefsViewControlle
|
||||
|
||||
// Load data from preferences
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
SBMetadataResultMap *savedMovieMap = [defaults SB_resultMapForKey:@"SBMetadataMovieResultMap"];
|
||||
SBMetadataResultMap *savedTvShowMap = [defaults SB_resultMapForKey:@"SBMetadataTvShowResultMap"];
|
||||
SBMetadataResultMap *savedMovieMap = [defaults mapForKey:@"SBMetadataMovieResultMap"];
|
||||
SBMetadataResultMap *savedTvShowMap = [defaults mapForKey:@"SBMetadataTvShowResultMap"];
|
||||
|
||||
_movieMap = savedMovieMap ? savedMovieMap : [SBMetadataResultMap movieDefaultMap];
|
||||
_tvShowMap = savedTvShowMap ? savedTvShowMap : [SBMetadataResultMap tvShowDefaultMap];
|
||||
@@ -110,8 +110,8 @@ static void *SBMetadataPrefsViewControllerContex = &SBMetadataPrefsViewControlle
|
||||
- (void)save
|
||||
{
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
[defaults SB_setResultMap:self.movieMap forKey:@"SBMetadataMovieResultMap"];
|
||||
[defaults SB_setResultMap:self.tvShowMap forKey:@"SBMetadataTvShowResultMap"];
|
||||
[defaults setMap:self.movieMap forKey:@"SBMetadataMovieResultMap"];
|
||||
[defaults setMap:self.tvShowMap forKey:@"SBMetadataTvShowResultMap"];
|
||||
}
|
||||
|
||||
- (IBAction)addMetadataItem:(id)sender
|
||||
@@ -167,7 +167,7 @@ static void *SBMetadataPrefsViewControllerContex = &SBMetadataPrefsViewControlle
|
||||
- (NSString *)tokenField:(NSTokenField *)tokenField displayStringForRepresentedObject:(id)representedObject
|
||||
{
|
||||
if ([representedObject rangeOfString: @"{"].location == 0) {
|
||||
return [SBMetadataResult localizedDisplayNameForKey:representedObject];
|
||||
return [SBMetadataResult localizedDisplayNameWithKey:representedObject];
|
||||
}
|
||||
|
||||
return representedObject;
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
//
|
||||
// SBMetadataDefaultSet.h
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 28/07/2016.
|
||||
//
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SBMetadataResultMapItem : NSObject<NSSecureCoding>
|
||||
|
||||
+ (instancetype)itemWithKey:(NSString *)key value:(NSArray *)value;
|
||||
- (instancetype)initWithKey:(NSString *)key value:(NSArray *)value;
|
||||
|
||||
@property (nonatomic, readonly) NSString *key;
|
||||
@property (nonatomic, readwrite, copy) NSArray<NSString *> *value;
|
||||
|
||||
@property (nonatomic, readonly) NSString *localizedKeyDisplayName;
|
||||
|
||||
@end
|
||||
|
||||
typedef NS_ENUM(NSUInteger, SBMetadataResultMapType) {
|
||||
SBMetadataResultMapTypeMovie,
|
||||
SBMetadataResultMapTypeTvShow,
|
||||
};
|
||||
|
||||
/**
|
||||
* Maps the values returned by the metadata importers
|
||||
* the the MP42Metadata values.
|
||||
*/
|
||||
@interface SBMetadataResultMap : NSObject<NSSecureCoding>
|
||||
|
||||
+ (instancetype)movieDefaultMap;
|
||||
+ (instancetype)tvShowDefaultMap;
|
||||
|
||||
- (instancetype)initWithItems:(NSArray<SBMetadataResultMapItem *> *)items type:(SBMetadataResultMapType)type;
|
||||
|
||||
@property (nonatomic, readonly) NSMutableArray<SBMetadataResultMapItem *> *items;
|
||||
@property (nonatomic, readonly) SBMetadataResultMapType type;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSUserDefaults (SublerMetadataResultMapAdditions)
|
||||
|
||||
- (nullable SBMetadataResultMap *)SB_resultMapForKey:(NSString *)defaultName;
|
||||
- (void)SB_setResultMap:(nullable SBMetadataResultMap *)value forKey:(NSString *)defaultName;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -1,207 +0,0 @@
|
||||
//
|
||||
// SBMetadataDefaultSet.m
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 28/07/2016.
|
||||
//
|
||||
//
|
||||
|
||||
#import "SBMetadataResultMap.h"
|
||||
#import "SBMetadataResult.h"
|
||||
#import <MP42Foundation/MP42Metadata.h>
|
||||
|
||||
@implementation SBMetadataResultMapItem
|
||||
|
||||
- (instancetype)initWithKey:(NSString *)key value:(NSArray *)value
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_key = [key copy];
|
||||
_value = [value copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)itemWithKey:(NSString *)key value:(NSArray *)value
|
||||
{
|
||||
return [[self alloc] initWithKey:key value:value];
|
||||
}
|
||||
|
||||
- (NSString *)localizedKeyDisplayName
|
||||
{
|
||||
return localizedMetadataKeyName(self.key);
|
||||
}
|
||||
|
||||
#pragma mark - NSSecureCoding
|
||||
|
||||
+ (BOOL)supportsSecureCoding
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)coder
|
||||
{
|
||||
self = [self init];
|
||||
if (self) {
|
||||
id temp;
|
||||
temp = [coder decodeObjectOfClass:[NSString class] forKey:@"key"];
|
||||
if (temp) {
|
||||
_key = temp;
|
||||
}
|
||||
temp = [coder decodeObjectOfClass:[NSArray class] forKey:@"value"];
|
||||
if (temp) {
|
||||
_value = temp;
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)coder
|
||||
{
|
||||
[coder encodeObject:self.key forKey:@"key"];
|
||||
[coder encodeObject:self.value forKey:@"value"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation SBMetadataResultMap
|
||||
|
||||
+ (instancetype)movieDefaultMap
|
||||
{
|
||||
NSArray<SBMetadataResultMapItem *> *items = @[
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyName value:@[SBMetadataResultName]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyArtist value:@[SBMetadataResultDirector]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyComposer value:@[SBMetadataResultComposer]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyUserGenre value:@[SBMetadataResultGenre]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyReleaseDate value:@[SBMetadataResultReleaseDate]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyDescription value:@[SBMetadataResultDescription]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyLongDescription value:@[SBMetadataResultLongDescription]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyRating value:@[SBMetadataResultRating]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyStudio value:@[SBMetadataResultStudio]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyCast value:@[SBMetadataResultCast]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyDirector value:@[SBMetadataResultDirector]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyProducer value:@[SBMetadataResultProducers]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyScreenwriters value:@[SBMetadataResultScreenwriters]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyCopyright value:@[SBMetadataResultCopyright]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyContentID value:@[SBMetadataResultContentID]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyAccountCountry value:@[SBMetadataResultITunesCountry]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyExecProducer value:@[SBMetadataResultExecutiveProducer]],
|
||||
];
|
||||
|
||||
return [[self alloc] initWithItems:items type:SBMetadataResultMapTypeMovie];
|
||||
}
|
||||
|
||||
+ (instancetype)tvShowDefaultMap
|
||||
{
|
||||
NSArray<SBMetadataResultMapItem *> *items = @[
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyName value:@[SBMetadataResultName]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyArtist value:@[SBMetadataResultSeriesName]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyAlbumArtist value:@[SBMetadataResultSeriesName]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyAlbum value:@[SBMetadataResultSeriesName, @", Season ", SBMetadataResultSeason]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyComposer value:@[SBMetadataResultComposer]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyUserGenre value:@[SBMetadataResultGenre]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyReleaseDate value:@[SBMetadataResultReleaseDate]],
|
||||
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyTrackNumber value:@[SBMetadataResultTrackNumber]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyDiscNumber value:@[SBMetadataResultDiskNumber]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyTVShow value:@[SBMetadataResultSeriesName]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyTVEpisodeNumber value:@[SBMetadataResultEpisodeNumber]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyTVNetwork value:@[SBMetadataResultNetwork]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyTVEpisodeID value:@[SBMetadataResultEpisodeID]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyTVSeason value:@[SBMetadataResultSeason]],
|
||||
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyDescription value:@[SBMetadataResultDescription]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyLongDescription value:@[SBMetadataResultLongDescription]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeySeriesDescription value:@[SBMetadataResultSeriesDescription]],
|
||||
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyRating value:@[SBMetadataResultRating]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyStudio value:@[SBMetadataResultStudio]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyCast value:@[SBMetadataResultCast]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyDirector value:@[SBMetadataResultDirector]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyProducer value:@[SBMetadataResultProducers]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyScreenwriters value:@[SBMetadataResultScreenwriters]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyExecProducer value:@[SBMetadataResultExecutiveProducer]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyCopyright value:@[SBMetadataResultCopyright]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyContentID value:@[SBMetadataResultContentID]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyArtistID value:@[SBMetadataResultArtistID]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyPlaylistID value:@[SBMetadataResultPlaylistID]],
|
||||
[SBMetadataResultMapItem itemWithKey:MP42MetadataKeyAccountCountry value:@[SBMetadataResultITunesCountry]],
|
||||
];
|
||||
|
||||
return [[self alloc] initWithItems:items type:SBMetadataResultMapTypeTvShow];
|
||||
}
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_items = [[NSMutableArray alloc] init];
|
||||
_type = SBMetadataResultMapTypeMovie;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithItems:(NSArray<SBMetadataResultMapItem *> *)items type:(SBMetadataResultMapType)type
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_items = [items mutableCopy];
|
||||
_type = type;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - NSSecureCoding
|
||||
|
||||
+ (BOOL)supportsSecureCoding
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)coder
|
||||
{
|
||||
self = [self init];
|
||||
if (self) {
|
||||
id temp;
|
||||
temp = [coder decodeObjectOfClass:[NSArray class] forKey:@"items"];
|
||||
if (temp) {
|
||||
_items = temp;
|
||||
}
|
||||
_type = [coder decodeIntegerForKey:@"type"];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)coder
|
||||
{
|
||||
[coder encodeObject:self.items forKey:@"items"];
|
||||
[coder encodeInteger:self.type forKey:@"type"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSUserDefaults (SublerMetadataResultMapAdditions)
|
||||
|
||||
- (nullable SBMetadataResultMap *)SB_resultMapForKey:(NSString *)defaultName
|
||||
{
|
||||
NSData *encodedObject = [self objectForKey:defaultName];
|
||||
if (encodedObject) {
|
||||
@try {
|
||||
SBMetadataResultMap *decodedMap = [NSKeyedUnarchiver unarchiveObjectWithData:encodedObject];
|
||||
if ([decodedMap isKindOfClass:[SBMetadataResultMap class]]) {
|
||||
return decodedMap;
|
||||
}
|
||||
}
|
||||
@catch (NSException *exception) {}
|
||||
@finally {}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)SB_setResultMap:(nullable SBMetadataResultMap *)value forKey:(NSString *)defaultName
|
||||
{
|
||||
NSData *encodedObject = [NSKeyedArchiver archivedDataWithRootObject:value];
|
||||
[self setObject:encodedObject forKey:defaultName];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#import "SBMetadataPrefsViewController.h"
|
||||
#import "SBSetPrefsViewController.h"
|
||||
#import "SBMetadataResultMap.h"
|
||||
|
||||
#import "Subler-Swift.h"
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#import "SBQueueAction.h"
|
||||
|
||||
#import "SBQueueItem.h"
|
||||
#import "SBMetadataResultMap.h"
|
||||
|
||||
#import <MP42Foundation/MP42File.h>
|
||||
#import <MP42Foundation/MP42FileImporter.h>
|
||||
|
||||
+14
-5
@@ -25,12 +25,12 @@ struct SquaredTVArt {
|
||||
return URL(string: thumbURL.absoluteString.replacingOccurrences(of: "_250.jpg", with: "_1280.jpg")) ?? thumbURL
|
||||
}
|
||||
|
||||
func toRemoteImage() -> RemoteImage {
|
||||
return RemoteImage(url: thumbURL, thumbURL: url, service: "Squared TV Art", type: "season square")
|
||||
func toRemoteImage() -> Artwork {
|
||||
return Artwork(url: thumbURL, thumbURL: url, service: "Squared TV Art", type: "season square")
|
||||
}
|
||||
}
|
||||
|
||||
func search(tvShow: String) -> [RemoteImage] {
|
||||
func search(tvShow: String) -> [Artwork] {
|
||||
let searchTerm = tvShow.urlEncoded()
|
||||
guard let url = URL(string: "\(basePath)search/\(searchTerm)") else { return [] }
|
||||
|
||||
@@ -38,7 +38,7 @@ struct SquaredTVArt {
|
||||
return mapped
|
||||
}
|
||||
|
||||
func search(tvShow: String, season: Int) -> [RemoteImage] {
|
||||
func search(tvShow: String, season: Int) -> [Artwork] {
|
||||
let searchTerm = "\(tvShow) Season \(season)".urlEncoded()
|
||||
guard let url = URL(string: "\(basePath)search/\(searchTerm)") else { return [] }
|
||||
|
||||
@@ -46,7 +46,7 @@ struct SquaredTVArt {
|
||||
return mapped
|
||||
}
|
||||
|
||||
func search(theTVDBSeriesId: Int, season: Int) -> [RemoteImage] {
|
||||
func search(theTVDBSeriesId: Int, season: Int) -> [Artwork] {
|
||||
let searchTerm = "\(theTVDBSeriesId) Season \(season)".urlEncoded()
|
||||
guard let url = URL(string: "\(basePath)search/\(searchTerm)") else { return [] }
|
||||
|
||||
@@ -88,6 +88,14 @@ struct SquaredTVArt {
|
||||
return nil
|
||||
}
|
||||
|
||||
private func parseString(info: [Substring], type: String) -> String? {
|
||||
let filtered = info.filter { $0.hasPrefix(type) }
|
||||
if let seriesID = filtered.first {
|
||||
return String(seriesID).replacingOccurrences(of: type, with: "")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
private func parse(xml: XMLDocument) -> [SquaredTVArtwork] {
|
||||
guard let nodes = try? xml.nodes(forXPath: "//div[starts-with(@class,'Post ')]") else { return [] }
|
||||
|
||||
@@ -99,6 +107,7 @@ struct SquaredTVArt {
|
||||
let info = element.attribute(forName: "class")?.stringValue?.split(separator: " "),
|
||||
let seriesID = parse(info: info, type: "thetvdb_series_"),
|
||||
let seasonID = parse(info: info, type: "thetvdb_season_"),
|
||||
//let imdbID = parseString(info: info, type: "imdb_series"),
|
||||
let season = parse(info: info, type: "season_") {
|
||||
return SquaredTVArtwork(thumbURL: url, tvShow: name, thetvdbSeriesID: seriesID, season: season, thetvdbSeasonID: seasonID)
|
||||
}
|
||||
|
||||
@@ -5,9 +5,6 @@
|
||||
#import "SBQueueItem.h"
|
||||
#import "SBQueueAction.h"
|
||||
|
||||
#import "SBMetadataResult.h"
|
||||
#import "SBMetadataResultMap.h"
|
||||
|
||||
#import <MP42Foundation/MP42Ratings.h>
|
||||
#import <MP42Foundation/MP42Languages.h>
|
||||
#import <MP42Foundation/MP42Image.h>
|
||||
|
||||
@@ -14,13 +14,14 @@
|
||||
8D15AC2F0486D014006FF6A4 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165FFE840EACC02AAC07 /* InfoPlist.strings */; };
|
||||
8D15AC320486D014006FF6A4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A37F4B0FDCFA73011CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
|
||||
8D15AC340486D014006FF6A4 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A7FEA54F5311CA2CBB /* Cocoa.framework */; };
|
||||
A902E1D51F29DD8900D73C17 /* SBMetadataImporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = A902E1D41F29DD8900D73C17 /* SBMetadataImporter.swift */; };
|
||||
A900CE3E1F3ACF9700CCA08E /* MetadataResultMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = A900CE3D1F3ACF9700CCA08E /* MetadataResultMap.swift */; };
|
||||
A90300C41DAE6E27008237D8 /* SBSetPrefsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A90300C21DAE6E27008237D8 /* SBSetPrefsViewController.m */; };
|
||||
A90300C81DAE72C4008237D8 /* SBSetPrefsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A90300CA1DAE72C4008237D8 /* SBSetPrefsViewController.xib */; };
|
||||
A906B5B11E434872007D12B1 /* Queue.sdef in Resources */ = {isa = PBXBuildFile; fileRef = A906B5B01E434872007D12B1 /* Queue.sdef */; };
|
||||
A909440A1DD4B80000E9F89C /* SBComboBoxCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A90944091DD4B80000E9F89C /* SBComboBoxCell.m */; };
|
||||
A909440D1DD4C70900E9F89C /* SBTokenFieldCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A909440C1DD4C70900E9F89C /* SBTokenFieldCell.m */; };
|
||||
A90B023B10F3290A000416F3 /* Prefs.xib in Resources */ = {isa = PBXBuildFile; fileRef = A90B023910F3290A000416F3 /* Prefs.xib */; };
|
||||
A90BC5E31F3A139700F9F3F3 /* MetadataResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = A90BC5E21F3A139700F9F3F3 /* MetadataResult.swift */; };
|
||||
A91690041DABFDAA004B9AB0 /* SBCheckBoxCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = A91690031DABFDAA004B9AB0 /* SBCheckBoxCellView.m */; };
|
||||
A917286119FD288B00348DF8 /* SBLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = A917286019FD288B00348DF8 /* SBLogger.m */; };
|
||||
A91B196C1F2B0DCB0008675F /* QueueAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = A91B196B1F2B0DCB0008675F /* QueueAction.swift */; };
|
||||
@@ -41,7 +42,6 @@
|
||||
A961476713F568210068F161 /* Queue.xib in Resources */ = {isa = PBXBuildFile; fileRef = A961476513F568210068F161 /* Queue.xib */; };
|
||||
A96946531BA3F83D0048C004 /* SBMediaTagsController.m in Sources */ = {isa = PBXBuildFile; fileRef = A96946511BA3F83D0048C004 /* SBMediaTagsController.m */; };
|
||||
A9707B9317B139780010F3DB /* Quartz.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD56966E12FAAFA90029FADB /* Quartz.framework */; };
|
||||
A98175501D49F11B00750709 /* SBMetadataResultMap.m in Sources */ = {isa = PBXBuildFile; fileRef = A981754F1D49F11B00750709 /* SBMetadataResultMap.m */; };
|
||||
A982D0C0140AB66400B92357 /* SBQueueItem.m in Sources */ = {isa = PBXBuildFile; fileRef = A982D0BF140AB66400B92357 /* SBQueueItem.m */; };
|
||||
A984DB4B0F52D644001A20B2 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A984DB4A0F52D644001A20B2 /* Sparkle.framework */; };
|
||||
A984DB530F52D679001A20B2 /* Sparkle.framework in Copy Files */ = {isa = PBXBuildFile; fileRef = A984DB4A0F52D644001A20B2 /* Sparkle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||
@@ -96,7 +96,6 @@
|
||||
A9E97F141F274F1100DBA586 /* iTunesStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9E97F131F274F1100DBA586 /* iTunesStore.swift */; };
|
||||
A9EEA5F218D65490008B54B4 /* SBOptionsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A9EEA5F018D65490008B54B4 /* SBOptionsViewController.m */; };
|
||||
A9EEA5F818D654B9008B54B4 /* QueueOptions.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9EEA5F618D654B9008B54B4 /* QueueOptions.xib */; };
|
||||
A9F442301C75017100AD8786 /* SBMetadataResult.m in Sources */ = {isa = PBXBuildFile; fileRef = A9F4422F1C75017100AD8786 /* SBMetadataResult.m */; };
|
||||
A9F5820C1DCC861F005F3E92 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A9F5820B1DCC861F005F3E92 /* Assets.xcassets */; };
|
||||
A9F7F8E01837C44B0036AE7E /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9ED7B21180067A2008FD3A8 /* IOKit.framework */; };
|
||||
A9FC6FF61EF2E3280034CCED /* TheTVDBService.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9FC6FF51EF2E3280034CCED /* TheTVDBService.swift */; };
|
||||
@@ -174,7 +173,7 @@
|
||||
8D15AC360486D014006FF6A4 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
8D15AC370486D014006FF6A4 /* Subler.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Subler.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
948058B5106E07990037A911 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = /usr/lib/libz.dylib; sourceTree = "<absolute>"; };
|
||||
A902E1D41F29DD8900D73C17 /* SBMetadataImporter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SBMetadataImporter.swift; path = Classes/MetadataImporters/SBMetadataImporter.swift; sourceTree = "<group>"; };
|
||||
A900CE3D1F3ACF9700CCA08E /* MetadataResultMap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = MetadataResultMap.swift; path = Classes/MetadataImporters/MetadataResultMap.swift; sourceTree = "<group>"; };
|
||||
A90300C11DAE6E27008237D8 /* SBSetPrefsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBSetPrefsViewController.h; path = Classes/SBSetPrefsViewController.h; sourceTree = "<group>"; };
|
||||
A90300C21DAE6E27008237D8 /* SBSetPrefsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SBSetPrefsViewController.m; path = Classes/SBSetPrefsViewController.m; sourceTree = "<group>"; };
|
||||
A90300C91DAE72C4008237D8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/SBSetPrefsViewController.xib; sourceTree = "<group>"; };
|
||||
@@ -183,6 +182,7 @@
|
||||
A90944091DD4B80000E9F89C /* SBComboBoxCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SBComboBoxCell.m; path = Classes/SBComboBoxCell.m; sourceTree = "<group>"; };
|
||||
A909440B1DD4C70900E9F89C /* SBTokenFieldCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBTokenFieldCell.h; path = Classes/SBTokenFieldCell.h; sourceTree = "<group>"; };
|
||||
A909440C1DD4C70900E9F89C /* SBTokenFieldCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SBTokenFieldCell.m; path = Classes/SBTokenFieldCell.m; sourceTree = "<group>"; };
|
||||
A90BC5E21F3A139700F9F3F3 /* MetadataResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = MetadataResult.swift; path = Classes/MetadataImporters/MetadataResult.swift; sourceTree = "<group>"; };
|
||||
A91690021DABFDAA004B9AB0 /* SBCheckBoxCellView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBCheckBoxCellView.h; path = Classes/SBCheckBoxCellView.h; sourceTree = "<group>"; };
|
||||
A91690031DABFDAA004B9AB0 /* SBCheckBoxCellView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SBCheckBoxCellView.m; path = Classes/SBCheckBoxCellView.m; sourceTree = "<group>"; };
|
||||
A917286019FD288B00348DF8 /* SBLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SBLogger.m; path = Classes/SBLogger.m; sourceTree = "<group>"; };
|
||||
@@ -229,8 +229,6 @@
|
||||
A96946501BA3F83D0048C004 /* SBMediaTagsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBMediaTagsController.h; path = Classes/SBMediaTagsController.h; sourceTree = "<group>"; };
|
||||
A96946511BA3F83D0048C004 /* SBMediaTagsController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SBMediaTagsController.m; path = Classes/SBMediaTagsController.m; sourceTree = "<group>"; };
|
||||
A97BE36E0F73D72E00652CBD /* QTKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QTKit.framework; path = /System/Library/Frameworks/QTKit.framework; sourceTree = "<absolute>"; };
|
||||
A981754E1D49F11B00750709 /* SBMetadataResultMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBMetadataResultMap.h; path = Classes/SBMetadataResultMap.h; sourceTree = "<group>"; };
|
||||
A981754F1D49F11B00750709 /* SBMetadataResultMap.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SBMetadataResultMap.m; path = Classes/SBMetadataResultMap.m; sourceTree = "<group>"; };
|
||||
A982D0BE140AB66400B92357 /* SBQueueItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBQueueItem.h; path = Classes/SBQueueItem.h; sourceTree = "<group>"; };
|
||||
A982D0BF140AB66400B92357 /* SBQueueItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SBQueueItem.m; path = Classes/SBQueueItem.m; sourceTree = "<group>"; };
|
||||
A984DB4A0F52D644001A20B2 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Sparkle.framework; sourceTree = "<group>"; };
|
||||
@@ -325,8 +323,6 @@
|
||||
A9ED7B21180067A2008FD3A8 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; };
|
||||
A9EEA5EF18D65490008B54B4 /* SBOptionsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBOptionsViewController.h; path = Classes/SBOptionsViewController.h; sourceTree = "<group>"; };
|
||||
A9EEA5F018D65490008B54B4 /* SBOptionsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SBOptionsViewController.m; path = Classes/SBOptionsViewController.m; sourceTree = "<group>"; };
|
||||
A9F4422E1C75017100AD8786 /* SBMetadataResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBMetadataResult.h; path = Classes/MetadataImporters/SBMetadataResult.h; sourceTree = "<group>"; };
|
||||
A9F4422F1C75017100AD8786 /* SBMetadataResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SBMetadataResult.m; path = Classes/MetadataImporters/SBMetadataResult.m; sourceTree = "<group>"; };
|
||||
A9F5820B1DCC861F005F3E92 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
A9FC6FF41EF2E3280034CCED /* Subler-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Subler-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
A9FC6FF51EF2E3280034CCED /* TheTVDBService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = TheTVDBService.swift; path = Classes/MetadataImporters/TheTVDBService.swift; sourceTree = "<group>"; };
|
||||
@@ -639,13 +635,10 @@
|
||||
CD71FF1A12F1C46900F0A98D /* MetadataImporters */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A9F4422E1C75017100AD8786 /* SBMetadataResult.h */,
|
||||
A9F4422F1C75017100AD8786 /* SBMetadataResult.m */,
|
||||
A981754E1D49F11B00750709 /* SBMetadataResultMap.h */,
|
||||
A981754F1D49F11B00750709 /* SBMetadataResultMap.m */,
|
||||
A902E1D41F29DD8900D73C17 /* SBMetadataImporter.swift */,
|
||||
A9AE70E01F2F7B3D001CF27C /* MetadataHelper.swift */,
|
||||
A9CBAB1D1F29C083001C26B3 /* MetadataImporter.swift */,
|
||||
A9AE70E01F2F7B3D001CF27C /* MetadataHelper.swift */,
|
||||
A90BC5E21F3A139700F9F3F3 /* MetadataResult.swift */,
|
||||
A900CE3D1F3ACF9700CCA08E /* MetadataResultMap.swift */,
|
||||
A9E97F131F274F1100DBA586 /* iTunesStore.swift */,
|
||||
A98D98451F0280CB00A77ABC /* TheMovieDB.swift */,
|
||||
A98D98471F02820F00A77ABC /* TheMovieDBService.swift */,
|
||||
@@ -833,12 +826,14 @@
|
||||
A960E96317D4B00900FC6ED9 /* SBImageBrowserView.m in Sources */,
|
||||
A9DA3B9D1B918D5C00F1E40C /* SBExceptionAlertController.m in Sources */,
|
||||
A94721931D49DC0000858DD8 /* SBMetadataPrefsViewController.m in Sources */,
|
||||
A90BC5E31F3A139700F9F3F3 /* MetadataResult.swift in Sources */,
|
||||
A99189CD1F2F87EC00623ED7 /* ChapterImporter.swift in Sources */,
|
||||
A9BC410318D9AB8700F8C92C /* SBItemViewController.m in Sources */,
|
||||
A9AB484917F0AEA2000AA72E /* SBAppDelegate.m in Sources */,
|
||||
A93DD7681DACCE930052749A /* SBComboBoxCellView.m in Sources */,
|
||||
A9B46A8C12B79B240040517A /* SBFileImport.m in Sources */,
|
||||
A9B46A8E12B79B240040517A /* SBPrefsController.m in Sources */,
|
||||
A900CE3E1F3ACF9700CCA08E /* MetadataResultMap.swift in Sources */,
|
||||
A9B46A8F12B79B240040517A /* SBTableView.m in Sources */,
|
||||
A9B46A9012B79B240040517A /* SBView.m in Sources */,
|
||||
A9B46A9E12B79B990040517A /* ButtonToolbarItem.m in Sources */,
|
||||
@@ -865,8 +860,6 @@
|
||||
A961476413F567E10068F161 /* SBPresetManager.m in Sources */,
|
||||
A982D0C0140AB66400B92357 /* SBQueueItem.m in Sources */,
|
||||
A9AF6A7518D0496400FAAB08 /* SBQueueAction.m in Sources */,
|
||||
A98175501D49F11B00750709 /* SBMetadataResultMap.m in Sources */,
|
||||
A9F442301C75017100AD8786 /* SBMetadataResult.m in Sources */,
|
||||
A90300C41DAE6E27008237D8 /* SBSetPrefsViewController.m in Sources */,
|
||||
A917286119FD288B00348DF8 /* SBLogger.m in Sources */,
|
||||
A91B196C1F2B0DCB0008675F /* QueueAction.swift in Sources */,
|
||||
@@ -877,7 +870,6 @@
|
||||
A9E97F141F274F1100DBA586 /* iTunesStore.swift in Sources */,
|
||||
A9433A8D1F2F5C3600BB38CA /* ChapterResult.swift in Sources */,
|
||||
A9EEA5F218D65490008B54B4 /* SBOptionsViewController.m in Sources */,
|
||||
A902E1D51F29DD8900D73C17 /* SBMetadataImporter.swift in Sources */,
|
||||
A9AB485517F0AEAC000AA72E /* SBEmptyViewController.m in Sources */,
|
||||
A9AE70E11F2F7B3D001CF27C /* MetadataHelper.swift in Sources */,
|
||||
A9A0542E1DEEC3E000D1AFA4 /* SBLanguageTransformer.m in Sources */,
|
||||
|
||||
Reference in new issue
Block a user