mirror of
https://github.com/cranci1/Sora.git
synced 2026-04-21 16:42:01 +00:00
added header bypass for most providers idk
Some checks are pending
Build and Release IPA / Build IPA (push) Waiting to run
Some checks are pending
Build and Release IPA / Build IPA (push) Waiting to run
This commit is contained in:
parent
36b818835b
commit
6f9a9c1a0a
4 changed files with 36 additions and 6 deletions
Binary file not shown.
|
|
@ -34,16 +34,26 @@ struct CustomMediaPlayer: View {
|
||||||
@State private var timeObserverToken: Any?
|
@State private var timeObserverToken: Any?
|
||||||
@Environment(\.presentationMode) var presentationMode
|
@Environment(\.presentationMode) var presentationMode
|
||||||
|
|
||||||
|
let module: ModuleStruct
|
||||||
let fullUrl: String
|
let fullUrl: String
|
||||||
let title: String
|
let title: String
|
||||||
let episodeNumber: Int
|
let episodeNumber: Int
|
||||||
let onWatchNext: () -> Void
|
let onWatchNext: () -> Void
|
||||||
|
|
||||||
init(urlString: String, fullUrl: String, title: String, episodeNumber: Int, onWatchNext: @escaping () -> Void) {
|
init(module: ModuleStruct, urlString: String, fullUrl: String, title: String, episodeNumber: Int, onWatchNext: @escaping () -> Void) {
|
||||||
guard let url = URL(string: urlString) else {
|
guard let url = URL(string: urlString) else {
|
||||||
fatalError("Invalid URL string")
|
fatalError("Invalid URL string")
|
||||||
}
|
}
|
||||||
_player = State(initialValue: AVPlayer(url: url))
|
|
||||||
|
var request = URLRequest(url: url)
|
||||||
|
if urlString.contains("ascdn") {
|
||||||
|
request.addValue("\(module.module[0].details.baseURL)", forHTTPHeaderField: "Referer")
|
||||||
|
}
|
||||||
|
|
||||||
|
let asset = AVURLAsset(url: url, options: ["AVURLAssetHTTPHeaderFieldsKey": request.allHTTPHeaderFields ?? [:]])
|
||||||
|
_player = State(initialValue: AVPlayer(playerItem: AVPlayerItem(asset: asset)))
|
||||||
|
|
||||||
|
self.module = module
|
||||||
self.fullUrl = fullUrl
|
self.fullUrl = fullUrl
|
||||||
self.title = title
|
self.title = title
|
||||||
self.episodeNumber = episodeNumber
|
self.episodeNumber = episodeNumber
|
||||||
|
|
@ -132,7 +142,7 @@ struct CustomMediaPlayer: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Spacer()
|
Spacer()
|
||||||
if duration - currentTime <= duration * 0.07 {
|
if duration - currentTime <= duration * 0.07 && currentTime != 0 {
|
||||||
Button(action: {
|
Button(action: {
|
||||||
player.pause()
|
player.pause()
|
||||||
presentationMode.wrappedValue.dismiss()
|
presentationMode.wrappedValue.dismiss()
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,23 @@ import UIKit
|
||||||
import AVKit
|
import AVKit
|
||||||
|
|
||||||
class VideoPlayerViewController: UIViewController {
|
class VideoPlayerViewController: UIViewController {
|
||||||
|
let module: ModuleStruct
|
||||||
|
|
||||||
var player: AVPlayer?
|
var player: AVPlayer?
|
||||||
var playerViewController: AVPlayerViewController?
|
var playerViewController: AVPlayerViewController?
|
||||||
var timeObserverToken: Any?
|
var timeObserverToken: Any?
|
||||||
var streamUrl: String?
|
var streamUrl: String?
|
||||||
var fullUrl: String = ""
|
var fullUrl: String = ""
|
||||||
|
|
||||||
|
init(module: ModuleStruct) {
|
||||||
|
self.module = module
|
||||||
|
super.init(nibName: nil, bundle: nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
required init?(coder: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
|
|
@ -22,7 +33,15 @@ class VideoPlayerViewController: UIViewController {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
player = AVPlayer(url: url)
|
var request = URLRequest(url: url)
|
||||||
|
if streamUrl.contains("ascdn") {
|
||||||
|
request.addValue("\(module.module[0].details.baseURL)", forHTTPHeaderField: "Referer")
|
||||||
|
}
|
||||||
|
|
||||||
|
let asset = AVURLAsset(url: url, options: ["AVURLAssetHTTPHeaderFieldsKey": request.allHTTPHeaderFields ?? [:]])
|
||||||
|
let playerItem = AVPlayerItem(asset: asset)
|
||||||
|
|
||||||
|
player = AVPlayer(playerItem: playerItem)
|
||||||
playerViewController = NormalPlayer()
|
playerViewController = NormalPlayer()
|
||||||
playerViewController?.player = player
|
playerViewController?.player = player
|
||||||
addPeriodicTimeObserver(fullURL: fullUrl)
|
addPeriodicTimeObserver(fullURL: fullUrl)
|
||||||
|
|
|
||||||
|
|
@ -190,6 +190,7 @@ struct AnimeInfoView: View {
|
||||||
} else if externalPlayer == "Custom" {
|
} else if externalPlayer == "Custom" {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
let customMediaPlayer = CustomMediaPlayer(
|
let customMediaPlayer = CustomMediaPlayer(
|
||||||
|
module: module,
|
||||||
urlString: streamUrl,
|
urlString: streamUrl,
|
||||||
fullUrl: fullURL,
|
fullUrl: fullURL,
|
||||||
title: anime.name,
|
title: anime.name,
|
||||||
|
|
@ -211,7 +212,7 @@ struct AnimeInfoView: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
let videoPlayerViewController = VideoPlayerViewController()
|
let videoPlayerViewController = VideoPlayerViewController(module: module)
|
||||||
videoPlayerViewController.streamUrl = streamUrl
|
videoPlayerViewController.streamUrl = streamUrl
|
||||||
videoPlayerViewController.fullUrl = fullURL
|
videoPlayerViewController.fullUrl = fullURL
|
||||||
videoPlayerViewController.modalPresentationStyle = .fullScreen
|
videoPlayerViewController.modalPresentationStyle = .fullScreen
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue