Skip to content

Commit

Permalink
Move TMDBSwift to CouchTracker repo
Browse files Browse the repository at this point in the history
  • Loading branch information
pietrocaselani committed May 15, 2019
1 parent 1ef1ac7 commit acd4f11
Show file tree
Hide file tree
Showing 36 changed files with 1,821 additions and 42 deletions.
1 change: 1 addition & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ excluded:
- vendor
- CouchTrackerCoreTests
- TraktSwiftTests
- TMDBSwiftTests
- CouchTrackerPlayground.playground

opt_in_rules:
Expand Down
1,007 changes: 985 additions & 22 deletions CouchTracker.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

25 changes: 24 additions & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ end

def common_pods
pod 'NonEmpty', '0.1.2'
pod 'TMDB', path: './vendor/TMDB-Swift'
pod 'TVDB', path: './vendor/TVDB-Swift'
pod 'RxSwift', RX_SWIFT_VERSION
end
Expand Down Expand Up @@ -119,3 +118,27 @@ target 'TraktSwiftTests' do

tests_shared_pods
end

target 'TMDBSwift' do
platform :osx, OSX_VERSION
use_frameworks!
inhibit_all_warnings!

api_pods
end

target 'TMDBSwift-iOS' do
platform :ios, IOS_VERSION
use_frameworks!
inhibit_all_warnings!

api_pods
end

target 'TMDBSwiftTests' do
platform :osx, OSX_VERSION
use_frameworks!
inhibit_all_warnings!

tests_shared_pods
end
9 changes: 1 addition & 8 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ PODS:
- Tabman (2.1.4):
- AutoInsetter (~> 1.5)
- Pageboy (~> 3.0)
- TMDB (0.1.0):
- Moya/RxSwift (= 12.0.1)
- SwiftLint (= 0.29.2)
- TVDB (0.1.0):
- Moya/RxSwift (= 12.0.1)
- SwiftLint (= 0.29.2)
Expand All @@ -62,7 +59,6 @@ DEPENDENCIES:
- RxTest (= 4.4.0)
- SnapKit (= 5.0.0)
- Tabman (= 2.1.4)
- TMDB (from `./vendor/TMDB-Swift`)
- TVDB (from `./vendor/TVDB-Swift`)

SPEC REPOS:
Expand Down Expand Up @@ -91,8 +87,6 @@ SPEC REPOS:
- Tabman

EXTERNAL SOURCES:
TMDB:
:path: "./vendor/TMDB-Swift"
TVDB:
:path: "./vendor/TVDB-Swift"

Expand All @@ -119,9 +113,8 @@ SPEC CHECKSUMS:
SnapKit: fd22d10eb9aff484d79a8724eab922c1ddf89bcf
SwiftLint: 47df60bdea6e7e902b193b6596db8683aafd86a3
Tabman: f8a6a1967312077334631d2f67010fe905a545f1
TMDB: c898c13c09362e35225a92badb51a406b692e844
TVDB: 02147961f77ddc25989b72bff5746e3da78ffb3d

PODFILE CHECKSUM: 141012650d5b6f0d9ce0d68ae925a053316a299d
PODFILE CHECKSUM: a8c0a9b8b009ac68b85ccab1d3e4b2ee5538e455

COCOAPODS: 1.5.3
22 changes: 22 additions & 0 deletions TMDBSwift-iOS/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
</dict>
</plist>
19 changes: 19 additions & 0 deletions TMDBSwift-iOS/TMDBSwift_iOS.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// TMDBSwift_iOS.h
// TMDBSwift-iOS
//
// Created by Pietro Caselani on 15/05/19.
// Copyright © 2019 Pietro Caselani. All rights reserved.
//

#import <UIKit/UIKit.h>

//! Project version number for TMDBSwift_iOS.
FOUNDATION_EXPORT double TMDBSwift_iOSVersionNumber;

//! Project version string for TMDBSwift_iOS.
FOUNDATION_EXPORT const unsigned char TMDBSwift_iOSVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <TMDBSwift_iOS/PublicHeader.h>


8 changes: 8 additions & 0 deletions TMDBSwift/BundleExtensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Foundation

extension Bundle {
static var testable: Bundle {
// swiftlint:disable force_unwrapping
return Bundle(identifier: "io.github.pietrocaselani.TMDBSwiftTestable")!
}
}
19 changes: 19 additions & 0 deletions TMDBSwift/Endpoints/ConfigurationEndpoint.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Moya

public enum ConfigurationService {
case configuration
}

extension ConfigurationService: TMDBType {
public var path: String {
return "configuration"
}

public var task: Task {
return .requestPlain
}

public var sampleData: Data {
return stubbedResponse("tmdb_configuration")
}
}
25 changes: 25 additions & 0 deletions TMDBSwift/Endpoints/Episodes.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Moya

public enum Episodes {
case images(showId: Int, season: Int, episode: Int)
}

extension Episodes: TMDBType {
public var path: String {
switch self {
case let .images(showId, season, episode):
return "tv/\(showId)/season/\(season)/episode/\(episode)/images"
}
}

public var task: Task {
return .requestPlain
}

public var sampleData: Data {
switch self {
case .images:
return stubbedResponse("tmdb_episode_images")
}
}
}
28 changes: 28 additions & 0 deletions TMDBSwift/Endpoints/Movies.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Moya

public enum Movies {
case images(movieId: Int)
}

extension Movies: TMDBType {
public var path: String {
switch self {
case let .images(movieId):
return "movie/\(movieId)/images"
}
}

public var task: Task {
return .requestPlain
}

public var sampleData: Data {
switch self {
case let .images(movieId):
guard movieId == 20526 else {
return stubbedResponse("tmdb_movie_images")
}
return stubbedResponse("tmdb_movie_images_20526")
}
}
}
25 changes: 25 additions & 0 deletions TMDBSwift/Endpoints/Shows.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Moya

public enum Shows {
case images(showId: Int)
}

extension Shows: TMDBType {
public var path: String {
switch self {
case let .images(showId):
return "tv/\(showId)/images"
}
}

public var task: Task {
return .requestPlain
}

public var sampleData: Data {
switch self {
case .images:
return stubbedResponse("tmdb_show_images")
}
}
}
24 changes: 24 additions & 0 deletions TMDBSwift/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2019 Pietro Caselani. All rights reserved.</string>
</dict>
</plist>
11 changes: 11 additions & 0 deletions TMDBSwift/Models/Configuration.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
public final class Configuration: Hashable, Codable {
public let images: ImagesConfiguration

public func hash(into hasher: inout Hasher) {
hasher.combine(images)
}

public static func == (lhs: Configuration, rhs: Configuration) -> Bool {
return lhs.hashValue == rhs.hashValue
}
}
30 changes: 30 additions & 0 deletions TMDBSwift/Models/Image.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
public final class Image: Codable {
public let filePath: String
public let width: Int
public let height: Int
public let iso6391: String?
public let aspectRatio: Float
public let voteAverage: Float
public let voteCount: Int

enum CodingKeys: String, CodingKey {
case width, height
case filePath = "file_path"
case iso6391 = "iso_639_1"
case aspectRatio = "aspect_ratio"
case voteAverage = "vote_average"
case voteCount = "vote_count"
}

public required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)

filePath = try container.decode(String.self, forKey: .filePath)
width = try container.decode(Int.self, forKey: .width)
height = try container.decode(Int.self, forKey: .height)
iso6391 = try container.decodeIfPresent(String.self, forKey: .iso6391)
aspectRatio = try container.decode(Float.self, forKey: .aspectRatio)
voteAverage = try container.decode(Float.self, forKey: .voteAverage)
voteCount = try container.decode(Int.self, forKey: .voteCount)
}
}
20 changes: 20 additions & 0 deletions TMDBSwift/Models/Images.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
public final class Images: Codable {
public let identifier: Int
public let backdrops: [Image]
public let posters: [Image]
public let stills: [Image]

private enum CodingKeys: String, CodingKey {
case identifier = "id"
case backdrops, posters, stills
}

public required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)

identifier = try container.decode(Int.self, forKey: .identifier)
backdrops = try container.decodeIfPresent([Image].self, forKey: .backdrops) ?? [Image]()
posters = try container.decodeIfPresent([Image].self, forKey: .posters) ?? [Image]()
stills = try container.decodeIfPresent([Image].self, forKey: .stills) ?? [Image]()
}
}
33 changes: 33 additions & 0 deletions TMDBSwift/Models/ImagesConfiguration.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
public final class ImagesConfiguration: Hashable, Codable {
public let secureBaseURL: String
public let backdropSizes: [String]
public let posterSizes: [String]
public let stillSizes: [String]

private enum CodingKeys: String, CodingKey {
case secureBaseURL = "secure_base_url"
case backdropSizes = "backdrop_sizes"
case posterSizes = "poster_sizes"
case stillSizes = "still_sizes"
}

public required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)

secureBaseURL = try container.decode(String.self, forKey: .secureBaseURL)
backdropSizes = try container.decode([String].self, forKey: .backdropSizes)
posterSizes = try container.decode([String].self, forKey: .posterSizes)
stillSizes = try container.decode([String].self, forKey: .backdropSizes)
}

public func hash(into hasher: inout Hasher) {
hasher.combine(secureBaseURL)
hasher.combine(backdropSizes)
hasher.combine(posterSizes)
hasher.combine(stillSizes)
}

public static func == (lhs: ImagesConfiguration, rhs: ImagesConfiguration) -> Bool {
return lhs.hashValue == rhs.hashValue
}
}
3 changes: 3 additions & 0 deletions TMDBSwift/Models/TMDBError.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public enum TMDBError: Int, Error {
case toManyRequests = 429
}
11 changes: 11 additions & 0 deletions TMDBSwift/String+Enconding.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Foundation

extension String {
public var urlEscaped: String {
return addingPercentEncoding(withAllowedCharacters: .urlHostAllowed) ?? self
}

public var utf8Encoded: Data {
return data(using: .utf8) ?? Data()
}
}
13 changes: 13 additions & 0 deletions TMDBSwift/TMDB+Constants.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Foundation

extension TMDB {
// swiftlint:disable force_unwrapping
public static let baseURL = URL(string: "https://\(TMDB.apiHost)/\(TMDB.apiVersion)")!

static let apiHost = "api.themoviedb.org"
static let apiVersion = "3"
static let defaultSecureImageURL = "https://image.tmdb.org/t/p/"
static let defaultBackdropSizes = ["w300", "w780", "w1280", "original"]
static let defaultPosterSizes = ["w92", "w154", "w185", "w342", "w500", "w780", "original"]
static let defaultStillSizes = ["w92", "w185", "w300", "original"]
}
Loading

0 comments on commit acd4f11

Please sign in to comment.