mirror of
https://github.com/cranci1/Sora.git
synced 2026-01-11 20:10:24 +00:00
fixed code missing + range/season is now saved
This commit is contained in:
parent
dcd7c363c6
commit
ac6e687107
4 changed files with 68 additions and 44 deletions
|
|
@ -70,7 +70,7 @@ class DownloadManager: NSObject, ObservableObject {
|
|||
for (key, value) in headers {
|
||||
urlRequest.addValue(value, forHTTPHeaderField: key)
|
||||
}
|
||||
} else if headers == nil {
|
||||
} else {
|
||||
urlRequest.addValue(module.metadata.baseUrl, forHTTPHeaderField: "Origin")
|
||||
urlRequest.addValue(module.metadata.baseUrl, forHTTPHeaderField: "Referer")
|
||||
}
|
||||
|
|
@ -171,8 +171,7 @@ extension DownloadManager: AVAssetDownloadDelegate {
|
|||
}
|
||||
|
||||
func urlSession(_ session: URLSession, assetDownloadTask: AVAssetDownloadTask, didLoad timeRange: CMTimeRange, totalTimeRangesLoaded loadedTimeRanges: [NSValue], timeRangeExpectedToLoad: CMTimeRange) {
|
||||
guard let (originalURL, _) = activeDownloadTasks[assetDownloadTask],
|
||||
let downloadIndex = activeDownloads.firstIndex(where: { $0.originalURL == originalURL }) else { return }
|
||||
guard let (originalURL, _) = activeDownloadTasks[assetDownloadTask], let downloadIndex = activeDownloads.firstIndex(where: { $0.originalURL == originalURL }) else { return }
|
||||
|
||||
let progress = loadedTimeRanges
|
||||
.map { $0.timeRangeValue.duration.seconds / timeRangeExpectedToLoad.duration.seconds }
|
||||
|
|
|
|||
|
|
@ -203,20 +203,16 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
}
|
||||
|
||||
var request = URLRequest(url: url)
|
||||
if let mydict = headers, !mydict.isEmpty
|
||||
{
|
||||
for (key,value) in mydict
|
||||
{
|
||||
if let mydict = headers, !mydict.isEmpty {
|
||||
for (key,value) in mydict {
|
||||
request.addValue(value, forHTTPHeaderField: key)
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
request.addValue("\(module.metadata.baseUrl)", forHTTPHeaderField: "Referer")
|
||||
request.addValue("\(module.metadata.baseUrl)", forHTTPHeaderField: "Origin")
|
||||
}
|
||||
request.addValue("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36",
|
||||
forHTTPHeaderField: "User-Agent")
|
||||
|
||||
request.addValue("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36", forHTTPHeaderField: "User-Agent")
|
||||
|
||||
let asset = AVURLAsset(url: url, options: ["AVURLAssetHTTPHeaderFieldsKey": request.allHTTPHeaderFields ?? [:]])
|
||||
let playerItem = AVPlayerItem(asset: asset)
|
||||
|
|
@ -301,6 +297,9 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
}
|
||||
|
||||
#if os(iOS) && !targetEnvironment(macCatalyst)
|
||||
if #available(iOS 16.0, *) {
|
||||
playerViewController.allowsVideoFrameAnalysis = false
|
||||
}
|
||||
#endif
|
||||
|
||||
if let url = subtitlesURL, !url.isEmpty {
|
||||
|
|
|
|||
|
|
@ -313,23 +313,24 @@ struct MediaInfoView: View {
|
|||
}
|
||||
},
|
||||
onMarkAllPrevious: {
|
||||
let userDefaults = UserDefaults.standard
|
||||
var updates = [String: Double]()
|
||||
|
||||
for ep2 in seasons[selectedSeason] where ep2.number < ep.number {
|
||||
let href = ep2.href
|
||||
updates["lastPlayedTime_\(href)"] = 99999999.0
|
||||
updates["totalTime_\(href)"] = 99999999.0
|
||||
DispatchQueue.main.async {
|
||||
let userDefaults = UserDefaults.standard
|
||||
let updates = NSMutableDictionary()
|
||||
|
||||
for ep2 in seasons[selectedSeason] where ep2.number < ep.number {
|
||||
let href = ep2.href
|
||||
updates.setValue(1000.0, forKey: "lastPlayedTime_\(href)")
|
||||
updates.setValue(1000.0, forKey: "totalTime_\(href)")
|
||||
}
|
||||
|
||||
userDefaults.setValuesForKeys(updates as! [String: Any])
|
||||
userDefaults.synchronize()
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
refreshTrigger.toggle()
|
||||
Logger.shared.log("Marked episodes watched within season \(selectedSeason + 1) of \"\(title)\".", type: "General")
|
||||
}
|
||||
}
|
||||
|
||||
for (key, value) in updates {
|
||||
userDefaults.set(value, forKey: key)
|
||||
}
|
||||
|
||||
userDefaults.synchronize()
|
||||
|
||||
refreshTrigger.toggle()
|
||||
Logger.shared.log("Marked episodes watched within season \(selectedSeason + 1) of \"\(title)\".", type: "General")
|
||||
}
|
||||
)
|
||||
.id(refreshTrigger)
|
||||
|
|
@ -364,23 +365,26 @@ struct MediaInfoView: View {
|
|||
}
|
||||
},
|
||||
onMarkAllPrevious: {
|
||||
let userDefaults = UserDefaults.standard
|
||||
var updates = [String: Double]()
|
||||
|
||||
for idx in 0..<i {
|
||||
if idx < episodeLinks.count {
|
||||
let href = episodeLinks[idx].href
|
||||
updates["lastPlayedTime_\(href)"] = 1000.0
|
||||
updates["totalTime_\(href)"] = 1000.0
|
||||
DispatchQueue.main.async {
|
||||
let userDefaults = UserDefaults.standard
|
||||
let updates = NSMutableDictionary()
|
||||
|
||||
for idx in 0..<i {
|
||||
if idx < episodeLinks.count {
|
||||
let href = episodeLinks[idx].href
|
||||
updates.setValue(1000.0, forKey: "lastPlayedTime_\(href)")
|
||||
updates.setValue(1000.0, forKey: "totalTime_\(href)")
|
||||
}
|
||||
}
|
||||
|
||||
userDefaults.setValuesForKeys(updates as! [String: Any])
|
||||
userDefaults.synchronize()
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
refreshTrigger.toggle()
|
||||
Logger.shared.log("Marked \(ep.number - 1) episodes watched within series \"\(title)\".", type: "General")
|
||||
}
|
||||
}
|
||||
|
||||
for (key, value) in updates {
|
||||
userDefaults.set(value, forKey: key)
|
||||
}
|
||||
|
||||
refreshTrigger.toggle()
|
||||
Logger.shared.log("Marked \(ep.number - 1) episodes watched within series \"\(title)\".", type: "General")
|
||||
}
|
||||
)
|
||||
.id(refreshTrigger)
|
||||
|
|
@ -454,10 +458,11 @@ struct MediaInfoView: View {
|
|||
}
|
||||
}
|
||||
|
||||
selectedRange = 0..<episodeChunkSize
|
||||
|
||||
hasFetched = true
|
||||
AnalyticsManager.shared.sendEvent(event: "search", additionalData: ["title": title])
|
||||
}
|
||||
selectedRange = 0..<episodeChunkSize
|
||||
}
|
||||
.onReceive(NotificationCenter.default.publisher(for: UIDevice.orientationDidChangeNotification)) { _ in
|
||||
orientationChanged.toggle()
|
||||
|
|
|
|||
|
|
@ -74,6 +74,27 @@ struct SettingsViewPlayer: View {
|
|||
}
|
||||
}
|
||||
|
||||
Section(header: Text("Progress bar Marker Color")) {
|
||||
ColorPicker("Segments Color", selection: Binding(
|
||||
get: {
|
||||
if let data = UserDefaults.standard.data(forKey: "segmentsColorData"),
|
||||
let uiColor = try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data) as? UIColor {
|
||||
return Color(uiColor)
|
||||
}
|
||||
return .yellow
|
||||
},
|
||||
set: { newColor in
|
||||
let uiColor = UIColor(newColor)
|
||||
if let data = try? NSKeyedArchiver.archivedData(
|
||||
withRootObject: uiColor,
|
||||
requiringSecureCoding: false
|
||||
) {
|
||||
UserDefaults.standard.set(data, forKey: "segmentsColorData")
|
||||
}
|
||||
}
|
||||
))
|
||||
}
|
||||
|
||||
Section(header: Text("Skip Settings"), footer : Text("Double tapping the screen on it's sides will skip with the short tap setting.")) {
|
||||
HStack {
|
||||
Text("Tap Skip:")
|
||||
|
|
|
|||
Loading…
Reference in a new issue