fix (#990)
This commit is contained in:
parent
a645444f25
commit
e28805a5cf
|
@ -12,8 +12,10 @@ import JellyfinAPI
|
|||
|
||||
extension JellyfinClient {
|
||||
|
||||
func fullURL<T>(with request: Request<T>) -> URL {
|
||||
let fullPath = configuration.url.appendingPathComponent(request.url?.path ?? "")
|
||||
func fullURL<T>(with request: Request<T>) -> URL? {
|
||||
|
||||
guard let path = request.url?.path else { return configuration.url }
|
||||
guard let fullPath = fullURL(with: path) else { return nil }
|
||||
|
||||
var components = URLComponents(string: fullPath.absoluteString)!
|
||||
components.queryItems = request.query?.map { URLQueryItem(name: $0.0, value: $0.1) } ?? []
|
||||
|
@ -21,7 +23,11 @@ extension JellyfinClient {
|
|||
return components.url ?? fullPath
|
||||
}
|
||||
|
||||
func fullURL(with path: String) -> URL {
|
||||
URL(string: configuration.url.absoluteString + path)!
|
||||
/// Appends the path to the current configuration `URL`, assuming that the path begins with a leading `/`.
|
||||
/// Returns `nil` if the new `URL` is malformed.
|
||||
func fullURL(with path: String) -> URL? {
|
||||
guard let fullPath = URL(string: configuration.url.absoluteString.trimmingCharacters(in: ["/"]) + path)
|
||||
else { return nil }
|
||||
return fullPath
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ import Foundation
|
|||
import JellyfinAPI
|
||||
import UIKit
|
||||
|
||||
// TODO: strongly type errors
|
||||
|
||||
extension MediaSourceInfo {
|
||||
|
||||
func videoPlayerViewModel(with item: BaseItemDto, playSessionID: String) throws -> VideoPlayerViewModel {
|
||||
|
@ -21,8 +23,8 @@ extension MediaSourceInfo {
|
|||
let streamType: StreamType
|
||||
|
||||
if let transcodingURL, !Defaults[.Experimental.forceDirectPlay] {
|
||||
guard let fullTranscodeURL = URL(string: transcodingURL, relativeTo: userSession.server.currentURL)
|
||||
else { throw JellyfinAPIError("Unable to construct transcoded url") }
|
||||
guard let fullTranscodeURL = userSession.client.fullURL(with: transcodingURL)
|
||||
else { throw JellyfinAPIError("Unable to make transcode URL") }
|
||||
playbackURL = fullTranscodeURL
|
||||
streamType = .transcode
|
||||
} else {
|
||||
|
@ -39,7 +41,10 @@ extension MediaSourceInfo {
|
|||
parameters: videoStreamParameters
|
||||
)
|
||||
|
||||
playbackURL = userSession.client.fullURL(with: videoStreamRequest)
|
||||
guard let streamURL = userSession.client.fullURL(with: videoStreamRequest)
|
||||
else { throw JellyfinAPIError("Unable to make stream URL") }
|
||||
|
||||
playbackURL = streamURL
|
||||
streamType = .direct
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@ extension MediaStream {
|
|||
let client = Container.userSession().client
|
||||
let deliveryPath = deliveryURL.removingFirst(if: client.configuration.url.absoluteString.last == "/")
|
||||
|
||||
let fullURL = client.fullURL(with: deliveryPath)
|
||||
guard let fullURL = client.fullURL(with: deliveryPath) else { return nil }
|
||||
|
||||
return .init(
|
||||
url: fullURL,
|
||||
|
|
|
@ -57,7 +57,8 @@ class VideoPlayerViewModel: ViewModel {
|
|||
parameters: parameters
|
||||
)
|
||||
|
||||
let hlsStreamComponents = URLComponents(url: userSession.client.fullURL(with: request), resolvingAgainstBaseURL: false)!
|
||||
// TODO: don't force unwrap
|
||||
let hlsStreamComponents = URLComponents(url: userSession.client.fullURL(with: request)!, resolvingAgainstBaseURL: false)!
|
||||
.addingQueryItem(key: "api_key", value: userSession.user.accessToken)
|
||||
|
||||
return hlsStreamComponents.url!
|
||||
|
|
|
@ -2535,8 +2535,7 @@
|
|||
E148128728C154BF003B8787 /* ItemFilter+ItemTrait.swift */,
|
||||
E11B1B6B2718CD68006DA3E8 /* JellyfinAPIError.swift */,
|
||||
E12A9EF729499E0100731C3A /* JellyfinClient.swift */,
|
||||
E1D8428E2933F2D900D1041A /* MediaSourceInfo.swift */,
|
||||
E18A8E7F28D6083700333B9A /* MediaSourceInfo+ItemVideoPlayerViewModel.swift */,
|
||||
E1F5F9B12BA0200500BA5014 /* MediaSourceInfo */,
|
||||
E122A9122788EAAD0060FA63 /* MediaStream.swift */,
|
||||
E1AD105E26D9ADDD003E4A08 /* NameGuidPair.swift */,
|
||||
E148128428C15472003B8787 /* SortOrder.swift */,
|
||||
|
@ -2821,6 +2820,15 @@
|
|||
path = PagingLibraryView;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
E1F5F9B12BA0200500BA5014 /* MediaSourceInfo */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E1D8428E2933F2D900D1041A /* MediaSourceInfo.swift */,
|
||||
E18A8E7F28D6083700333B9A /* MediaSourceInfo+ItemVideoPlayerViewModel.swift */,
|
||||
);
|
||||
path = MediaSourceInfo;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
E1FA891C289A302600176FEB /* CollectionItemView */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
|
Loading…
Reference in New Issue