add Moya Lib

init JellyfinAPI
This commit is contained in:
PangMo5 2021-05-27 12:18:54 +09:00
parent 784733da76
commit d9f8fb5e42
3 changed files with 139 additions and 2 deletions

View File

@ -41,6 +41,9 @@
53E4E649263F725B00F67C6B /* MultiSelector.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53E4E648263F725B00F67C6B /* MultiSelector.swift */; };
53EE24E6265060780068F029 /* LibrarySearchView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53EE24E5265060780068F029 /* LibrarySearchView.swift */; };
53FF7F2A263CF3F500585C35 /* LatestMediaView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53FF7F29263CF3F500585C35 /* LatestMediaView.swift */; };
6273DD43265F4195009C1D0B /* Moya in Frameworks */ = {isa = PBXBuildFile; productRef = 6273DD42265F4195009C1D0B /* Moya */; };
6273DD45265F4195009C1D0B /* CombineMoya in Frameworks */ = {isa = PBXBuildFile; productRef = 6273DD44265F4195009C1D0B /* CombineMoya */; };
6273DD48265F41B3009C1D0B /* JellyfinAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6273DD47265F41B3009C1D0B /* JellyfinAPI.swift */; };
AE8C3154265D60BF008AA076 /* SettingsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE8C3153265D60BF008AA076 /* SettingsModel.swift */; };
AE8C3156265D616A008AA076 /* SettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE8C3155265D616A008AA076 /* SettingsViewModel.swift */; };
AE8C3159265D6F90008AA076 /* bitrates.json in Resources */ = {isa = PBXBuildFile; fileRef = AE8C3158265D6F90008AA076 /* bitrates.json */; };
@ -100,6 +103,7 @@
53E4E648263F725B00F67C6B /* MultiSelector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiSelector.swift; sourceTree = "<group>"; };
53EE24E5265060780068F029 /* LibrarySearchView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LibrarySearchView.swift; sourceTree = "<group>"; };
53FF7F29263CF3F500585C35 /* LatestMediaView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LatestMediaView.swift; sourceTree = "<group>"; };
6273DD47265F41B3009C1D0B /* JellyfinAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JellyfinAPI.swift; sourceTree = "<group>"; };
AE8C3153265D60BF008AA076 /* SettingsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsModel.swift; sourceTree = "<group>"; };
AE8C3155265D616A008AA076 /* SettingsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewModel.swift; sourceTree = "<group>"; };
AE8C3158265D6F90008AA076 /* bitrates.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = bitrates.json; sourceTree = "<group>"; };
@ -112,6 +116,8 @@
files = (
538CD954263E3DC100BB5AF0 /* SDWebImageSwiftUI in Frameworks */,
5338F757263B7E2E0014BF09 /* KeychainSwift in Frameworks */,
6273DD45265F4195009C1D0B /* CombineMoya in Frameworks */,
6273DD43265F4195009C1D0B /* Moya in Frameworks */,
53D5E3DD264B47EE00BADDC8 /* MobileVLCKit.xcframework in Frameworks */,
5338F754263B65E10014BF09 /* SwiftyRequest in Frameworks */,
53352571265EA0A0006CCA86 /* Introspect in Frameworks */,
@ -144,6 +150,7 @@
5377CBF3263B596A003A4E83 /* JellyfinPlayer */ = {
isa = PBXGroup;
children = (
6273DD46265F419B009C1D0B /* APIs */,
AE8C3157265D6F5E008AA076 /* Resources */,
AE8C3152265D607B008AA076 /* ViewModels */,
AE8C3151265D6075008AA076 /* Models */,
@ -192,6 +199,14 @@
name = Frameworks;
sourceTree = "<group>";
};
6273DD46265F419B009C1D0B /* APIs */ = {
isa = PBXGroup;
children = (
6273DD47265F41B3009C1D0B /* JellyfinAPI.swift */,
);
path = APIs;
sourceTree = "<group>";
};
AE8C3150265D5FE1008AA076 /* Views */ = {
isa = PBXGroup;
children = (
@ -251,6 +266,8 @@
538CD953263E3DC100BB5AF0 /* SDWebImageSwiftUI */,
5302F8292658791C00647A2E /* Sentry */,
53352570265EA0A0006CCA86 /* Introspect */,
6273DD42265F4195009C1D0B /* Moya */,
6273DD44265F4195009C1D0B /* CombineMoya */,
);
productName = JellyfinPlayer;
productReference = 5377CBF1263B596A003A4E83 /* JellyfinPlayer.app */;
@ -289,6 +306,7 @@
538CD952263E3DC100BB5AF0 /* XCRemoteSwiftPackageReference "SDWebImageSwiftUI" */,
5302F8282658791C00647A2E /* XCRemoteSwiftPackageReference "sentry-cocoa" */,
5335256F265EA0A0006CCA86 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */,
6273DD41265F4195009C1D0B /* XCRemoteSwiftPackageReference "Moya" */,
);
productRefGroup = 5377CBF2263B596A003A4E83 /* Products */;
projectDirPath = "";
@ -332,6 +350,7 @@
53A089D0264DA9DA00D57806 /* MovieItemView.swift in Sources */,
53E4E649263F725B00F67C6B /* MultiSelector.swift in Sources */,
53E4E647263F6CF100F67C6B /* LibraryFilterView.swift in Sources */,
6273DD48265F41B3009C1D0B /* JellyfinAPI.swift in Sources */,
53892777263CBB000035E14B /* JellyApiTypings.swift in Sources */,
5377CBF7263B596A003A4E83 /* ContentView.swift in Sources */,
53987CA82657424A00E7EA70 /* EpisodeItemView.swift in Sources */,
@ -476,7 +495,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 20;
DEVELOPMENT_ASSET_PATHS = "\"JellyfinPlayer/Preview Content\"";
DEVELOPMENT_TEAM = 9R8RREG67J;
DEVELOPMENT_TEAM = 4BHXT8RHFR;
ENABLE_BITCODE = NO;
ENABLE_PREVIEWS = YES;
EXCLUDED_ARCHS = "";
@ -503,7 +522,7 @@
CURRENT_PROJECT_VERSION = 20;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_ASSET_PATHS = "\"JellyfinPlayer/Preview Content\"";
DEVELOPMENT_TEAM = 9R8RREG67J;
DEVELOPMENT_TEAM = 4BHXT8RHFR;
ENABLE_BITCODE = NO;
ENABLE_PREVIEWS = YES;
EXCLUDED_ARCHS = "";
@ -593,6 +612,14 @@
minimumVersion = 2.0.2;
};
};
6273DD41265F4195009C1D0B /* XCRemoteSwiftPackageReference "Moya" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/Moya/Moya";
requirement = {
kind = exactVersion;
version = "15.0.0-alpha.1";
};
};
/* End XCRemoteSwiftPackageReference section */
/* Begin XCSwiftPackageProductDependency section */
@ -626,6 +653,16 @@
package = 538CD952263E3DC100BB5AF0 /* XCRemoteSwiftPackageReference "SDWebImageSwiftUI" */;
productName = SDWebImageSwiftUI;
};
6273DD42265F4195009C1D0B /* Moya */ = {
isa = XCSwiftPackageProductDependency;
package = 6273DD41265F4195009C1D0B /* XCRemoteSwiftPackageReference "Moya" */;
productName = Moya;
};
6273DD44265F4195009C1D0B /* CombineMoya */ = {
isa = XCSwiftPackageProductDependency;
package = 6273DD41265F4195009C1D0B /* XCRemoteSwiftPackageReference "Moya" */;
productName = CombineMoya;
};
/* End XCSwiftPackageProductDependency section */
/* Begin XCVersionGroup section */

View File

@ -1,6 +1,15 @@
{
"object": {
"pins": [
{
"package": "Alamofire",
"repositoryURL": "https://github.com/Alamofire/Alamofire.git",
"state": {
"branch": null,
"revision": "f96b619bcb2383b43d898402283924b80e2c4bae",
"version": "5.4.3"
}
},
{
"package": "async-http-client",
"repositoryURL": "https://github.com/swift-server/async-http-client.git",
@ -37,6 +46,33 @@
"version": "1.9.200"
}
},
{
"package": "Moya",
"repositoryURL": "https://github.com/Moya/Moya",
"state": {
"branch": null,
"revision": "e5a28fb62dd5ff4e17b7025643366550044a40b0",
"version": "15.0.0-alpha.1"
}
},
{
"package": "ReactiveSwift",
"repositoryURL": "https://github.com/Moya/ReactiveSwift.git",
"state": {
"branch": null,
"revision": "f195d82bb30e412e70446e2b4a77e1b514099e88",
"version": "6.1.0"
}
},
{
"package": "RxSwift",
"repositoryURL": "https://github.com/ReactiveX/RxSwift.git",
"state": {
"branch": null,
"revision": "254617dd7fae0c45319ba5fbea435bf4d0e15b5d",
"version": "5.1.2"
}
},
{
"package": "SDWebImage",
"repositoryURL": "https://github.com/SDWebImage/SDWebImage.git",

View File

@ -0,0 +1,64 @@
//
// SearchAPI.swift
// JellyfinPlayer
//
// Created by PangMo5 on 2021/05/27.
//
import Foundation
import Moya
enum SortType: String {
case name = "Name"
}
enum ASC: String {
case descending = "Descending"
case ascending = "Ascending"
}
enum JellyfinAPI {
case search(globalData: GlobalData, url: URL, query: String, sort: SortType = .name, asc: ASC = .descending)
}
extension JellyfinAPI: TargetType {
var baseURL: URL {
switch self {
case let .search(_, url, _, _, _):
return url
}
}
var path: String {
return ""
}
var method: Moya.Method {
switch self {
case .search:
return .get
}
}
var sampleData: Data {
"{".data(using: .utf8)!
}
var task: Task {
switch self {
case let .search(_, _, query, sort, asc):
var parameters = [String: Any]()
parameters["searchTerm"] = query.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
parameters["SortBy"] = sort.rawValue
parameters["SortOrder"] = asc.rawValue
return .requestParameters(parameters: parameters, encoding: JSONEncoding.default)
}
}
var headers: [String: String]? {
switch self {
case let .search(globalData, _, _, _, _):
return ["X-Emby-Authorization": globalData.authHeader]
}
}
}