Skip to content

Commit

Permalink
Update to CreateAPI 0.2.0 (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
LePips authored Aug 30, 2023
1 parent 2369172 commit ecc338b
Show file tree
Hide file tree
Showing 422 changed files with 473 additions and 496 deletions.
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ let package = Package(
),
.binaryTarget(
name: "create-api",
url: "https://github.com/CreateAPI/CreateAPI/releases/download/0.1.0/create-api.artifactbundle.zip",
checksum: "4e9d1fb023c52e423d57de0928da5d943e3e4c81f6cb903523654867e6372db7"
url: "https://github.com/CreateAPI/CreateAPI/releases/download/0.2.0/create-api.artifactbundle.zip",
checksum: "6f8a3ce099f07eb2655ccaf6f66d8c9a09b74bb2307781c4adec36609ddac009"
),
.plugin(
name: "CreateAPI",
Expand Down
4 changes: 2 additions & 2 deletions Plugins/CreateAPI/GeneratePlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ struct Plugin: CommandPlugin {
.appending(["Sources", "jellyfin-openapi-stable.json"])

let decoder = JSONDecoder()
let data = Data(referencing: try NSData(contentsOfFile: filePath.string))
let data = try Data(referencing: NSData(contentsOfFile: filePath.string))
return try decoder.decode(AnyJSON.self, from: data)
}

Expand Down Expand Up @@ -186,7 +186,7 @@ struct Plugin: CommandPlugin {
.directory
.appending(["Plugins", "CreateAPI", "PatchFiles", "SpecialFeatureType.swift"])

let sourceData = Data(referencing: try NSData(contentsOfFile: sourceFilePath.string))
let sourceData = try Data(referencing: NSData(contentsOfFile: sourceFilePath.string))

let finalFilePath = context
.package
Expand Down
2 changes: 1 addition & 1 deletion Sources/Entities/BaseItemDto.swift
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public struct BaseItemDto: Codable, Hashable, Identifiable {
public var timerID: String?
/// Gets or sets the trailer count.
public var trailerCount: Int?
/// Gets or sets the type.
/// The base item kind.
public var type: BaseItemKind?
/// Gets or sets the user data for this item based on the user it's being requested for.
public var userData: UserItemDataDto?
Expand Down
9 changes: 6 additions & 3 deletions Sources/Entities/ClientCapabilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,20 @@ import Foundation

public struct ClientCapabilities: Codable, Hashable {
public var appStoreURL: String?
/// A MediaBrowser.Model.Dlna.DeviceProfile represents a set of metadata which determines which content a certain device is able to play.
/// A MediaBrowser.Model.Dlna.DeviceProfile represents a set of metadata which determines which content a certain device is able to
/// play.
///
/// <br />
///
/// Specifically, it defines the supported <see cref="P:MediaBrowser.Model.Dlna.DeviceProfile.ContainerProfiles">containers</see> and
///
/// <see cref="P:MediaBrowser.Model.Dlna.DeviceProfile.CodecProfiles">codecs</see> (video and/or audio, including codec profiles and levels)
/// <see cref="P:MediaBrowser.Model.Dlna.DeviceProfile.CodecProfiles">codecs</see> (video and/or audio, including codec profiles and
/// levels)
///
/// the device is able to direct play (without transcoding or remuxing),
///
/// as well as which <see cref="P:MediaBrowser.Model.Dlna.DeviceProfile.TranscodingProfiles">containers/codecs to transcode to</see> in case it isn't.
/// as well as which <see cref="P:MediaBrowser.Model.Dlna.DeviceProfile.TranscodingProfiles">containers/codecs to transcode to</see> in
/// case it isn't.
public var deviceProfile: DeviceProfile?
public var iconURL: String?
public var messageCallbackURL: String?
Expand Down
3 changes: 2 additions & 1 deletion Sources/Entities/DeviceProfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import Foundation
///
/// the device is able to direct play (without transcoding or remuxing),
///
/// as well as which <see cref="P:MediaBrowser.Model.Dlna.DeviceProfile.TranscodingProfiles">containers/codecs to transcode to</see> in case it isn't.
/// as well as which <see cref="P:MediaBrowser.Model.Dlna.DeviceProfile.TranscodingProfiles">containers/codecs to transcode to</see> in case
/// it isn't.
public struct DeviceProfile: Codable, Hashable, Identifiable {
/// Gets or sets the AlbumArtPn.
public var albumArtPn: String?
Expand Down
4 changes: 2 additions & 2 deletions Sources/Entities/DisplayPreferencesDto.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ public struct DisplayPreferencesDto: Codable, Hashable, Identifiable {
public var isRememberIndexing: Bool?
/// Gets or sets a value indicating whether [remember sorting].
public var isRememberSorting: Bool?
/// Gets or sets the scroll direction.
/// An enum representing the axis that should be scrolled.
public var scrollDirection: ScrollDirection?
/// Gets or sets a value indicating whether to show backdrops on this item.
public var isShowBackdrop: Bool?
/// Gets or sets a value indicating whether [show sidebar].
public var isShowSidebar: Bool?
/// Gets or sets the sort by.
public var sortBy: String?
/// Gets or sets the sort order.
/// An enum representing the sorting order.
public var sortOrder: SortOrder?
/// Gets or sets the type of the view.
public var viewType: String?
Expand Down
10 changes: 5 additions & 5 deletions Sources/Entities/EncodingOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public struct EncodingOptions: Codable, Hashable {
public var throttleDelaySeconds: Int?
public var tonemappingAlgorithm: String?
public var tonemappingDesat: Double?
public var tonemappingMode: String?
public var tonemappingParam: Double?
public var tonemappingPeak: Double?
public var tonemappingRange: String?
public var tonemappingThreshold: Double?
public var transcodingTempPath: String?
public var vaapiDevice: String?
public var vppTonemappingBrightness: Double?
Expand Down Expand Up @@ -81,10 +81,10 @@ public struct EncodingOptions: Codable, Hashable {
throttleDelaySeconds: Int? = nil,
tonemappingAlgorithm: String? = nil,
tonemappingDesat: Double? = nil,
tonemappingMode: String? = nil,
tonemappingParam: Double? = nil,
tonemappingPeak: Double? = nil,
tonemappingRange: String? = nil,
tonemappingThreshold: Double? = nil,
transcodingTempPath: String? = nil,
vaapiDevice: String? = nil,
vppTonemappingBrightness: Double? = nil,
Expand Down Expand Up @@ -120,10 +120,10 @@ public struct EncodingOptions: Codable, Hashable {
self.throttleDelaySeconds = throttleDelaySeconds
self.tonemappingAlgorithm = tonemappingAlgorithm
self.tonemappingDesat = tonemappingDesat
self.tonemappingMode = tonemappingMode
self.tonemappingParam = tonemappingParam
self.tonemappingPeak = tonemappingPeak
self.tonemappingRange = tonemappingRange
self.tonemappingThreshold = tonemappingThreshold
self.transcodingTempPath = transcodingTempPath
self.vaapiDevice = vaapiDevice
self.vppTonemappingBrightness = vppTonemappingBrightness
Expand Down Expand Up @@ -165,10 +165,10 @@ public struct EncodingOptions: Codable, Hashable {
self.throttleDelaySeconds = try values.decodeIfPresent(Int.self, forKey: "ThrottleDelaySeconds")
self.tonemappingAlgorithm = try values.decodeIfPresent(String.self, forKey: "TonemappingAlgorithm")
self.tonemappingDesat = try values.decodeIfPresent(Double.self, forKey: "TonemappingDesat")
self.tonemappingMode = try values.decodeIfPresent(String.self, forKey: "TonemappingMode")
self.tonemappingParam = try values.decodeIfPresent(Double.self, forKey: "TonemappingParam")
self.tonemappingPeak = try values.decodeIfPresent(Double.self, forKey: "TonemappingPeak")
self.tonemappingRange = try values.decodeIfPresent(String.self, forKey: "TonemappingRange")
self.tonemappingThreshold = try values.decodeIfPresent(Double.self, forKey: "TonemappingThreshold")
self.transcodingTempPath = try values.decodeIfPresent(String.self, forKey: "TranscodingTempPath")
self.vaapiDevice = try values.decodeIfPresent(String.self, forKey: "VaapiDevice")
self.vppTonemappingBrightness = try values.decodeIfPresent(Double.self, forKey: "VppTonemappingBrightness")
Expand Down Expand Up @@ -210,10 +210,10 @@ public struct EncodingOptions: Codable, Hashable {
try values.encodeIfPresent(throttleDelaySeconds, forKey: "ThrottleDelaySeconds")
try values.encodeIfPresent(tonemappingAlgorithm, forKey: "TonemappingAlgorithm")
try values.encodeIfPresent(tonemappingDesat, forKey: "TonemappingDesat")
try values.encodeIfPresent(tonemappingMode, forKey: "TonemappingMode")
try values.encodeIfPresent(tonemappingParam, forKey: "TonemappingParam")
try values.encodeIfPresent(tonemappingPeak, forKey: "TonemappingPeak")
try values.encodeIfPresent(tonemappingRange, forKey: "TonemappingRange")
try values.encodeIfPresent(tonemappingThreshold, forKey: "TonemappingThreshold")
try values.encodeIfPresent(transcodingTempPath, forKey: "TranscodingTempPath")
try values.encodeIfPresent(vaapiDevice, forKey: "VaapiDevice")
try values.encodeIfPresent(vppTonemappingBrightness, forKey: "VppTonemappingBrightness")
Expand Down
4 changes: 3 additions & 1 deletion Sources/Entities/GetProgramsDto.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ public struct GetProgramsDto: Codable, Hashable {
///
/// Optional.
public var enableUserData: Bool?
/// Gets or sets specify additional fields of information to return in the output. This allows multiple, comma delimited. Options: Budget, Chapters, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines.
/// Gets or sets specify additional fields of information to return in the output. This allows multiple, comma delimited. Options:
/// Budget, Chapters, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds,
/// PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines.
///
/// Optional.
public var fields: [ItemFields]?
Expand Down
18 changes: 12 additions & 6 deletions Sources/Entities/NetworkConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public struct NetworkConfiguration: Codable, Hashable {
public var isAutoDiscoveryTracing: Bool?
/// Gets or sets a value used to specify the URL prefix that your Jellyfin instance can be accessed at.
public var baseURL: String?
/// Gets or sets the password required to access the X.509 certificate data in the file specified by Jellyfin.Networking.Configuration.NetworkConfiguration.CertificatePath.
/// Gets or sets the password required to access the X.509 certificate data in the file specified by
/// Jellyfin.Networking.Configuration.NetworkConfiguration.CertificatePath.
public var certificatePassword: String?
/// Gets or sets the filesystem path of an X.509 certificate to use for SSL.
public var certificatePath: String?
Expand Down Expand Up @@ -46,9 +47,11 @@ public struct NetworkConfiguration: Codable, Hashable {
public var httpserverPortNumber: Int?
/// Gets or sets the HTTPS server port number.
public var httpsPortNumber: Int?
/// Gets or sets a value indicating whether address names that match Jellyfin.Networking.Configuration.NetworkConfiguration.VirtualInterfaceNames should be Ignore for the purposes of binding.
/// Gets or sets a value indicating whether address names that match
/// Jellyfin.Networking.Configuration.NetworkConfiguration.VirtualInterfaceNames should be Ignore for the purposes of binding.
public var isIgnoreVirtualInterfaces: Bool?
/// Gets or sets a value indicating whether <seealso cref="P:Jellyfin.Networking.Configuration.NetworkConfiguration.RemoteIPFilter" /> contains a blacklist or a whitelist. Default is a whitelist.
/// Gets or sets a value indicating whether <seealso cref="P:Jellyfin.Networking.Configuration.NetworkConfiguration.RemoteIPFilter" />
/// contains a blacklist or a whitelist. Default is a whitelist.
public var isRemoteIPFilterBlacklist: Bool?
/// Gets or sets the known proxies. If the proxy is a network, it's added to the KnownNetworks.
public var knownProxies: [String]?
Expand All @@ -64,13 +67,15 @@ public struct NetworkConfiguration: Codable, Hashable {
///
/// Gets or sets PublishedServerUri to advertise for specific subnets.
public var publishedServerUriBySubnet: [String]?
/// Gets or sets the filter for remote IP connectivity. Used in conjuntion with <seealso cref="P:Jellyfin.Networking.Configuration.NetworkConfiguration.IsRemoteIPFilterBlacklist" />.
/// Gets or sets the filter for remote IP connectivity. Used in conjuntion with <seealso
/// cref="P:Jellyfin.Networking.Configuration.NetworkConfiguration.IsRemoteIPFilterBlacklist" />.
public var remoteIPFilter: [String]?
/// Gets or sets a value indicating whether the server should force connections over HTTPS.
public var requireHTTPS: Bool?
/// Gets or sets the SSDPTracingFilter
///
/// Gets or sets a value indicating whether an IP address is to be used to filter the detailed ssdp logs that are being sent to the console/log.
/// Gets or sets a value indicating whether an IP address is to be used to filter the detailed ssdp logs that are being sent to the
/// console/log.
///
/// If the setting "Emby.Dlna": "Debug" msut be set in logging.default.json for this property to work.
public var sSDPTracingFilter: String?
Expand All @@ -86,7 +91,8 @@ public struct NetworkConfiguration: Codable, Hashable {
public var uDPSendDelay: Int?
/// Gets or sets a value indicating whether the http port should be mapped as part of UPnP automatic port forwarding.
public var isUPnPCreateHTTPPortMap: Bool?
/// Gets or sets a value indicating the interfaces that should be ignored. The list can be comma separated. <seealso cref="P:Jellyfin.Networking.Configuration.NetworkConfiguration.IgnoreVirtualInterfaces" />.
/// Gets or sets a value indicating the interfaces that should be ignored. The list can be comma separated. <seealso
/// cref="P:Jellyfin.Networking.Configuration.NetworkConfiguration.IgnoreVirtualInterfaces" />.
public var virtualInterfaceNames: String?

public init(
Expand Down
6 changes: 4 additions & 2 deletions Sources/Entities/ServerConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ public struct ServerConfiguration: Codable, Hashable {
public var libraryScanFanoutConcurrency: Int?
/// Gets or sets the number of days we should retain log files.
public var logFileRetentionDays: Int?
/// Gets or sets the remaining minutes of a book that can be played while still saving playstate. If this percentage is crossed playstate will be reset to the beginning and the item will be marked watched.
/// Gets or sets the remaining minutes of a book that can be played while still saving playstate. If this percentage is crossed
/// playstate will be reset to the beginning and the item will be marked watched.
public var maxAudiobookResume: Int?
/// Gets or sets the maximum percentage of an item that can be played while still saving playstate. If this percentage is crossed playstate will be reset to the beginning and the item will be marked watched.
/// Gets or sets the maximum percentage of an item that can be played while still saving playstate. If this percentage is crossed
/// playstate will be reset to the beginning and the item will be marked watched.
public var maxResumePct: Int?
/// Gets or sets the metadata country code.
public var metadataCountryCode: String?
Expand Down
4 changes: 1 addition & 3 deletions Sources/Entities/SessionInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ public struct SessionInfo: Codable, Hashable, Identifiable {
public var lastActivityDate: Date?
/// Gets or sets the last playback check in.
public var lastPlaybackCheckIn: Date?
/// This is strictly used as a data transfer object from the api layer.
///
/// This holds information about a BaseItem in a format that is convenient for the client.
/// Gets or sets the now playing item.
public var nowPlayingItem: BaseItemDto?
public var nowPlayingQueue: [QueueItem]?
public var nowPlayingQueueFullItems: [BaseItemDto]?
Expand Down
2 changes: 1 addition & 1 deletion Sources/Entities/UserPolicy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public struct UserPolicy: Codable, Hashable {
public var maxParentalRating: Int?
public var passwordResetProviderID: String?
public var remoteClientBitrateLimit: Int?
/// Gets or sets a value indicating what SyncPlay features the user can access.
/// Enum SyncPlayUserAccessType.
public var syncPlayAccess: SyncPlayUserAccessType?

public init(
Expand Down
52 changes: 6 additions & 46 deletions Sources/JellyfinClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,33 +153,13 @@ public final class JellyfinClient {

extension JellyfinClient: APIClientDelegate {

/// Allows you to modify the request right before it is sent.
/// Also injects required Jellyfin headers for every request.
///
/// Gets called right before sending the request. If the retries are enabled,
/// is called before every attempt.
///
/// - parameters:
/// - client: The client that sends the request.
/// - request: The request about to be sent. Can be modified
public func client(_ client: APIClient, willSendRequest request: inout URLRequest) async throws {
// Inject required headers
request.addValue(authHeaders(), forHTTPHeaderField: "Authorization")

try await delegate?.client(_apiClient, willSendRequest: &request)
}

/// Validates response for the given request.
///
/// - parameters:
/// - client: The client that sent the request.
/// - response: The response with an invalid status code.
/// - data: Body of the response, if any.
/// - request: Failing request.
///
/// - throws: An error to be returned to the user. By default, throws
/// ``APIError/unacceptableStatusCode(_:)`` if the code is outside of
/// the `200..<300` range.
public func client(_ client: APIClient, validateResponse response: HTTPURLResponse, data: Data, task: URLSessionTask) throws {
if let delegate = delegate {
try delegate.client(_apiClient, validateResponse: response, data: data, task: task)
Expand All @@ -190,34 +170,12 @@ extension JellyfinClient: APIClientDelegate {
}
}

/// Gets called after a networking failure. Only one retry attempt is allowed.
///
/// - important: This method will only be called for network requests, but not for
/// response body decoding failures or failures with creating requests using
/// ``client(_:makeURLFor:query:)`` and ``client(_:willSendRequest:)``.
///
/// - parameters:
/// - client: The client that sent the request.
/// - task: The failed task.
/// - error: The encountered error.
/// - attempts: The number of already performed attempts.
///
/// - returns: Return `true` to retry the request.
public func client(_ client: APIClient, shouldRetry task: URLSessionTask, error: Error, attempts: Int) async throws -> Bool {
try await delegate?.client(_apiClient, shouldRetry: task, error: error, attempts: attempts) ?? false
}

/// Constructs URL for the given request.
///
/// - parameters:
/// - client: The client that sends the request.
/// - url: The URL passed by the client.
/// - request: The request about to be sent.
///
/// - returns: The URL for the request. Return `nil` to use the default
/// logic used by client.
public func client(_ client: APIClient, makeURLFor url: String, query: [(String, String?)]?) throws -> URL? {
try delegate?.client(_apiClient, makeURLFor: url, query: query)
public func client<T>(_ client: APIClient, makeURLForRequest request: Request<T>) throws -> URL? {
try delegate?.client(_apiClient, makeURLForRequest: request)
}
}

Expand All @@ -227,7 +185,8 @@ public extension JellyfinClient {

/// Signs in a user given a username and password. On a successful response `accessToken` is set to the given access token.
///
/// - Note: Overrides the current access token if one was previously set. Save this token locally or revoke it with `signOut` for proper access token management.
/// - Note: Overrides the current access token if one was previously set. Save this token locally or revoke it with `signOut` for proper
/// access token management.
///
/// - Parameters:
/// - username: username of the user
Expand All @@ -250,7 +209,8 @@ public extension JellyfinClient {

/// Signs in a user given a Quick Connect secret.
///
/// - Note: Overrides the current access token if one was previously set. Save this token locally or revoke it with `signOut` for proper access token management.
/// - Note: Overrides the current access token if one was previously set. Save this token locally or revoke it with `signOut` for proper
/// access token management.
///
/// - Parameters:
/// - quickConnectSecret: current Quick Connect secret
Expand Down
Loading

0 comments on commit ecc338b

Please sign in to comment.