fixed issue on episode stream on failure

This commit is contained in:
cranci1 2025-01-28 18:03:19 +01:00
parent b6eda454bf
commit ac500c58ac
3 changed files with 7 additions and 5 deletions

View file

@ -183,8 +183,8 @@
133D7C882D2BE2640075467E /* Modules */ = {
isa = PBXGroup;
children = (
133D7C892D2BE2640075467E /* Modules.swift */,
139935652D468C450065CEFF /* ModuleManager.swift */,
133D7C892D2BE2640075467E /* Modules.swift */,
);
path = Modules;
sourceTree = "<group>";

View file

@ -17,6 +17,7 @@ struct ModuleMetadata: Codable, Hashable {
let searchBaseUrl: String
let scriptUrl: String
let asyncJS: Bool?
let streamAsyncJS: Bool?
}
struct ScrapingModule: Codable, Identifiable, Hashable {

View file

@ -324,14 +324,13 @@ struct MediaInfoView: View {
let jsContent = try moduleManager.getModuleContent(module)
jsController.loadScript(jsContent)
if module.metadata.asyncJS == true {
if module.metadata.asyncJS == true || module.metadata.streamAsyncJS == true {
jsController.fetchStreamUrlJS(episodeUrl: href) { streamUrl in
guard let url = streamUrl, url != "null" else {
handleStreamFailure()
return
}
playStream(url: url, fullURL: href)
isFetchingEpisode = false
}
} else {
jsController.fetchStreamUrl(episodeUrl: href) { streamUrl in
@ -340,15 +339,14 @@ struct MediaInfoView: View {
return
}
playStream(url: url, fullURL: href)
isFetchingEpisode = false
}
}
} catch {
handleStreamFailure(error: error)
isFetchingEpisode = false
}
}
}
isFetchingEpisode = false
}
func handleStreamFailure(error: Error? = nil) {
@ -356,6 +354,9 @@ struct MediaInfoView: View {
Logger.shared.log("Error loading module: \(error)", type: "Error")
}
DropManager.shared.showDrop(title: "Stream not Found", subtitle: "", duration: 1.0, icon: UIImage(systemName: "xmark"))
UINotificationFeedbackGenerator().notificationOccurred(.error)
self.isFetchingEpisode = false
self.isLoading = false
}