mirror of
https://github.com/cranci1/Sora.git
synced 2026-03-11 17:45:37 +00:00
bug fixes
This commit is contained in:
parent
e8f1a7d896
commit
dd3b97b0f2
6 changed files with 45 additions and 33 deletions
|
|
@ -351,6 +351,7 @@
|
|||
ENABLE_PREVIEWS = YES;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = "Sora-JS/Info.plist";
|
||||
INFOPLIST_KEY_CFBundleDisplayName = Sora;
|
||||
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
|
||||
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
||||
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
|
||||
|
|
@ -361,7 +362,7 @@
|
|||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0;
|
||||
MARKETING_VERSION = 0.2.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "me.cranci.Sora-JS";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
|
|
@ -382,6 +383,7 @@
|
|||
ENABLE_PREVIEWS = YES;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = "Sora-JS/Info.plist";
|
||||
INFOPLIST_KEY_CFBundleDisplayName = Sora;
|
||||
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
|
||||
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
||||
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
|
||||
|
|
@ -392,7 +394,7 @@
|
|||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0;
|
||||
MARKETING_VERSION = 0.2.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "me.cranci.Sora-JS";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@
|
|||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class JSController: ObservableObject {
|
|||
context.evaluateScript(script)
|
||||
}
|
||||
|
||||
func scrapeAnime(keyword: String, module: ScrapingModule, completion: @escaping ([AnimeItem]) -> Void) {
|
||||
func searchContent(keyword: String, module: ScrapingModule, completion: @escaping ([MediaItem]) -> Void) {
|
||||
let searchUrl = module.metadata.searchBaseUrl.replacingOccurrences(of: "%s", with: keyword.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? "")
|
||||
|
||||
guard let url = URL(string: searchUrl) else {
|
||||
|
|
@ -56,14 +56,14 @@ class JSController: ObservableObject {
|
|||
|
||||
if let parseFunction = self.context.objectForKeyedSubscript("parseHTML"),
|
||||
let results = parseFunction.call(withArguments: [html]).toArray() as? [[String: String]] {
|
||||
let animeItems = results.map { item in
|
||||
AnimeItem(
|
||||
let mediaItems = results.map { item in
|
||||
MediaItem(
|
||||
title: item["title"] ?? "",
|
||||
imageUrl: item["image"] ?? ""
|
||||
)
|
||||
}
|
||||
DispatchQueue.main.async {
|
||||
completion(animeItems)
|
||||
completion(mediaItems)
|
||||
}
|
||||
} else {
|
||||
print("Failed to parse results")
|
||||
|
|
|
|||
|
|
@ -8,14 +8,14 @@
|
|||
import Foundation
|
||||
|
||||
struct ModuleMetadata: Codable, Hashable {
|
||||
let sourceName: String
|
||||
let author: String
|
||||
let iconUrl: String
|
||||
let version: String
|
||||
let language: String
|
||||
let mediaType: String
|
||||
let baseUrl: String
|
||||
let searchBaseUrl: String
|
||||
let scriptUrl: String
|
||||
let version: String
|
||||
let description: String
|
||||
}
|
||||
|
||||
struct ScrapingModule: Codable, Identifiable, Hashable {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
import SwiftUI
|
||||
import Kingfisher
|
||||
|
||||
struct AnimeItem: Identifiable {
|
||||
struct MediaItem: Identifiable {
|
||||
let id = UUID()
|
||||
let title: String
|
||||
let imageUrl: String
|
||||
|
|
@ -18,7 +18,7 @@ struct SearchView: View {
|
|||
@StateObject private var jsController = JSController()
|
||||
@EnvironmentObject var moduleManager: ModuleManager
|
||||
@State private var searchText = ""
|
||||
@State private var animeItems: [AnimeItem] = []
|
||||
@State private var mediaItems: [MediaItem] = []
|
||||
@State private var isSearching = false
|
||||
@AppStorage("selectedModuleId") private var selectedModuleId: String?
|
||||
|
||||
|
|
@ -37,7 +37,7 @@ struct SearchView: View {
|
|||
.font(.headline)
|
||||
Text("Please select a module from settings")
|
||||
.font(.caption)
|
||||
.foregroundColor(.gray)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
.padding()
|
||||
.frame(maxWidth: .infinity)
|
||||
|
|
@ -55,7 +55,7 @@ struct SearchView: View {
|
|||
}
|
||||
|
||||
LazyVGrid(columns: [GridItem(.adaptive(minimum: 150))], spacing: 16) {
|
||||
ForEach(animeItems) { item in
|
||||
ForEach(mediaItems) { item in
|
||||
VStack {
|
||||
KFImage(URL(string: item.imageUrl))
|
||||
.resizable()
|
||||
|
|
@ -80,9 +80,9 @@ struct SearchView: View {
|
|||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
HStack {
|
||||
if let selectedModule = selectedModule {
|
||||
Text(selectedModule.metadata.mediaType)
|
||||
Text(selectedModule.metadata.sourceName)
|
||||
.font(.headline)
|
||||
.foregroundColor(.gray)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
Menu {
|
||||
ForEach(moduleManager.modules) { module in
|
||||
|
|
@ -96,7 +96,7 @@ struct SearchView: View {
|
|||
.frame(width: 20, height: 20)
|
||||
.cornerRadius(4)
|
||||
|
||||
Text(module.metadata.mediaType)
|
||||
Text(module.metadata.sourceName)
|
||||
Spacer()
|
||||
if module.id.uuidString == selectedModuleId {
|
||||
Image(systemName: "checkmark")
|
||||
|
|
@ -106,18 +106,23 @@ struct SearchView: View {
|
|||
}
|
||||
} label: {
|
||||
Image(systemName: "chevron.up.chevron.down")
|
||||
.foregroundColor(.gray)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationViewStyle(StackNavigationViewStyle())
|
||||
.onChange(of: selectedModuleId) { _ in
|
||||
if !searchText.isEmpty {
|
||||
performSearch()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func performSearch() {
|
||||
guard !searchText.isEmpty, let module = selectedModule else {
|
||||
animeItems = []
|
||||
mediaItems = []
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -127,8 +132,8 @@ struct SearchView: View {
|
|||
do {
|
||||
let jsContent = try moduleManager.getModuleContent(module)
|
||||
jsController.loadScript(jsContent)
|
||||
jsController.scrapeAnime(keyword: searchText, module: module) { items in
|
||||
animeItems = items
|
||||
jsController.searchContent(keyword: searchText, module: module) { items in
|
||||
mediaItems = items
|
||||
isSearching = false
|
||||
}
|
||||
} catch {
|
||||
|
|
@ -154,7 +159,7 @@ struct SearchBar: View {
|
|||
.overlay(
|
||||
HStack {
|
||||
Image(systemName: "magnifyingglass")
|
||||
.foregroundColor(.gray)
|
||||
.foregroundColor(.secondary)
|
||||
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
|
||||
.padding(.leading, 8)
|
||||
|
||||
|
|
@ -163,7 +168,7 @@ struct SearchBar: View {
|
|||
self.text = ""
|
||||
}) {
|
||||
Image(systemName: "multiply.circle.fill")
|
||||
.foregroundColor(.gray)
|
||||
.foregroundColor(.secondary)
|
||||
.padding(.trailing, 8)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,14 +26,19 @@ struct SettingsViewModule: View {
|
|||
.padding(.trailing, 10)
|
||||
|
||||
VStack(alignment: .leading) {
|
||||
Text(module.metadata.mediaType)
|
||||
.font(.system(size: 16))
|
||||
.foregroundColor(.primary)
|
||||
HStack(alignment: .bottom, spacing: 4) {
|
||||
Text(module.metadata.sourceName)
|
||||
.font(.headline)
|
||||
.foregroundColor(.primary)
|
||||
Text("v\(module.metadata.version)")
|
||||
.font(.subheadline)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
Text("Author: \(module.metadata.author)")
|
||||
.font(.system(size: 14))
|
||||
.font(.subheadline)
|
||||
.foregroundColor(.secondary)
|
||||
Text("\(module.metadata.language) • v\(module.metadata.version)")
|
||||
.font(.system(size: 14))
|
||||
Text("Language: \(module.metadata.language)")
|
||||
.font(.subheadline)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue