mirror of
https://github.com/cranci1/Sora.git
synced 2026-03-11 17:45:37 +00:00
Merge pull request #3 from cranci1/main-cf-autofix
Some checks are pending
Build and Release IPA / Build IPA and Mac Catalyst (push) Waiting to run
Some checks are pending
Build and Release IPA / Build IPA and Mac Catalyst (push) Waiting to run
Apply fixes from CodeFactor
This commit is contained in:
commit
0f8852dc98
9 changed files with 13 additions and 13 deletions
|
|
@ -53,7 +53,7 @@ struct ContentView: View {
|
||||||
func fetchLatestRelease(completion: @escaping (GitHubRelease?) -> Void) {
|
func fetchLatestRelease(completion: @escaping (GitHubRelease?) -> Void) {
|
||||||
let url = URL(string: "https://api.github.com/repos/cranci1/Sora/releases/latest")!
|
let url = URL(string: "https://api.github.com/repos/cranci1/Sora/releases/latest")!
|
||||||
|
|
||||||
URLSession.custom.dataTask(with: url) { data, response, error in
|
URLSession.custom.dataTask(with: url) { data, _, error in
|
||||||
guard let data = data, error == nil else {
|
guard let data = data, error == nil else {
|
||||||
completion(nil)
|
completion(nil)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -55,13 +55,13 @@ struct MusicProgressSlider<T: BinaryFloatingPoint>: View {
|
||||||
.frame(width: bounds.size.width, height: bounds.size.height, alignment: .center)
|
.frame(width: bounds.size.width, height: bounds.size.height, alignment: .center)
|
||||||
.contentShape(Rectangle())
|
.contentShape(Rectangle())
|
||||||
.gesture(DragGesture(minimumDistance: 0, coordinateSpace: .local)
|
.gesture(DragGesture(minimumDistance: 0, coordinateSpace: .local)
|
||||||
.updating($isActive) { value, state, transaction in
|
.updating($isActive) { _, state, _ in
|
||||||
state = true
|
state = true
|
||||||
}
|
}
|
||||||
.onChanged { gesture in
|
.onChanged { gesture in
|
||||||
localTempProgress = T(gesture.translation.width / bounds.size.width)
|
localTempProgress = T(gesture.translation.width / bounds.size.width)
|
||||||
value = max(min(getPrgValue(), inRange.upperBound), inRange.lowerBound)
|
value = max(min(getPrgValue(), inRange.upperBound), inRange.lowerBound)
|
||||||
}.onEnded { value in
|
}.onEnded { _ in
|
||||||
localRealProgress = max(min(localRealProgress + localTempProgress, 1), 0)
|
localRealProgress = max(min(localRealProgress + localTempProgress, 1), 0)
|
||||||
localTempProgress = 0
|
localTempProgress = 0
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ class GitHubAPI {
|
||||||
func fetchReleases(completion: @escaping ([GitHubReleases]?) -> Void) {
|
func fetchReleases(completion: @escaping ([GitHubReleases]?) -> Void) {
|
||||||
let url = URL(string: "https://api.github.com/repos/cranci1/Sora/releases")!
|
let url = URL(string: "https://api.github.com/repos/cranci1/Sora/releases")!
|
||||||
|
|
||||||
URLSession.custom.dataTask(with: url) { data, response, error in
|
URLSession.custom.dataTask(with: url) { data, _, error in
|
||||||
guard let data = data, error == nil else {
|
guard let data = data, error == nil else {
|
||||||
completion(nil)
|
completion(nil)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ class ModulesManager: ObservableObject {
|
||||||
completion(.failure(ModuleError.invalidURL))
|
completion(.failure(ModuleError.invalidURL))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let task = URLSession.custom.dataTask(with: url) { data, response, error in
|
let task = URLSession.custom.dataTask(with: url) { data, _, error in
|
||||||
guard let data = data, error == nil else {
|
guard let data = data, error == nil else {
|
||||||
completion(.failure(error ?? ModuleError.unknown))
|
completion(.failure(error ?? ModuleError.unknown))
|
||||||
return
|
return
|
||||||
|
|
@ -69,7 +69,7 @@ class ModulesManager: ObservableObject {
|
||||||
func refreshModules() {
|
func refreshModules() {
|
||||||
for (name, urlString) in moduleURLs {
|
for (name, urlString) in moduleURLs {
|
||||||
guard let url = URL(string: urlString) else { continue }
|
guard let url = URL(string: urlString) else { continue }
|
||||||
let task = URLSession.custom.dataTask(with: url) { data, response, error in
|
let task = URLSession.custom.dataTask(with: url) { data, _, error in
|
||||||
guard let data = data, error == nil else { return }
|
guard let data = data, error == nil else { return }
|
||||||
do {
|
do {
|
||||||
let updatedModule = try JSONDecoder().decode(ModuleStruct.self, from: data)
|
let updatedModule = try JSONDecoder().decode(ModuleStruct.self, from: data)
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ struct HomeView: View {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
URLSession.custom.dataTask(with: url) { data, response, error in
|
URLSession.custom.dataTask(with: url) { data, _, error in
|
||||||
guard let data = data, error == nil else {
|
guard let data = data, error == nil else {
|
||||||
completion([])
|
completion([])
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ struct EpisodeCell: View {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
URLSession.custom.dataTask(with: url) { data, response, error in
|
URLSession.custom.dataTask(with: url) { data, _, error in
|
||||||
if let error = error {
|
if let error = error {
|
||||||
print("Failed to fetch episode details: \(error)")
|
print("Failed to fetch episode details: \(error)")
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ extension MediaView {
|
||||||
func fetchItemDetails() {
|
func fetchItemDetails() {
|
||||||
guard let url = URL(string: item.href.hasPrefix("https") ? item.href : "\(module.module[0].details.baseURL.hasSuffix("/") ? module.module[0].details.baseURL : "\(module.module[0].details.baseURL)/")\(item.href.hasPrefix("/") ? String(item.href.dropFirst()) : item.href)") else { return }
|
guard let url = URL(string: item.href.hasPrefix("https") ? item.href : "\(module.module[0].details.baseURL.hasSuffix("/") ? module.module[0].details.baseURL : "\(module.module[0].details.baseURL)/")\(item.href.hasPrefix("/") ? String(item.href.dropFirst()) : item.href)") else { return }
|
||||||
|
|
||||||
URLSession.custom.dataTask(with: url) { data, response, error in
|
URLSession.custom.dataTask(with: url) { data, _, error in
|
||||||
defer { isLoading = false }
|
defer { isLoading = false }
|
||||||
guard let data = data, error == nil else { return }
|
guard let data = data, error == nil else { return }
|
||||||
|
|
||||||
|
|
@ -53,7 +53,7 @@ extension MediaView {
|
||||||
guard let url = URL(string: urlString.hasPrefix("https") ? urlString : "\(module.module[0].details.baseURL)\(urlString)") else { return }
|
guard let url = URL(string: urlString.hasPrefix("https") ? urlString : "\(module.module[0].details.baseURL)\(urlString)") else { return }
|
||||||
|
|
||||||
Logger.shared.log("Pressed episode button")
|
Logger.shared.log("Pressed episode button")
|
||||||
URLSession.custom.dataTask(with: url) { data, response, error in
|
URLSession.custom.dataTask(with: url) { data, _, error in
|
||||||
guard let data = data, error == nil else { return }
|
guard let data = data, error == nil else { return }
|
||||||
|
|
||||||
let html = String(data: data, encoding: .utf8) ?? ""
|
let html = String(data: data, encoding: .utf8) ?? ""
|
||||||
|
|
@ -80,7 +80,7 @@ extension MediaView {
|
||||||
let patternURL = extractPatternURL(from: html)
|
let patternURL = extractPatternURL(from: html)
|
||||||
guard let patternURL = patternURL else { return }
|
guard let patternURL = patternURL else { return }
|
||||||
|
|
||||||
URLSession.custom.dataTask(with: patternURL) { data, response, error in
|
URLSession.custom.dataTask(with: patternURL) { data, _, error in
|
||||||
guard let data = data, error == nil else { return }
|
guard let data = data, error == nil else { return }
|
||||||
|
|
||||||
let patternHTML = String(data: data, encoding: .utf8) ?? ""
|
let patternHTML = String(data: data, encoding: .utf8) ?? ""
|
||||||
|
|
|
||||||
|
|
@ -352,7 +352,7 @@ struct MediaView: View {
|
||||||
let parameters: [String: Any] = ["query": query]
|
let parameters: [String: Any] = ["query": query]
|
||||||
request.httpBody = try? JSONSerialization.data(withJSONObject: parameters)
|
request.httpBody = try? JSONSerialization.data(withJSONObject: parameters)
|
||||||
|
|
||||||
URLSession.custom.dataTask(with: request) { data, response, error in
|
URLSession.custom.dataTask(with: request) { data, _, error in
|
||||||
if let error = error {
|
if let error = error {
|
||||||
completion(.failure(error))
|
completion(.failure(error))
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,7 @@ struct SearchResultsView: View {
|
||||||
let urlString = "\(module.module[0].search.url)?\(module.module[0].search.parameter)=\(encodedSearchText)"
|
let urlString = "\(module.module[0].search.url)?\(module.module[0].search.parameter)=\(encodedSearchText)"
|
||||||
guard let url = URL(string: urlString) else { return }
|
guard let url = URL(string: urlString) else { return }
|
||||||
|
|
||||||
URLSession.custom.dataTask(with: url) { data, response, error in
|
URLSession.custom.dataTask(with: url) { data, _, error in
|
||||||
defer { isLoading = false }
|
defer { isLoading = false }
|
||||||
guard let data = data, error == nil else { return }
|
guard let data = data, error == nil else { return }
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue