final fixes for linux
This commit is contained in:
parent
54f71ce23f
commit
9841cc2a4c
|
@ -6,7 +6,7 @@ import PackageDescription
|
|||
let package = Package(
|
||||
name: "Seanut",
|
||||
platforms: [
|
||||
.macOS(.v13),
|
||||
.macOS(.v10_15),
|
||||
],
|
||||
products: [
|
||||
.executable(name: "seanut", targets: ["Seanut"])
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
// APIClient.swift
|
||||
|
||||
import Foundation
|
||||
import Get
|
||||
|
||||
extension APIClient {
|
||||
#if os(Linux)
|
||||
|
||||
public func download<T>(for request: Request<T>, to location: URL) async throws {
|
||||
let data = try await data(for: request).value
|
||||
data.write(to: location)
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
|
@ -92,9 +92,15 @@ extension Seanut {
|
|||
path: "/Items/\(id)/Download",
|
||||
method: .get
|
||||
)
|
||||
let response = try await DownloadCommand.client.download(for: dlReq)
|
||||
|
||||
#if os(Linux)
|
||||
try await DownloadCommand.client.download(for: dlReq, to: outputPath)
|
||||
|
||||
#else
|
||||
let response = try await DownloadCommand.client.download(for: dlReq)
|
||||
try FileManager.default.moveItem(at: response.location, to: outputPath)
|
||||
|
||||
#endif
|
||||
} catch {
|
||||
fatalError("Encountered \(error) downloading media. Please try again later.")
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ extension Seanut {
|
|||
if !FileManager.default.fileExists(atPath: seanutCacheFolder) {
|
||||
do {
|
||||
try FileManager.default.createDirectory(
|
||||
at: URL(filePath: seanutCacheFolder),
|
||||
at: URL(fileURLWithPath: seanutCacheFolder),
|
||||
withIntermediateDirectories: false
|
||||
)
|
||||
} catch {
|
||||
|
|
|
@ -72,7 +72,7 @@ struct Seanut: AsyncParsableCommand {
|
|||
|
||||
let domain = client.configuration.baseURL!
|
||||
let configuration = generateJellyfinConfiguration(url: domain)
|
||||
let fileName = "~/.seanut/\(domain.host()!)".expandingTildeInPath
|
||||
let fileName = "~/.seanut/\(domain.host!)".expandingTildeInPath
|
||||
|
||||
do {
|
||||
let signIn: Request<AuthenticationResponse> = jellyfinRequest(
|
||||
|
@ -84,7 +84,7 @@ struct Seanut: AsyncParsableCommand {
|
|||
)
|
||||
|
||||
let resp = try await client.send(signIn).value
|
||||
try resp.accessToken!.write(to: URL(filePath: fileName), atomically: false, encoding: .utf8)
|
||||
try resp.accessToken!.write(to: URL(fileURLWithPath: fileName), atomically: false, encoding: .utf8)
|
||||
|
||||
print("Access token retrieved ☑️")
|
||||
} catch {
|
||||
|
|
Loading…
Reference in New Issue