~ knotless Search/
↑↓ move↵ open⇧↵ all results

geesawra.industries/hydraulophone

An unofficial YouTube Music app for iPhone, iPad, and Mac.

0
0
main
91 lines · 4.5 KB Raw History

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:

  • url is percent-decoded once and must be an HTTPS media URL;
  • s must be non-empty;
  • sp defaults to sig and is restricted to a safe query-key character set;
  • n, when present in a direct or embedded URL, is passed unchanged to the solver;
  • approxDurationMs is preferred, with videoDetails.lengthSeconds as 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:

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.