mirror of
https://github.com/cranci1/Sora.git
synced 2026-04-21 00:22:12 +00:00
This commit is contained in:
parent
0aa11c7529
commit
c0eafa1c74
1 changed files with 18 additions and 7 deletions
|
|
@ -247,28 +247,39 @@ struct MediaInfoView: View {
|
||||||
do {
|
do {
|
||||||
let jsContent = try moduleManager.getModuleContent(module)
|
let jsContent = try moduleManager.getModuleContent(module)
|
||||||
jsController.loadScript(jsContent)
|
jsController.loadScript(jsContent)
|
||||||
|
|
||||||
if module.metadata.asyncJS == true {
|
if module.metadata.asyncJS == true {
|
||||||
jsController.fetchStreamUrlJS(episodeUrl: href) { streamUrl in
|
jsController.fetchStreamUrlJS(episodeUrl: href) { streamUrl in
|
||||||
if let url = streamUrl {
|
guard let url = streamUrl, url != "null" else {
|
||||||
playStream(url: url, fullURL: href)
|
handleStreamFailure()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
playStream(url: url, fullURL: href)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
jsController.fetchStreamUrl(episodeUrl: href) { streamUrl in
|
jsController.fetchStreamUrl(episodeUrl: href) { streamUrl in
|
||||||
if let url = streamUrl {
|
guard let url = streamUrl, url != "null" else {
|
||||||
playStream(url: url, fullURL: href)
|
handleStreamFailure()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
playStream(url: url, fullURL: href)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
Logger.shared.log("Error loading module: \(error)", type: "Error")
|
handleStreamFailure(error: error)
|
||||||
DropManager.shared.showDrop(title: "Stream not Found", subtitle: "", duration: 1.0, icon: UIImage(systemName: "xmark"))
|
|
||||||
self.isLoading = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func handleStreamFailure(error: Error? = nil) {
|
||||||
|
if let error = error {
|
||||||
|
Logger.shared.log("Error loading module: \(error)", type: "Error")
|
||||||
|
}
|
||||||
|
DropManager.shared.showDrop(title: "Stream not Found", subtitle: "", duration: 1.0, icon: UIImage(systemName: "xmark"))
|
||||||
|
self.isLoading = false
|
||||||
|
}
|
||||||
|
|
||||||
func playStream(url: String, fullURL: String) {
|
func playStream(url: String, fullURL: String) {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
let videoPlayerViewController = VideoPlayerViewController(module: module)
|
let videoPlayerViewController = VideoPlayerViewController(module: module)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue