Add User-Agent to request

We generate a User-Agent for the platform we are running on and add it to the URLTester requests and also to MPV and AVPlayer
This commit is contained in:
Toni Förster
2024-05-19 13:37:50 +02:00
parent 90777d91f6
commit 2e9cceafa5
7 changed files with 46 additions and 3 deletions

View File

@@ -232,7 +232,10 @@ final class AVPlayerBackend: PlayerBackend {
upgrading: Bool = false
) {
asset?.cancelLoading()
asset = AVURLAsset(url: url)
asset = AVURLAsset(
url: url,
options: ["AVURLAssetHTTPHeaderFieldsKey": ["User-Agent": "\(UserAgentManager.shared.userAgent)"]]
)
asset?.loadValuesAsynchronously(forKeys: Self.assetKeysToLoad) { [weak self] in
var error: NSError?
switch self?.asset?.statusOfValue(forKey: "duration", error: &error) {

View File

@@ -68,6 +68,7 @@ final class MPVClient: ObservableObject {
checkError(mpv_set_option_string(mpv, "vo", "libmpv"))
checkError(mpv_set_option_string(mpv, "demuxer-lavf-analyzeduration", "1"))
checkError(mpv_set_option_string(mpv, "deinterlace", Defaults[.mpvDeinterlace] ? "yes" : "no"))
checkError(mpv_set_option_string(mpv, "user-agent", UserAgentManager.shared.userAgent))
checkError(mpv_initialize(mpv))