geesawra.industries/hydraulophone
An unofficial YouTube Music app for iPhone, iPad, and Mac.
Ciphered AAC stream resolution
Boundary
Hydraulophone keeps InnerTube request construction, session credentials, profile
headers, and media probing in InnerTubeClient. A local implementation of
PlayerStreamCipher is an optional Core dependency:
public protocol PlayerStreamCipher: Sendable {
func decipher(_ request: PlayerStreamCipherRequest) async throws -> URL
}
PlayerStreamCipherRequest contains an ephemeral media base URL, an optional
s signature, its sp parameter (defaulting to sig), the optional n query
value, and player JavaScript source. A nil signature is used for a direct AAC
URL that only needs the n transformation. The solver returns only an
ephemeral URL. It does not own URLSession, cookies, authorization, profile
selection, media probing, or persistence. Cancellation is propagated; a
decipher, script discovery, or probe failure is bounded to the current profile
and does not retry the same URL indefinitely.
The default service has no cipher capability (nil), preserving the existing
direct-AAC-only behavior and compatibility with fake services. When a real
local solver is injected, WEB_REMIX is attempted before the existing finite
profile order. This is an intentional capability policy based on current
evidence: the working iOS response can expose a URL that succeeds at byte zero
but fails later ranged access, while authenticated WEB_REMIX exposes ciphered
AAC and no HLS manifest. If WEB_REMIX deciphering or probing fails, the normal
bounded profile fallback remains available.
Parsing and validation
ResponseParser.audioCandidates(from:) accepts native audio/mp4/mp4a
formats with either a direct URL or a signatureCipher/cipher value. Cipher
query fields are decoded as protocol data:
urlis percent-decoded once and must be an HTTPS media URL;smust be non-empty;spdefaults tosigand is restricted to a safe query-key character set;n, when present in a direct or embedded URL, is passed unchanged to the solver;approxDurationMsis preferred, withvideoDetails.lengthSecondsas the fallback.
The service validates the solver's returned URL again with
InnerTubeMediaURLPolicy before probing. URLs with non-HTTPS schemes, ports,
embedded user/password credentials, lookalike hosts, or non-media paths are
discarded. Raw media URLs, cipher values, player JavaScript, and complete
player responses are not logged or persisted.
Player JavaScript discovery
InnerTubeClient.fetchPlayerJavaScript(from:videoID:profile:) first uses a
validated assets.js/player-script URL in the player response. If absent or
stale, it performs a bounded credential-free watch-page discovery request. It
only accepts HTTPS youtube.com, www.youtube.com, or music.youtube.com
player-script paths (/s/player/ or /yts/jsbin/), limits response sizes, and
sets httpShouldHandleCookies to false without Cookie or Authorization
headers. Redirects and final URLs are validated before script source is
returned. No remote extraction service is used.
Normal audio playback intentionally does not send a signature timestamp. In the
pinned AuraMusic reference, the timestamp helper is used by the video
getVideoStreamUrl path, not by the normal audio player-response requests.
Any future WEB_REMIX timestamp alignment should therefore be treated as a
bounded Hydraulophone experiment, not as established AuraMusic audio parity.
Provenance and update risk
The deciphering implementation is a narrow local adaptation of the approved YouTubeKit 0.4.9 source:
- source: https://github.com/alexeichhorn/YouTubeKit/tree/e5b7d0396ce12bf3444f0d209e8436c83373b7af
- approved scope: JavaScriptCore signature and
ntransformations only; Hydraulophone does not replace its InnerTube transport or authentication. - related notices that apply to adapted solver code: YouTubeKit MIT, Meriyah ISC, Astring MIT, and yt-dlp/ejs Unlicense.
The finite profile order and media fallback policy remain based on the
clean-room Hydraulophone adapter documented from AuraMusic commit
185a77d31733047de06cbec619d40731755a0ec1:
https://github.com/TeamAuraMusic/AuraMusic/tree/185a77d31733047de06cbec619d40731755a0ec1.
This protocol depends on undocumented player JavaScript and may break when YouTube changes function names, obfuscation, or player-script paths. Keep solver fixtures offline and sanitized; update the pinned source/provenance note and the deciphering tests together when the player script shape changes. This feature does not provide a PO-token provider, so responses requiring a provider remain unavailable.