mirror of
https://github.com/cranci1/Sora.git
synced 2026-04-18 23:22:08 +00:00
little fixes
This commit is contained in:
parent
2cf0c01ce5
commit
67894ade21
10 changed files with 52 additions and 52 deletions
|
|
@ -31,8 +31,8 @@
|
|||
132417C02D131A0600B4F2D2 /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 132417B12D131A0600B4F2D2 /* HomeView.swift */; };
|
||||
132417C12D131A0600B4F2D2 /* LibraryManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 132417B32D131A0600B4F2D2 /* LibraryManager.swift */; };
|
||||
132417C22D131A0600B4F2D2 /* LibraryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 132417B42D131A0600B4F2D2 /* LibraryView.swift */; };
|
||||
132417C32D131A0600B4F2D2 /* AnimeInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 132417B62D131A0600B4F2D2 /* AnimeInfoView.swift */; };
|
||||
132417C42D131A0600B4F2D2 /* AnimeInfoExtraction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 132417B72D131A0600B4F2D2 /* AnimeInfoExtraction.swift */; };
|
||||
132417C32D131A0600B4F2D2 /* MediaView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 132417B62D131A0600B4F2D2 /* MediaView.swift */; };
|
||||
132417C42D131A0600B4F2D2 /* MediaExtraction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 132417B72D131A0600B4F2D2 /* MediaExtraction.swift */; };
|
||||
132417CF2D131B7400B4F2D2 /* SwiftSoup in Frameworks */ = {isa = PBXBuildFile; productRef = 132417CE2D131B7400B4F2D2 /* SwiftSoup */; };
|
||||
132417D22D131C5300B4F2D2 /* Kingfisher in Frameworks */ = {isa = PBXBuildFile; productRef = 132417D12D131C5300B4F2D2 /* Kingfisher */; };
|
||||
132417D52D13240200B4F2D2 /* EpisodeCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 132417D42D13240200B4F2D2 /* EpisodeCell.swift */; };
|
||||
|
|
@ -68,8 +68,8 @@
|
|||
132417B12D131A0600B4F2D2 /* HomeView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = "<group>"; };
|
||||
132417B32D131A0600B4F2D2 /* LibraryManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LibraryManager.swift; sourceTree = "<group>"; };
|
||||
132417B42D131A0600B4F2D2 /* LibraryView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LibraryView.swift; sourceTree = "<group>"; };
|
||||
132417B62D131A0600B4F2D2 /* AnimeInfoView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnimeInfoView.swift; sourceTree = "<group>"; };
|
||||
132417B72D131A0600B4F2D2 /* AnimeInfoExtraction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnimeInfoExtraction.swift; sourceTree = "<group>"; };
|
||||
132417B62D131A0600B4F2D2 /* MediaView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MediaView.swift; sourceTree = "<group>"; };
|
||||
132417B72D131A0600B4F2D2 /* MediaExtraction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MediaExtraction.swift; sourceTree = "<group>"; };
|
||||
132417C52D131AA500B4F2D2 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
132417D42D13240200B4F2D2 /* EpisodeCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EpisodeCell.swift; sourceTree = "<group>"; };
|
||||
132417D62D13242400B4F2D2 /* CircularProgressBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircularProgressBar.swift; sourceTree = "<group>"; };
|
||||
|
|
@ -212,7 +212,7 @@
|
|||
132417B22D131A0600B4F2D2 /* LibraryViews */,
|
||||
132417A62D131A0600B4F2D2 /* SearchViews */,
|
||||
132417A92D131A0600B4F2D2 /* SettingsViews */,
|
||||
132417B52D131A0600B4F2D2 /* AnimeViews */,
|
||||
132417B52D131A0600B4F2D2 /* MediaViews */,
|
||||
);
|
||||
path = Views;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -257,23 +257,23 @@
|
|||
path = LibraryViews;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
132417B52D131A0600B4F2D2 /* AnimeViews */ = {
|
||||
132417B52D131A0600B4F2D2 /* MediaViews */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
132417D32D1323F500B4F2D2 /* EpisodeCell */,
|
||||
132417B62D131A0600B4F2D2 /* AnimeInfoView.swift */,
|
||||
132417B72D131A0600B4F2D2 /* AnimeInfoExtraction.swift */,
|
||||
132417D32D1323F500B4F2D2 /* EpisodesCell */,
|
||||
132417B62D131A0600B4F2D2 /* MediaView.swift */,
|
||||
132417B72D131A0600B4F2D2 /* MediaExtraction.swift */,
|
||||
);
|
||||
path = AnimeViews;
|
||||
path = MediaViews;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
132417D32D1323F500B4F2D2 /* EpisodeCell */ = {
|
||||
132417D32D1323F500B4F2D2 /* EpisodesCell */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
132417D42D13240200B4F2D2 /* EpisodeCell.swift */,
|
||||
132417D62D13242400B4F2D2 /* CircularProgressBar.swift */,
|
||||
);
|
||||
path = EpisodeCell;
|
||||
path = EpisodesCell;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
|
@ -356,7 +356,7 @@
|
|||
files = (
|
||||
13B3A4B22D1477F100BCC0D5 /* StorageSettingsView.swift in Sources */,
|
||||
132417BB2D131A0600B4F2D2 /* SettingsIUView.swift in Sources */,
|
||||
132417C42D131A0600B4F2D2 /* AnimeInfoExtraction.swift in Sources */,
|
||||
132417C42D131A0600B4F2D2 /* MediaExtraction.swift in Sources */,
|
||||
132417B82D131A0600B4F2D2 /* SearchView.swift in Sources */,
|
||||
1308CFBC2D19844A004CD38C /* Double+Extension.swift in Sources */,
|
||||
132417D92D1328B900B4F2D2 /* VideoPlayerView.swift in Sources */,
|
||||
|
|
@ -371,7 +371,7 @@
|
|||
132417D72D13242400B4F2D2 /* CircularProgressBar.swift in Sources */,
|
||||
132417C02D131A0600B4F2D2 /* HomeView.swift in Sources */,
|
||||
132417BF2D131A0600B4F2D2 /* SettingView.swift in Sources */,
|
||||
132417C32D131A0600B4F2D2 /* AnimeInfoView.swift in Sources */,
|
||||
132417C32D131A0600B4F2D2 /* MediaView.swift in Sources */,
|
||||
132417A12D1319E800B4F2D2 /* ModuleStruct.swift in Sources */,
|
||||
132417B92D131A0600B4F2D2 /* SearchResultsView.swift in Sources */,
|
||||
132417842D13198000B4F2D2 /* SoraApp.swift in Sources */,
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -11,7 +11,7 @@ import SwiftSoup
|
|||
|
||||
struct HomeView: View {
|
||||
@StateObject private var modulesManager = ModulesManager()
|
||||
@State private var featuredItems: [String: [SearchResult]] = [:]
|
||||
@State private var featuredItems: [String: [ItemResult]] = [:]
|
||||
@State private var isLoading = true
|
||||
|
||||
var body: some View {
|
||||
|
|
@ -40,7 +40,7 @@ struct HomeView: View {
|
|||
ScrollView(.horizontal, showsIndicators: false) {
|
||||
HStack(spacing: 20) {
|
||||
ForEach(items) { item in
|
||||
NavigationLink(destination: AnimeInfoView(module: module, anime: item)) {
|
||||
NavigationLink(destination: MediaView(module: module, item: item)) {
|
||||
VStack {
|
||||
KFImage(URL(string: item.imageUrl))
|
||||
.resizable()
|
||||
|
|
@ -97,7 +97,7 @@ struct HomeView: View {
|
|||
}
|
||||
}
|
||||
|
||||
private func fetchFeaturedItems(for module: ModuleStruct, completion: @escaping ([SearchResult]) -> Void) {
|
||||
private func fetchFeaturedItems(for module: ModuleStruct, completion: @escaping ([ItemResult]) -> Void) {
|
||||
let urlString = module.module[0].featured.url
|
||||
guard let url = URL(string: urlString) else {
|
||||
completion([])
|
||||
|
|
@ -115,7 +115,7 @@ struct HomeView: View {
|
|||
let document = try SwiftSoup.parse(html)
|
||||
let elements = try document.select(module.module[0].featured.documentSelector)
|
||||
|
||||
var results: [SearchResult] = []
|
||||
var results: [ItemResult] = []
|
||||
for element in elements {
|
||||
let title = try element.select(module.module[0].featured.title).text()
|
||||
let href = try element.select(module.module[0].featured.href).attr("href")
|
||||
|
|
@ -125,7 +125,7 @@ struct HomeView: View {
|
|||
imageURL = "\(module.module[0].details.baseURL)\(imageURL)"
|
||||
}
|
||||
|
||||
let result = SearchResult(name: title, imageUrl: imageURL, href: href)
|
||||
let result = ItemResult(name: title, imageUrl: imageURL, href: href)
|
||||
results.append(result)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ struct EpisodeCell: View {
|
|||
let episodeID: Int
|
||||
let imageUrl: String
|
||||
let progress: Double
|
||||
let animeID: Int
|
||||
let itemID: Int
|
||||
|
||||
@State private var episodeTitle: String = ""
|
||||
@State private var episodeImageUrl: String = ""
|
||||
|
|
@ -55,7 +55,7 @@ struct EpisodeCell: View {
|
|||
}
|
||||
|
||||
func fetchEpisodeDetails() {
|
||||
guard let url = URL(string: "https://api.ani.zip/mappings?anilist_id=\(animeID)") else {
|
||||
guard let url = URL(string: "https://api.ani.zip/mappings?anilist_id=\(itemID)") else {
|
||||
isLoading = false
|
||||
return
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// AnimeInfoExtraction.swift
|
||||
// MediaExtraction.swift
|
||||
// Sora
|
||||
//
|
||||
// Created by Francesco on 18/12/24.
|
||||
|
|
@ -8,9 +8,9 @@
|
|||
import SwiftUI
|
||||
import SwiftSoup
|
||||
|
||||
extension AnimeInfoView {
|
||||
func fetchAnimeDetails() {
|
||||
guard let url = URL(string: anime.href.hasPrefix("https") ? anime.href : "\(module.module[0].details.baseURL)\(anime.href)") else { return }
|
||||
extension MediaView {
|
||||
func fetchItemDetails() {
|
||||
guard let url = URL(string: item.href.hasPrefix("https") ? item.href : "\(module.module[0].details.baseURL)\(item.href)") else { return }
|
||||
|
||||
URLSession.custom.dataTask(with: url) { data, response, error in
|
||||
defer { isLoading = false }
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// AnimeDetailsView.swift
|
||||
// MediaView.swift
|
||||
// Sora
|
||||
//
|
||||
// Created by Francesco on 18/12/24.
|
||||
|
|
@ -10,9 +10,9 @@ import SwiftUI
|
|||
import Kingfisher
|
||||
import SafariServices
|
||||
|
||||
struct AnimeInfoView: View {
|
||||
struct MediaView: View {
|
||||
let module: ModuleStruct
|
||||
let anime: SearchResult
|
||||
let item: ItemResult
|
||||
|
||||
@State var aliases: String = ""
|
||||
@State var synopsis: String = ""
|
||||
|
|
@ -21,7 +21,7 @@ struct AnimeInfoView: View {
|
|||
@State var episodes: [String] = []
|
||||
@State var isLoading: Bool = true
|
||||
@State var showFullSynopsis: Bool = false
|
||||
@State var animeID: Int?
|
||||
@State var itemID: Int?
|
||||
@State private var selectedEpisode: String = ""
|
||||
@State private var selectedEpisodeNumber: Int = 0
|
||||
|
||||
|
|
@ -36,18 +36,18 @@ struct AnimeInfoView: View {
|
|||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: 16) {
|
||||
HStack(alignment: .top, spacing: 10) {
|
||||
KFImage(URL(string: anime.imageUrl))
|
||||
KFImage(URL(string: item.imageUrl))
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(height: 190)
|
||||
.cornerRadius(10)
|
||||
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Text(anime.name)
|
||||
Text(item.name)
|
||||
.font(.system(size: 17))
|
||||
.fontWeight(.bold)
|
||||
|
||||
if !aliases.isEmpty && aliases != anime.name {
|
||||
if !aliases.isEmpty && aliases != item.name {
|
||||
Text(aliases)
|
||||
.font(.system(size: 13))
|
||||
.foregroundColor(.secondary)
|
||||
|
|
@ -138,7 +138,7 @@ struct AnimeInfoView: View {
|
|||
let totalTime = UserDefaults.standard.double(forKey: "totalTime_\(episodeURL)")
|
||||
let progress = totalTime > 0 ? lastPlayedTime / totalTime : 0
|
||||
|
||||
EpisodeCell(episode: episodes[index], episodeID: index, imageUrl: anime.imageUrl, progress: progress, animeID: animeID ?? 0)
|
||||
EpisodeCell(episode: episodes[index], episodeID: index, imageUrl: item.imageUrl, progress: progress, itemID: itemID ?? 0)
|
||||
.onTapGesture {
|
||||
selectedEpisode = episodes[index]
|
||||
selectedEpisodeNumber = index + 1
|
||||
|
|
@ -150,21 +150,21 @@ struct AnimeInfoView: View {
|
|||
}
|
||||
.padding()
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.navigationBarTitle(anime.name)
|
||||
.navigationBarTitle(item.name)
|
||||
.navigationViewStyle(StackNavigationViewStyle())
|
||||
}
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
fetchAnimeDetails()
|
||||
fetchAnimeID(byTitle: anime.name) { result in
|
||||
fetchItemDetails()
|
||||
fetchItemID(byTitle: item.name) { result in
|
||||
switch result {
|
||||
case .success(let id):
|
||||
animeID = id
|
||||
Logger.shared.log("Fetched Anime ID: \(id)")
|
||||
itemID = id
|
||||
Logger.shared.log("Fetched Item ID: \(id)")
|
||||
case .failure(let error):
|
||||
print("Failed to fetch Anime ID: \(error)")
|
||||
Logger.shared.log("Failed to fetch Anime ID: \(error)")
|
||||
print("Failed to fetch Item ID: \(error)")
|
||||
Logger.shared.log("Failed to fetch Item ID: \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -196,7 +196,7 @@ struct AnimeInfoView: View {
|
|||
module: module,
|
||||
urlString: streamUrl,
|
||||
fullUrl: fullURL,
|
||||
title: anime.name,
|
||||
title: item.name,
|
||||
episodeNumber: selectedEpisodeNumber,
|
||||
onWatchNext: {
|
||||
selectNextEpisode()
|
||||
|
|
@ -240,7 +240,7 @@ struct AnimeInfoView: View {
|
|||
}
|
||||
|
||||
private func openSafariViewController(with urlString: String) {
|
||||
guard let url = URL(string: anime.href.hasPrefix("http") ? anime.href : "\(module.module[0].details.baseURL)\(anime.href)") else {
|
||||
guard let url = URL(string: item.href.hasPrefix("http") ? item.href : "\(module.module[0].details.baseURL)\(item.href)") else {
|
||||
Logger.shared.log("Unable to open the webpage")
|
||||
return
|
||||
}
|
||||
|
|
@ -260,7 +260,7 @@ struct AnimeInfoView: View {
|
|||
Logger.shared.log("Unable to open the stream: 'streamUrl'")
|
||||
}
|
||||
|
||||
private func fetchAnimeID(byTitle title: String, completion: @escaping (Result<Int, Error>) -> Void) {
|
||||
private func fetchItemID(byTitle title: String, completion: @escaping (Result<Int, Error>) -> Void) {
|
||||
let query = """
|
||||
query {
|
||||
Media(search: "\(title)", type: ANIME) {
|
||||
|
|
@ -12,7 +12,7 @@ import SwiftSoup
|
|||
struct SearchResultsView: View {
|
||||
let module: ModuleStruct?
|
||||
let searchText: String
|
||||
@State private var searchResults: [SearchResult] = []
|
||||
@State private var searchResults: [ItemResult] = []
|
||||
@State private var isLoading: Bool = true
|
||||
@State private var filter: FilterType = .all
|
||||
@AppStorage("listSearch") private var isListSearchEnabled: Bool = false
|
||||
|
|
@ -47,7 +47,7 @@ struct SearchResultsView: View {
|
|||
ScrollView {
|
||||
LazyVGrid(columns: [GridItem(.adaptive(minimum: 150))], spacing: 20) {
|
||||
ForEach(filteredResults) { result in
|
||||
NavigationLink(destination: AnimeInfoView(module: module!, anime: result)) {
|
||||
NavigationLink(destination: MediaView(module: module!, item: result)) {
|
||||
VStack {
|
||||
KFImage(URL(string: result.imageUrl))
|
||||
.resizable()
|
||||
|
|
@ -90,7 +90,7 @@ struct SearchResultsView: View {
|
|||
} else {
|
||||
List {
|
||||
ForEach(filteredResults) { result in
|
||||
NavigationLink(destination: AnimeInfoView(module: module!, anime: result)) {
|
||||
NavigationLink(destination: MediaView(module: module!, item: result)) {
|
||||
HStack {
|
||||
KFImage(URL(string: result.imageUrl))
|
||||
.resizable()
|
||||
|
|
@ -155,7 +155,7 @@ struct SearchResultsView: View {
|
|||
}
|
||||
}
|
||||
|
||||
var filteredResults: [SearchResult] {
|
||||
var filteredResults: [ItemResult] {
|
||||
switch filter {
|
||||
case .all:
|
||||
return searchResults
|
||||
|
|
@ -186,7 +186,7 @@ struct SearchResultsView: View {
|
|||
let document = try SwiftSoup.parse(html)
|
||||
let elements = try document.select(module.module[0].search.documentSelector)
|
||||
|
||||
var results: [SearchResult] = []
|
||||
var results: [ItemResult] = []
|
||||
for element in elements {
|
||||
let title = try element.select(module.module[0].search.title).text()
|
||||
let href = try element.select(module.module[0].search.href).attr("href")
|
||||
|
|
@ -196,7 +196,7 @@ struct SearchResultsView: View {
|
|||
imageURL = "\(module.module[0].details.baseURL)\(imageURL)"
|
||||
}
|
||||
|
||||
let result = SearchResult(name: title, imageUrl: imageURL, href: href)
|
||||
let result = ItemResult(name: title, imageUrl: imageURL, href: href)
|
||||
results.append(result)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import SwiftUI
|
||||
|
||||
struct SearchResult: Identifiable {
|
||||
struct ItemResult: Identifiable {
|
||||
let id = UUID()
|
||||
let name: String
|
||||
let imageUrl: String
|
||||
|
|
@ -16,7 +16,7 @@ struct SearchResult: Identifiable {
|
|||
|
||||
struct SearchView: View {
|
||||
@State private var searchText: String = ""
|
||||
@State private var searchResults: [SearchResult] = []
|
||||
@State private var searchResults: [ItemResult] = []
|
||||
@State private var navigateToResults: Bool = false
|
||||
@State private var selectedModule: ModuleStruct?
|
||||
@State private var showAlert = false
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ struct SettingsModuleView: View {
|
|||
func showAddModuleAlert() {
|
||||
let alert = UIAlertController(title: "Add Module", message: "Enter the URL of the module file", preferredStyle: .alert)
|
||||
alert.addTextField { textField in
|
||||
textField.placeholder = "https://cranci.tech/sora/animeworld.json"
|
||||
textField.placeholder = "https://real.url/module.json"
|
||||
}
|
||||
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
|
||||
alert.addAction(UIAlertAction(title: "Add", style: .default, handler: { _ in
|
||||
|
|
|
|||
Loading…
Reference in a new issue