mirror of
https://github.com/cranci1/Sora.git
synced 2026-04-21 00:22:12 +00:00
well maybe this does work
This commit is contained in:
parent
17c8a61416
commit
e86a7b229a
1 changed files with 29 additions and 10 deletions
|
|
@ -60,6 +60,8 @@ struct MediaInfoView: View {
|
||||||
@State private var customAniListID: Int?
|
@State private var customAniListID: Int?
|
||||||
@State private var showStreamLoadingView: Bool = false
|
@State private var showStreamLoadingView: Bool = false
|
||||||
@State private var currentStreamTitle: String = ""
|
@State private var currentStreamTitle: String = ""
|
||||||
|
@State private var isDownloadMode: Bool = false
|
||||||
|
@State private var pendingDownloadEp: EpisodeLink? = nil
|
||||||
|
|
||||||
@State private var activeFetchID: UUID? = nil
|
@State private var activeFetchID: UUID? = nil
|
||||||
@Environment(\.dismiss) private var dismiss
|
@Environment(\.dismiss) private var dismiss
|
||||||
|
|
@ -380,8 +382,10 @@ struct MediaInfoView: View {
|
||||||
episodeNumber: ep.number,
|
episodeNumber: ep.number,
|
||||||
season: 1
|
season: 1
|
||||||
)
|
)
|
||||||
|
|
||||||
if downloadStatus == .notDownloaded {
|
if downloadStatus == .notDownloaded {
|
||||||
|
isDownloadMode = true
|
||||||
|
pendingDownloadEp = ep
|
||||||
selectedEpisodeNumber = ep.number
|
selectedEpisodeNumber = ep.number
|
||||||
fetchStream(href: ep.href)
|
fetchStream(href: ep.href)
|
||||||
DropManager.shared.showDrop(title: "Starting Download", subtitle: "", duration: 1.0, icon: UIImage(systemName: "arrow.down.circle"))
|
DropManager.shared.showDrop(title: "Starting Download", subtitle: "", duration: 1.0, icon: UIImage(systemName: "arrow.down.circle"))
|
||||||
|
|
@ -1071,16 +1075,26 @@ struct MediaInfoView: View {
|
||||||
if sources.count > 1 {
|
if sources.count > 1 {
|
||||||
self.showStreamSelectionAlert(streams: sources, fullURL: href, subtitles: result.subtitles?.first, fetchID: fetchID)
|
self.showStreamSelectionAlert(streams: sources, fullURL: href, subtitles: result.subtitles?.first, fetchID: fetchID)
|
||||||
} else if let streamUrl = sources[0]["streamUrl"] as? String {
|
} else if let streamUrl = sources[0]["streamUrl"] as? String {
|
||||||
let headers = sources[0]["headers"] as? [String: String]
|
if isDownloadMode, let ep = pendingDownloadEp, let urlObj = URL(string: streamUrl) {
|
||||||
self.playStream(url: streamUrl, fullURL: href, subtitles: result.subtitles?.first, headers: headers, fetchID: fetchID)
|
let subtitleURL = result.subtitles?.first.flatMap { URL(string: $0) }
|
||||||
|
startEpisodeDownloadWithProcessedStream(episode: ep, url: urlObj, streamUrl: streamUrl, subtitleURL: subtitleURL)
|
||||||
|
} else {
|
||||||
|
let headers = sources[0]["headers"] as? [String: String]
|
||||||
|
playStream(url: streamUrl, fullURL: href, subtitles: result.subtitles?.first, headers: headers, fetchID: fetchID)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
self.handleStreamFailure(error: nil)
|
handleStreamFailure(error: nil)
|
||||||
}
|
}
|
||||||
} else if let streams = result.streams, !streams.isEmpty {
|
} else if let streams = result.streams, !streams.isEmpty {
|
||||||
if streams.count > 1 {
|
if streams.count > 1 {
|
||||||
self.showStreamSelectionAlert(streams: streams, fullURL: href, subtitles: result.subtitles?.first, fetchID: fetchID)
|
showStreamSelectionAlert(streams: streams, fullURL: href, subtitles: result.subtitles?.first, fetchID: fetchID)
|
||||||
} else {
|
} else if let streamUrl = streams.first {
|
||||||
self.playStream(url: streams[0], fullURL: href, subtitles: result.subtitles?.first, fetchID: fetchID)
|
if isDownloadMode, let ep = pendingDownloadEp, let urlObj = URL(string: streamUrl) {
|
||||||
|
let subtitleURL = result.subtitles?.first.flatMap { URL(string: $0) }
|
||||||
|
startEpisodeDownloadWithProcessedStream(episode: ep, url: urlObj, streamUrl: streamUrl, subtitleURL: subtitleURL)
|
||||||
|
} else {
|
||||||
|
playStream(url: streamUrl, fullURL: href, subtitles: result.subtitles?.first, fetchID: fetchID)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.handleStreamFailure(error: nil)
|
self.handleStreamFailure(error: nil)
|
||||||
|
|
@ -1185,10 +1199,15 @@ struct MediaInfoView: View {
|
||||||
|
|
||||||
|
|
||||||
alert.addAction(UIAlertAction(title: title, style: .default) { _ in
|
alert.addAction(UIAlertAction(title: title, style: .default) { _ in
|
||||||
guard self.activeFetchID == fetchID else {
|
guard self.activeFetchID == fetchID else { return }
|
||||||
return
|
if self.isDownloadMode, let ep = self.pendingDownloadEp, let urlObj = URL(string: streamUrl) {
|
||||||
|
let subtitleURL = subtitles.flatMap { URL(string: $0) }
|
||||||
|
self.startEpisodeDownloadWithProcessedStream(episode: ep, url: urlObj, streamUrl: streamUrl, subtitleURL: subtitleURL)
|
||||||
|
} else {
|
||||||
|
self.playStream(url: streamUrl, fullURL: fullURL, subtitles: subtitles, headers: headers, fetchID: fetchID)
|
||||||
}
|
}
|
||||||
self.playStream(url: streamUrl, fullURL: fullURL, subtitles: subtitles, headers: headers, fetchID: fetchID)
|
self.isDownloadMode = false
|
||||||
|
self.pendingDownloadEp = nil
|
||||||
})
|
})
|
||||||
|
|
||||||
streamIndex += 1
|
streamIndex += 1
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue