Remove 10.9 support.
This commit is contained in:
18 files changed
+54
-118
No files matched your search
@@ -58,7 +58,7 @@ public struct ChapterDB : ChapterService {
|
||||
var currentTime: UInt64 = 0
|
||||
var chapters: [Chapter] = Array()
|
||||
|
||||
for (time, name) in zip(times.flatMap { $0.stringValue }, names.flatMap { $0.stringValue }) {
|
||||
for (time, name) in zip(times.compactMap { $0.stringValue }, names.compactMap { $0.stringValue }) {
|
||||
let timestamp = TimeFromString(time, 1000)
|
||||
|
||||
if timestamp < currentTime {
|
||||
@@ -84,7 +84,7 @@ public struct ChapterDB : ChapterService {
|
||||
guard let document = try? XMLDocument(data: data, options: []),
|
||||
let children = try? document.nodes(forXPath: "//*:chapterInfo") else { return [] }
|
||||
|
||||
return children.flatMap { parse(node: $0) }
|
||||
return children.compactMap { parse(node: $0) }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -239,7 +239,7 @@ public class MetadataResult : NSObject {
|
||||
public func mappedMetadata(to map: MetadataResultMap, keepEmptyKeys: Bool) -> MP42Metadata {
|
||||
let metadata = MP42Metadata()
|
||||
|
||||
metadata.addItems(map.items.flatMap {
|
||||
metadata.addItems(map.items.compactMap {
|
||||
let value = $0.value.reduce("", {
|
||||
if let key = Key(rawValue: $1) {
|
||||
if let value = dictionary[key] {
|
||||
|
||||
@@ -111,7 +111,7 @@ struct SquaredTVArt {
|
||||
private func parse(xml: XMLDocument) -> [SquaredTVArtwork] {
|
||||
guard let nodes = try? xml.nodes(forXPath: "//div[starts-with(@class,'Post ')]") else { return [] }
|
||||
|
||||
return nodes.flatMap { (node) -> SquaredTVArtwork? in
|
||||
return nodes.compactMap { (node) -> SquaredTVArtwork? in
|
||||
if let subXml = try? XMLDocument(xmlString: node.xmlString, options: []),
|
||||
let name = completeName(xml: subXml),
|
||||
let url = thumbURL(xml: subXml),
|
||||
|
||||
@@ -57,14 +57,14 @@ public struct TheMovieDB: MetadataService {
|
||||
private func cleanList(items: [TMDBTuple]?) -> String? {
|
||||
guard let items = items else { return nil }
|
||||
if items.count == 0 { return nil }
|
||||
return items.flatMap { (t: TMDBTuple) -> String? in return t.name }
|
||||
return items.compactMap { (t: TMDBTuple) -> String? in return t.name }
|
||||
.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 }
|
||||
return cast.compactMap { (t: TMDBCast) -> String? in return t.name }
|
||||
.reduce("", { (s1: String, s2: String) -> String in return s1 + (s1.isEmpty ? "" : ", ") + s2 })
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public struct TheMovieDB: MetadataService {
|
||||
guard let crew = crew else { return nil }
|
||||
let found = crew.filter { (c: TMDBCrew) -> Bool in return c.job == job }
|
||||
if found.count == 0 { return nil }
|
||||
return found.flatMap { $0.name }
|
||||
return found.compactMap { $0.name }
|
||||
.reduce("", { $0 + ($0.isEmpty ? "" : ", " ) + $1 })
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public struct TheMovieDB: MetadataService {
|
||||
guard let crew = crew else { return nil }
|
||||
let found = crew.filter { (c: TMDBCrew) -> Bool in return c.department == department }
|
||||
if found.count == 0 { return nil }
|
||||
return found.flatMap { $0.name }
|
||||
return found.compactMap { $0.name }
|
||||
.reduce("", { $0 + ($0.isEmpty ? "" : ", ") + $1 })
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public struct TheMovieDB: MetadataService {
|
||||
let backdropThumbnailSize = config.backdrop_sizes.first {
|
||||
|
||||
if let images = result.images?.posters {
|
||||
artworks.append(contentsOf: images.flatMap { loadArtwork(filePath: $0.file_path, baseURL: imageBaseURL, thumbSize: posterThumbnailSize, kind: .poster) } )
|
||||
artworks.append(contentsOf: images.compactMap { loadArtwork(filePath: $0.file_path, baseURL: imageBaseURL, thumbSize: posterThumbnailSize, kind: .poster) } )
|
||||
}
|
||||
|
||||
if result.images?.posters?.count == 0, let posterPath = result.poster_path,
|
||||
@@ -288,7 +288,7 @@ public struct TheMovieDB: MetadataService {
|
||||
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 }
|
||||
let USRating = ratings.filter { $0.iso_3166_1 == "US" }.compactMap { $0.rating }
|
||||
if let rating = USRating.first {
|
||||
metadata[.rating] = MP42Ratings.defaultManager.ratingStringForiTunesCountry("USA",
|
||||
media: "TV",
|
||||
@@ -342,8 +342,8 @@ public struct TheMovieDB: MetadataService {
|
||||
let imageBaseURL = config.secure_base_url,
|
||||
let posterThumbnailSize = config.poster_sizes.first {
|
||||
|
||||
artworks.append(contentsOf: seasonImages.flatMap { loadArtwork(filePath: $0.file_path, baseURL: imageBaseURL, thumbSize: posterThumbnailSize, kind: .season) } )
|
||||
artworks.append(contentsOf: episodeImages.flatMap { loadArtwork(filePath: $0.file_path, baseURL: imageBaseURL, thumbSize: posterThumbnailSize, kind: .episode) } )
|
||||
artworks.append(contentsOf: seasonImages.compactMap { loadArtwork(filePath: $0.file_path, baseURL: imageBaseURL, thumbSize: posterThumbnailSize, kind: .season) } )
|
||||
artworks.append(contentsOf: episodeImages.compactMap { loadArtwork(filePath: $0.file_path, baseURL: imageBaseURL, thumbSize: posterThumbnailSize, kind: .episode) } )
|
||||
}
|
||||
|
||||
}
|
||||
@@ -352,7 +352,7 @@ public struct TheMovieDB: MetadataService {
|
||||
|
||||
var iTunesImage = [Artwork](), squareTVArt = [Artwork]()
|
||||
let group = DispatchGroup()
|
||||
DispatchQueue.global(priority: .default).async(group: group) {
|
||||
DispatchQueue.global().async(group: group) {
|
||||
// add iTunes artwork
|
||||
if let name = metadata[.seriesName] as? String,
|
||||
let iTunesMetadata = iTunesStore.quickiTunesSearch(tvSeriesName: name,
|
||||
@@ -361,7 +361,7 @@ public struct TheMovieDB: MetadataService {
|
||||
iTunesImage = iTunesMetadata.remoteArtworks
|
||||
}
|
||||
}
|
||||
DispatchQueue.global(priority: .default).async(group: group) {
|
||||
DispatchQueue.global().async(group: group) {
|
||||
// Add Squared TV Artwork
|
||||
squareTVArt = self.loadSquareTVArtwork(metadata)
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public struct TheTVDB : MetadataService, MetadataNameService {
|
||||
var results: Set<String> = Set()
|
||||
|
||||
let series = session.fetch(series: tvShow, language: language)
|
||||
results.formUnion(series.flatMap { $0.seriesName } )
|
||||
results.formUnion(series.compactMap { $0.seriesName } )
|
||||
|
||||
if language != defaultLanguage {
|
||||
let englishResults = search(tvShow: tvShow, language: defaultLanguage)
|
||||
@@ -341,16 +341,16 @@ public struct TheTVDB : MetadataService, MetadataNameService {
|
||||
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) {
|
||||
DispatchQueue.global().async(group: group) {
|
||||
iTunesImage = self.loadiTunesArtwork(metadata)
|
||||
}
|
||||
DispatchQueue.global(priority: .default).async(group: group) {
|
||||
DispatchQueue.global().async(group: group) {
|
||||
squareTVArt = self.loadSquareTVArtwork(metadata)
|
||||
}
|
||||
DispatchQueue.global(priority: .default).async(group: group) {
|
||||
DispatchQueue.global().async(group: group) {
|
||||
seasonImages = self.loadTVArtwork(seriesID: seriesId, type: .season, season: String(season), language: language)
|
||||
}
|
||||
DispatchQueue.global(priority: .default).async(group: group) {
|
||||
DispatchQueue.global().async(group: group) {
|
||||
posterImages = self.loadTVArtwork(seriesID: seriesId, type: .poster, season: String(season), language: language)
|
||||
}
|
||||
group.wait()
|
||||
|
||||
@@ -295,7 +295,7 @@ public struct iTunesStore: MetadataService {
|
||||
return c1.collectionName.minimumEditDistance(other: seriesName) > c2.collectionName.minimumEditDistance(other: seriesName) ? false : true
|
||||
})
|
||||
|
||||
let ids = sortedResults.flatMap { extractID(result: $0, show: seriesName, season: seasonNum, store: store) }
|
||||
let ids = sortedResults.compactMap { extractID(result: $0, show: seriesName, season: seasonNum, store: store) }
|
||||
if ids.isEmpty && sortedResults.first!.collectionName.minimumEditDistance(other: seriesName) < 30 {
|
||||
return [sortedResults.first!.collectionId]
|
||||
} else {
|
||||
@@ -310,7 +310,7 @@ public struct iTunesStore: MetadataService {
|
||||
return a1.artistName.minimumEditDistance(other: seriesName) > a2.artistName.minimumEditDistance(other: seriesName) ? false : true
|
||||
})
|
||||
|
||||
let ids = sortedResults.flatMap { extractID(result: $0, show: seriesName, store: store) }
|
||||
let ids = sortedResults.compactMap { extractID(result: $0, show: seriesName, store: store) }
|
||||
if ids.isEmpty && sortedResults.first!.artistName.minimumEditDistance(other: seriesName) < 30 {
|
||||
return [sortedResults.first!.artistId]
|
||||
} else {
|
||||
@@ -492,7 +492,7 @@ public struct iTunesStore: MetadataService {
|
||||
for node in nodes {
|
||||
if let subXml = try? XMLDocument(xmlString: node.xmlString, options: []),
|
||||
let subNodes = try? subXml.nodes(forXPath: "//a") {
|
||||
return subNodes.flatMap { $0.stringValue }
|
||||
return subNodes.compactMap { $0.stringValue }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user