final fixes for linux

This commit is contained in:
a. fox 2024-02-29 22:16:13 -05:00
parent 54f71ce23f
commit 9add39c455
5 changed files with 26 additions and 5 deletions

View File

@ -6,7 +6,7 @@ import PackageDescription
let package = Package(
name: "Seanut",
platforms: [
.macOS(.v13),
.macOS(.v10_15),
],
products: [
.executable(name: "seanut", targets: ["Seanut"])

15
Sources/APIClient.swift Normal file
View File

@ -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
try data.write(to: location)
}
#endif
}

View File

@ -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.")
}

View File

@ -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 {

View File

@ -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 {