mirror of
https://github.com/cranci1/Sora.git
synced 2026-04-21 00:22:12 +00:00
yeah weird ass things
This commit is contained in:
parent
9d45c12a6e
commit
d5abd35beb
2 changed files with 109 additions and 7 deletions
|
|
@ -50,6 +50,8 @@ struct MediaInfoView: View {
|
||||||
@EnvironmentObject private var libraryManager: LibraryManager
|
@EnvironmentObject private var libraryManager: LibraryManager
|
||||||
|
|
||||||
@State private var selectedRange: Range<Int> = 0..<100
|
@State private var selectedRange: Range<Int> = 0..<100
|
||||||
|
@State private var showSettingsMenu = false
|
||||||
|
@State private var customAniListID: Int?
|
||||||
|
|
||||||
private var isGroupedBySeasons: Bool {
|
private var isGroupedBySeasons: Bool {
|
||||||
return groupedEpisodes().count > 1
|
return groupedEpisodes().count > 1
|
||||||
|
|
@ -127,6 +129,55 @@ struct MediaInfoView: View {
|
||||||
.padding(4)
|
.padding(4)
|
||||||
.background(Capsule().fill(Color.accentColor.opacity(0.4)))
|
.background(Capsule().fill(Color.accentColor.opacity(0.4)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Menu {
|
||||||
|
Button(action: {
|
||||||
|
showCustomIDAlert()
|
||||||
|
}) {
|
||||||
|
Label("Set Custom AniList ID", systemImage: "number")
|
||||||
|
}
|
||||||
|
|
||||||
|
if let customID = customAniListID {
|
||||||
|
Button(action: {
|
||||||
|
customAniListID = nil
|
||||||
|
itemID = nil
|
||||||
|
fetchItemID(byTitle: cleanTitle(title)) { result in
|
||||||
|
switch result {
|
||||||
|
case .success(let id):
|
||||||
|
itemID = id
|
||||||
|
case .failure(let error):
|
||||||
|
Logger.shared.log("Failed to fetch AniList ID: \(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}) {
|
||||||
|
Label("Reset AniList ID", systemImage: "arrow.clockwise")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let id = itemID ?? customAniListID {
|
||||||
|
Button(action: {
|
||||||
|
if let url = URL(string: "https://anilist.co/anime/\(id)") {
|
||||||
|
openSafariViewController(with: url.absoluteString)
|
||||||
|
}
|
||||||
|
}) {
|
||||||
|
Label("Open in AniList", systemImage: "link")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Divider()
|
||||||
|
|
||||||
|
Button(action: {
|
||||||
|
Logger.shared.log("Debug Info:\nTitle: \(title)\nHref: \(href)\nModule: \(module.metadata.sourceName)\nAniList ID: \(itemID ?? -1)\nCustom ID: \(customAniListID ?? -1)", type: "Debug")
|
||||||
|
DropManager.shared.showDrop(title: "Debug Info Logged", subtitle: "", duration: 1.0, icon: UIImage(systemName: "terminal"))
|
||||||
|
}) {
|
||||||
|
Label("Log Debug Info", systemImage: "terminal")
|
||||||
|
}
|
||||||
|
} label: {
|
||||||
|
Image(systemName: "ellipsis.circle")
|
||||||
|
.resizable()
|
||||||
|
.frame(width: 20, height: 20)
|
||||||
|
.foregroundColor(.primary)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -372,13 +423,19 @@ struct MediaInfoView: View {
|
||||||
DropManager.shared.showDrop(title: "Fetching Data", subtitle: "Please wait while fetching.", duration: 0.5, icon: UIImage(systemName: "arrow.triangle.2.circlepath"))
|
DropManager.shared.showDrop(title: "Fetching Data", subtitle: "Please wait while fetching.", duration: 0.5, icon: UIImage(systemName: "arrow.triangle.2.circlepath"))
|
||||||
fetchDetails()
|
fetchDetails()
|
||||||
|
|
||||||
fetchItemID(byTitle: cleanTitle(title)) { result in
|
if let savedID = UserDefaults.standard.object(forKey: "custom_anilist_id_\(href)") as? Int {
|
||||||
switch result {
|
customAniListID = savedID
|
||||||
case .success(let id):
|
itemID = savedID
|
||||||
itemID = id
|
Logger.shared.log("Using custom AniList ID: \(savedID)", type: "Debug")
|
||||||
case .failure(let error):
|
} else {
|
||||||
Logger.shared.log("Failed to fetch AniList ID: \(error)")
|
fetchItemID(byTitle: cleanTitle(title)) { result in
|
||||||
AnalyticsManager.shared.sendEvent(event: "error", additionalData: ["error": error, "message": "Failed to fetch AniList ID"])
|
switch result {
|
||||||
|
case .success(let id):
|
||||||
|
itemID = id
|
||||||
|
case .failure(let error):
|
||||||
|
Logger.shared.log("Failed to fetch AniList ID: \(error)")
|
||||||
|
AnalyticsManager.shared.sendEvent(event: "error", additionalData: ["error": error, "message": "Failed to fetch AniList ID"])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -857,4 +914,33 @@ struct MediaInfoView: View {
|
||||||
}
|
}
|
||||||
}.resume()
|
}.resume()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func showCustomIDAlert() {
|
||||||
|
let alert = UIAlertController(title: "Set Custom AniList ID", message: "Enter the AniList ID for this media", preferredStyle: .alert)
|
||||||
|
|
||||||
|
alert.addTextField { textField in
|
||||||
|
textField.placeholder = "AniList ID"
|
||||||
|
textField.keyboardType = .numberPad
|
||||||
|
if let customID = customAniListID {
|
||||||
|
textField.text = "\(customID)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel))
|
||||||
|
alert.addAction(UIAlertAction(title: "Save", style: .default) { _ in
|
||||||
|
if let text = alert.textFields?.first?.text,
|
||||||
|
let id = Int(text) {
|
||||||
|
customAniListID = id
|
||||||
|
itemID = id
|
||||||
|
UserDefaults.standard.set(id, forKey: "custom_anilist_id_\(href)")
|
||||||
|
Logger.shared.log("Set custom AniList ID: \(id)", type: "General")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
||||||
|
let window = windowScene.windows.first,
|
||||||
|
let rootVC = window.rootViewController {
|
||||||
|
findTopViewController.findViewController(rootVC).present(alert, animated: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,7 @@
|
||||||
13103E802D589D6C000F0673 /* Tracking Services */ = {
|
13103E802D589D6C000F0673 /* Tracking Services */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
13E62FBF2DABC3A20007E259 /* Trakt */,
|
||||||
13103E812D589D77000F0673 /* AniList */,
|
13103E812D589D77000F0673 /* AniList */,
|
||||||
);
|
);
|
||||||
path = "Tracking Services";
|
path = "Tracking Services";
|
||||||
|
|
@ -395,6 +396,21 @@
|
||||||
path = MediaPlayer;
|
path = MediaPlayer;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
13E62FBF2DABC3A20007E259 /* Trakt */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
13E62FC02DABC3A90007E259 /* Auth */,
|
||||||
|
);
|
||||||
|
path = Trakt;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
13E62FC02DABC3A90007E259 /* Auth */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
);
|
||||||
|
path = Auth;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
13EA2BD02D32D97400C1EBD7 /* CustomPlayer */ = {
|
13EA2BD02D32D97400C1EBD7 /* CustomPlayer */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue