mirror of
https://github.com/cranci1/Sora.git
synced 2026-04-12 20:40:21 +00:00
test fix
This commit is contained in:
parent
653e714955
commit
34334f8e6e
2 changed files with 38 additions and 9 deletions
|
|
@ -110,7 +110,7 @@ struct EpisodeCell: View {
|
|||
Spacer()
|
||||
CircularProgressBar(progress: currentProgress)
|
||||
.frame(width: 40, height: 40)
|
||||
.padding(.trailing, 8)
|
||||
.padding(.trailing, 4)
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
.background(isMultiSelectMode && isSelected ? Color.accentColor.opacity(0.1) : Color.clear)
|
||||
|
|
|
|||
|
|
@ -755,22 +755,28 @@ struct MediaInfoView: View {
|
|||
showLoadingAlert = true
|
||||
isFetchingEpisode = true
|
||||
let completion: ((streams: [String]?, subtitles: [String]?, sources: [[String: Any]]?)) -> Void = { result in
|
||||
guard self.activeFetchID == fetchID else { return }
|
||||
guard self.activeFetchID == fetchID else {
|
||||
return
|
||||
}
|
||||
self.showLoadingAlert = false
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
guard self.activeFetchID == fetchID else {
|
||||
return
|
||||
}
|
||||
|
||||
if let streams = result.sources, !streams.isEmpty {
|
||||
if streams.count > 1 {
|
||||
self.showStreamSelectionAlert(streams: streams, fullURL: href, subtitles: result.subtitles?.first)
|
||||
self.showStreamSelectionAlert(streams: streams, fullURL: href, subtitles: result.subtitles?.first, fetchID: fetchID)
|
||||
} else {
|
||||
self.playStream(url: streams[0]["streamUrl"] as? String ?? "", fullURL: href, subtitles: result.subtitles?.first, headers: streams[0]["headers"] as! [String : String])
|
||||
self.playStream(url: streams[0]["streamUrl"] as? String ?? "", fullURL: href, subtitles: result.subtitles?.first, headers: (streams[0]["headers"] as! [String : String]), fetchID: fetchID)
|
||||
}
|
||||
}
|
||||
else if let streams = result.streams, !streams.isEmpty {
|
||||
if streams.count > 1 {
|
||||
self.showStreamSelectionAlert(streams: streams, fullURL: href, subtitles: result.subtitles?.first)
|
||||
self.showStreamSelectionAlert(streams: streams, fullURL: href, subtitles: result.subtitles?.first, fetchID: fetchID)
|
||||
} else {
|
||||
self.playStream(url: streams[0], fullURL: href, subtitles: result.subtitles?.first)
|
||||
self.playStream(url: streams[0], fullURL: href, subtitles: result.subtitles?.first, fetchID: fetchID)
|
||||
}
|
||||
} else {
|
||||
self.handleStreamFailure(error: nil)
|
||||
|
|
@ -816,11 +822,19 @@ struct MediaInfoView: View {
|
|||
self.isLoading = false
|
||||
}
|
||||
|
||||
func showStreamSelectionAlert(streams: [Any], fullURL: String, subtitles: String? = nil) {
|
||||
func showStreamSelectionAlert(streams: [Any], fullURL: String, subtitles: String? = nil, fetchID: UUID) {
|
||||
guard self.activeFetchID == fetchID else {
|
||||
return
|
||||
}
|
||||
|
||||
self.isFetchingEpisode = false
|
||||
self.showLoadingAlert = false
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
guard self.activeFetchID == fetchID else {
|
||||
return
|
||||
}
|
||||
|
||||
let alert = UIAlertController(title: "Select Server", message: "Choose a server to play from", preferredStyle: .actionSheet)
|
||||
|
||||
var index = 0
|
||||
|
|
@ -866,7 +880,10 @@ struct MediaInfoView: View {
|
|||
|
||||
|
||||
alert.addAction(UIAlertAction(title: title, style: .default) { _ in
|
||||
self.playStream(url: streamUrl, fullURL: fullURL, subtitles: subtitles,headers: headers)
|
||||
guard self.activeFetchID == fetchID else {
|
||||
return
|
||||
}
|
||||
self.playStream(url: streamUrl, fullURL: fullURL, subtitles: subtitles, headers: headers, fetchID: fetchID)
|
||||
})
|
||||
|
||||
streamIndex += 1
|
||||
|
|
@ -900,11 +917,19 @@ struct MediaInfoView: View {
|
|||
}
|
||||
}
|
||||
|
||||
func playStream(url: String, fullURL: String, subtitles: String? = nil, headers: [String:String]? = nil) {
|
||||
func playStream(url: String, fullURL: String, subtitles: String? = nil, headers: [String:String]? = nil, fetchID: UUID) {
|
||||
guard self.activeFetchID == fetchID else {
|
||||
return
|
||||
}
|
||||
|
||||
self.isFetchingEpisode = false
|
||||
self.showLoadingAlert = false
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
guard self.activeFetchID == fetchID else {
|
||||
return
|
||||
}
|
||||
|
||||
let externalPlayer = UserDefaults.standard.string(forKey: "externalPlayer") ?? "Sora"
|
||||
var scheme: String?
|
||||
|
||||
|
|
@ -952,6 +977,10 @@ struct MediaInfoView: View {
|
|||
return
|
||||
}
|
||||
|
||||
guard self.activeFetchID == fetchID else {
|
||||
return
|
||||
}
|
||||
|
||||
let customMediaPlayer = CustomMediaPlayerViewController(
|
||||
module: module,
|
||||
urlString: url.absoluteString,
|
||||
|
|
|
|||
Loading…
Reference in a new issue