Use web safari for playback (#673)
* Use web safari for playback * user agent
This commit is contained in:
1 parent
7f8cdeb351
commit
3bc25cc2d1
4 files changed
+54
-2
No files matched your search
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
|
||||||
|
- Experiment: use web safari for `/player` endpoint
|
||||||
|
|
||||||
## [0.40.9] - 2025-07-06
|
## [0.40.9] - 2025-07-06
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
const VIDEO_PLAYER_USER_AGENT = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:139.0) Gecko/20100101 Firefox/139.0"
|
' const VIDEO_PLAYER_USER_AGENT = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:139.0) Gecko/20100101 Firefox/139.0"
|
||||||
|
const VIDEO_PLAYER_USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.6 Safari/605.1.15"
|
||||||
|
|
||||||
const INNERTUBE_IOS_CLIENT_NAME = "5"
|
const INNERTUBE_IOS_CLIENT_NAME = "5"
|
||||||
const INNERTUBE_IOS_CLIENT_VERSION = "20.20.5"
|
const INNERTUBE_IOS_CLIENT_VERSION = "20.20.5"
|
||||||
@@ -6,6 +7,16 @@ const INNERTUBE_IOS_DEVICE_MODEL = "iPhone16,2"
|
|||||||
const INNERTUBE_IOS_OS_VERSION = "18.1"
|
const INNERTUBE_IOS_OS_VERSION = "18.1"
|
||||||
const INNERTUBE_IOS_USER_AGENT = "com.google.ios.youtube/20.20.5 (iPhone16,2; U; CPU iOS 18_1_0 like Mac OS X)"
|
const INNERTUBE_IOS_USER_AGENT = "com.google.ios.youtube/20.20.5 (iPhone16,2; U; CPU iOS 18_1_0 like Mac OS X)"
|
||||||
|
|
||||||
|
const INNERTUBE_WEB_SAFARI_BROWSER_NAME = "Safari"
|
||||||
|
const INNERTUBE_WEB_SAFARI_BROWSER_VERSION = "17.6"
|
||||||
|
const INNERTUBE_WEB_SAFARI_CLIENT_NAME = "1"
|
||||||
|
const INNERTUBE_WEB_SAFARI_CLIENT_VERSION = "2.20250701.09.00"
|
||||||
|
const INNERTUBE_WEB_SAFARI_DEVICE_MAKE = "Apple"
|
||||||
|
const INNERTUBE_WEB_SAFARI_DEVICE_MODEL = ""
|
||||||
|
const INNERTUBE_WEB_SAFARI_OS_NAME = "Macintosh"
|
||||||
|
const INNERTUBE_WEB_SAFARI_OS_VERSION = "10_15_7"
|
||||||
|
const INNERTUBE_WEB_SAFARI_USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.6 Safari/605.1.15"
|
||||||
|
|
||||||
const INNERTUBE_WEB_BROWSER_NAME = "Chrome"
|
const INNERTUBE_WEB_BROWSER_NAME = "Chrome"
|
||||||
const INNERTUBE_WEB_BROWSER_VERSION = "136.0.0.0"
|
const INNERTUBE_WEB_BROWSER_VERSION = "136.0.0.0"
|
||||||
const INNERTUBE_WEB_CLIENT_NAME = "1"
|
const INNERTUBE_WEB_CLIENT_NAME = "1"
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ namespace Innertube
|
|||||||
Web = "WEB"
|
Web = "WEB"
|
||||||
IOS = "IOS"
|
IOS = "IOS"
|
||||||
Tv = "TV"
|
Tv = "TV"
|
||||||
|
WebSafari = "WEB_SAFARI"
|
||||||
end enum
|
end enum
|
||||||
|
|
||||||
function CreateHeaders(clienType as Innertube.ClientType) as object
|
function CreateHeaders(clienType as Innertube.ClientType) as object
|
||||||
@@ -35,6 +36,14 @@ namespace Innertube
|
|||||||
"x-youtube-client-name": INNERTUBE_TV_CLIENT_NAME
|
"x-youtube-client-name": INNERTUBE_TV_CLIENT_NAME
|
||||||
"x-youtube-client-version": INNERTUBE_TV_CLIENT_VERSION
|
"x-youtube-client-version": INNERTUBE_TV_CLIENT_VERSION
|
||||||
}
|
}
|
||||||
|
else if clienType = ClientType.WebSafari
|
||||||
|
return {
|
||||||
|
"accept": "*/*"
|
||||||
|
"accept-language": "*"
|
||||||
|
"user-agent": INNERTUBE_WEB_SAFARI_USER_AGENT
|
||||||
|
"x-youtube-client-name": INNERTUBE_WEB_SAFARI_CLIENT_NAME
|
||||||
|
"x-youtube-client-version": INNERTUBE_WEB_SAFARI_CLIENT_VERSION
|
||||||
|
}
|
||||||
else
|
else
|
||||||
throw "Invalid client type"
|
throw "Invalid client type"
|
||||||
end if
|
end if
|
||||||
@@ -48,6 +57,8 @@ namespace Innertube
|
|||||||
client = CreateContextClientIOS(deviceInfo)
|
client = CreateContextClientIOS(deviceInfo)
|
||||||
else if clienType = ClientType.Tv
|
else if clienType = ClientType.Tv
|
||||||
client = CreateContextClientTv(deviceInfo)
|
client = CreateContextClientTv(deviceInfo)
|
||||||
|
else if clienType = ClientType.WebSafari
|
||||||
|
client = CreateContextClientWebSafari(deviceInfo)
|
||||||
else
|
else
|
||||||
throw "Invalid client type"
|
throw "Invalid client type"
|
||||||
end if
|
end if
|
||||||
@@ -177,6 +188,32 @@ namespace Innertube
|
|||||||
}
|
}
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function CreateContextClientWebSafari(deviceInfo as object) as object
|
||||||
|
return {
|
||||||
|
"hl": GetCurrentLocale(deviceInfo)
|
||||||
|
"gl": GetContentRegion(deviceInfo)
|
||||||
|
"remoteHost": ""
|
||||||
|
"screenDensityFloat": 1
|
||||||
|
"screenHeightPoints": 1440
|
||||||
|
"screenPixelDensity": 1
|
||||||
|
"screenWidthPoints": 2560
|
||||||
|
"clientName": INNERTUBE_WEB_SAFARI_CLIENT_NAME
|
||||||
|
"clientVersion": INNERTUBE_WEB_SAFARI_CLIENT_VERSION
|
||||||
|
"osName": INNERTUBE_WEB_SAFARI_OS_NAME
|
||||||
|
"osVersion": INNERTUBE_WEB_SAFARI_OS_VERSION
|
||||||
|
"platform": "DESKTOP"
|
||||||
|
"clientFormFactor": "UNKNOWN_FORM_FACTOR"
|
||||||
|
"userInterfaceTheme": "USER_INTERFACE_THEME_LIGHT"
|
||||||
|
"timeZone": deviceInfo.GetTimeZone()
|
||||||
|
"originalUrl": "https://www.youtube.com"
|
||||||
|
"deviceMake": INNERTUBE_WEB_SAFARI_DEVICE_MAKE
|
||||||
|
"deviceModel": INNERTUBE_WEB_SAFARI_DEVICE_MODEL
|
||||||
|
"browserName": INNERTUBE_WEB_SAFARI_BROWSER_NAME
|
||||||
|
"browserVersion": INNERTUBE_WEB_SAFARI_BROWSER_VERSION
|
||||||
|
"utcOffsetMinutes": -240
|
||||||
|
}
|
||||||
|
end function
|
||||||
|
|
||||||
function GetCurrentLocale(deviceInfo as object) as string
|
function GetCurrentLocale(deviceInfo as object) as string
|
||||||
currentLocale = deviceInfo.GetCurrentLocale()
|
currentLocale = deviceInfo.GetCurrentLocale()
|
||||||
' en_CA is not a valid locale for Innertube
|
' en_CA is not a valid locale for Innertube
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace InnertubeService
|
|||||||
fetchNext = OptionUtils.GetOrDefault(options, "fetchNext", true)
|
fetchNext = OptionUtils.GetOrDefault(options, "fetchNext", true)
|
||||||
raw = OptionUtils.GetOrDefault(options, "raw", false)
|
raw = OptionUtils.GetOrDefault(options, "raw", false)
|
||||||
|
|
||||||
playerRequest = Innertube.CreatePlayerRequest(videoId, Innertube.ClientType.IOS, options)
|
playerRequest = Innertube.CreatePlayerRequest(videoId, Innertube.ClientType.WebSafari, options)
|
||||||
playerRequest.Cancellation(cancellation)
|
playerRequest.Cancellation(cancellation)
|
||||||
if raw
|
if raw
|
||||||
playerRequest.LogCurlCommand()
|
playerRequest.LogCurlCommand()
|
||||||
|
|||||||
Reference in new issue
Block a user