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