This commit is contained in:
Damiano Galassi committed 2017-06-30 16:55:15 +02:00
1 parent 51973beabf
commit 554d9defa8
2 files changed
+15 -38

No files matched your search

@@ -70,11 +70,7 @@
} }
+ (NSString *)defaultLanguageForProvider:(NSString *)provider { + (NSString *)defaultLanguageForProvider:(NSString *)provider {
if ([provider isEqualToString:@"iTunes Store"]) { return [SBMetadataImporter importerForProvider:provider].defaultLanguage;
return @"USA (English)";
} else {
return @"en";
}
} }
#pragma mark Asynchronous searching #pragma mark Asynchronous searching
+14 -33
View File
@@ -82,6 +82,12 @@ final public class TheMovieDB: SBMetadataImporter {
// MARK: - Movie metadata loading // MARK: - Movie metadata loading
private func loadArtwork(filePath: String, baseURL: String, thumbSize: String, providerName: String) -> SBRemoteImage? {
guard let url = URL(string: baseURL + "original" + filePath),
let thumbURL = URL(string: baseURL + thumbSize + filePath) else { return nil }
return SBRemoteImage(url: url, thumbURL: thumbURL, providerName: providerName)
}
private func loadMovieArtworks(result: TMDBMovie) -> [SBRemoteImage] { private func loadMovieArtworks(result: TMDBMovie) -> [SBRemoteImage] {
var artworks: [SBRemoteImage] = Array() var artworks: [SBRemoteImage] = Array()
@@ -98,28 +104,17 @@ final public class TheMovieDB: SBMetadataImporter {
let backdropThumbnailSize = config.backdrop_sizes.first { let backdropThumbnailSize = config.backdrop_sizes.first {
if let images = result.images?.posters { if let images = result.images?.posters {
for image in images { artworks.append(contentsOf: images.flatMap { loadArtwork(filePath: $0.file_path, baseURL: imageBaseURL, thumbSize: posterThumbnailSize, providerName: "TheMovieDB|poster") } )
if let url = URL(string: imageBaseURL + "original" + image.file_path),
let thumbURL = URL(string: imageBaseURL + posterThumbnailSize + image.file_path) {
let remoteImage = SBRemoteImage(url: url, thumbURL: thumbURL, providerName: "TheMovieDB|poster")
artworks.append(remoteImage)
}
}
} }
if result.images?.posters?.count == 0, if result.images?.posters?.count == 0, let posterPath = result.poster_path,
let posterPath = result.poster_path, let artwork = loadArtwork(filePath: posterPath, baseURL: imageBaseURL, thumbSize: posterThumbnailSize, providerName: "TheMovieDB|poster") {
let url = URL(string: imageBaseURL + "original" + posterPath), artworks.append(artwork)
let thumbURL = URL(string: imageBaseURL + posterThumbnailSize + posterPath) {
let remoteImage = SBRemoteImage(url: url, thumbURL: thumbURL, providerName: "TheMovieDB|poster")
artworks.append(remoteImage)
} }
if let backdropPath = result.backdrop_path, if let backdropPath = result.backdrop_path,
let url = URL(string: imageBaseURL + "original" + backdropPath), let artwork = loadArtwork(filePath: backdropPath, baseURL: imageBaseURL, thumbSize: backdropThumbnailSize, providerName: "TheMovieDB|poster") {
let thumbURL = URL(string: imageBaseURL + backdropThumbnailSize + backdropPath) { artworks.append(artwork)
let remoteImage = SBRemoteImage(url: url, thumbURL: thumbURL, providerName: "TheMovieDB|poster")
artworks.append(remoteImage)
} }
} }
@@ -333,22 +328,8 @@ final public class TheMovieDB: SBMetadataImporter {
let imageBaseURL = config.secure_base_url, let imageBaseURL = config.secure_base_url,
let posterThumbnailSize = config.poster_sizes.first { let posterThumbnailSize = config.poster_sizes.first {
for image in seasonImages { artworks.append(contentsOf: seasonImages.flatMap { loadArtwork(filePath: $0.file_path, baseURL: imageBaseURL, thumbSize: posterThumbnailSize, providerName: "TheMovieDB|season") } )
if let url = URL(string: imageBaseURL + "original" + image.file_path), artworks.append(contentsOf: episodeImages.flatMap { loadArtwork(filePath: $0.file_path, baseURL: imageBaseURL, thumbSize: posterThumbnailSize, providerName: "TheMovieDB|episode") } )
let thumbURL = URL(string: imageBaseURL + posterThumbnailSize + image.file_path) {
let remoteImage = SBRemoteImage(url: url, thumbURL: thumbURL, providerName: "TheMovieDB|season")
artworks.append(remoteImage)
}
}
for image in episodeImages {
if let url = URL(string: imageBaseURL + "original" + image.file_path),
let thumbURL = URL(string: imageBaseURL + posterThumbnailSize + image.file_path) {
let remoteImage = SBRemoteImage(url: url, thumbURL: thumbURL, providerName: "TheMovieDB|episode")
artworks.append(remoteImage)
}
}
} }
} }