Skip to main content

A thin wrapper over yt-dlp/ejs for deciphering YT signatures. Comes with Deno out of the box.

Project description

Red-YT-Cipher-Solver

Red-YT-Cipher-Solver on PyPI License: MIT

A thin wrapper over yt-dlp/ejs for deciphering YT signatures. Aside from yt-dlp/ejs, this uses the official Deno PyPI package, meaning no additional setup is required beyond installing the package and then using it either as a library or as a Lavalink-compatible cipher server.

Using this project

This package only functions on systems supported by Deno JS runtime. At the time of writing, this includes:

  • Windows x86_64
  • macOS x86_64 & arm64
  • Linux x86_64 & aarch64 with glibc 2.27 or higher

[!NOTE] If you intend to add this as a dependency to your project and want to support other platforms as well, ensure to specify appropriate environment markers for the dependency and guard your imports appropriately as the deno dependency of this project will not install on unsupported platforms:

  • pyproject.toml
    [project]
    # [...]
    dependencies = [
        """\
        Red-YT-Cipher-Solver; \
            (sys_platform == 'win32' and platform_machine == 'AMD64') \
            or (sys_platform == 'linux' and (platform_machine == 'x86_64' or platform_machine == 'aarch64')) \
            or (sys_platform == 'darwin' and (platform_machine == 'x86_64' or platform_machine == 'arm64')) \
        """,
    ]
    
    # [...]
    
  • requirements.txt
    Red-YT-Cipher-Solver; (sys_platform == 'win32' and platform_machine == 'AMD64') or (sys_platform == 'linux' and (platform_machine == 'x86_64' or platform_machine == 'aarch64')) or (sys_platform == 'darwin' and (platform_machine == 'x86_64' or platform_machine == 'arm64'))
    # [...]
    

Installation

Install the package:

  • Linux & macOS
    python3.10 -m venv red_yt_cipher_solver
    . red_yt_cipher_solver/bin/activate
    python -m pip install -U Red-YT-Cipher-Solver
    
  • Windows
    py -3.10 -m venv red_yt_cipher_solver
    red_yt_cipher_solver\Scripts\Activate.ps1
    python -m pip install -U Red-YT-Cipher-Solver
    

Running as a server

Run the server with the default configuration (listening on http://localhost:2334 with no authentication):

red-yt-cipher-solver serve

To specify custom hostname and port, use the positional arguments:

red-yt-cipher-solver 0.0.0.0 4242

You can require the clients to send an Authorization header with a token by specifying one in the RED_YT_CIPHER_SERVER_TOKEN environment variable.

Using as a standalone solver

$ red-yt-cipher-solver solve --help
usage: red-yt-cipher-solver solve [-h] [--encrypted-signature ENCRYPTED_SIGNATURE]
                                  [--n-param N_PARAM] [--signature-key SIGNATURE_KEY]
                                  [--include-player-content]
                                  player_url stream_url

Solve a JS challenge request using the yt-dlp/ejs solver:

red-yt-cipher-solver solve \
    /s/player/00c52fa0/player_ias.vflset/de_DE/base.js \
    "https://rr4---sn-4g5e6nzl.googlevideo.com/videoplayback?expire=1772476120&n=Fc9IL2b0xD7Lybd7&ei=..." \
    --encrypted-signature "R=ANHkhNZInqwBBEsHpvykqHsygJje6J4T_Q-aL2VO7PkCQIC4ruoYYg2TeWFSfKXFTeQF=B_hR1UlnJw75Wfb24g6nQgIQRw4MNqEHA"

Using as a library

While this is mostly a thin wrapper over yt-dlp/ejs, it does come with Deno out of the box, so it might be of interest to some to use that wrapper directly.

The following functions are currently exposed in red_yt_cipher_solver

solve_js_challenges() / solve_js_challenges_sync()

Solve JS challenge requests using the yt-dlp/ejs solver.

The variant without the _sync suffix is an asynchronous function.

Arguments:

  • player_content (str) - The content of the player script.
  • *requests (JsChallengeRequest) - The JS challenge requests to solve.

Returns:
SolveOutput - The parsed output from yt-dlp/ejs solver.

Raises:

  • SolveOutputError - Some or all of the challenge requests could not be solved.
  • UnsupportedGLibCError - The glibc version used on this system is unsupported.
  • subprocess.CalledProcessError - The yt-dlp/ejs script crashed/Deno failed to run.

get_sts()

Get timestamp from the player script.

Parameters:

  • player_content (str) - The content of the player script.

Returns:
str - The timestamp extracted from the player script. When this is an empty string, the timestamp could not be found.

normalize_player_url()

Normalize the provided player URL.

This will prepend the YT URL to a path-only URL in case of relative URLs and validate the URL and its hostname in case of absolute URLs.

Parameters:

  • player_url (str) - The player URL.

Returns:
str - The normalized player URL.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

red_yt_cipher_solver-0.3.0.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

red_yt_cipher_solver-0.3.0-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file red_yt_cipher_solver-0.3.0.tar.gz.

File metadata

  • Download URL: red_yt_cipher_solver-0.3.0.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for red_yt_cipher_solver-0.3.0.tar.gz
Algorithm Hash digest
SHA256 d9f9e441a84302218cfbd3aa21df01969b73d12b6361ca6d0e19e8fd725d147a
MD5 bccd25375d23761f7eee17e013fa8ec1
BLAKE2b-256 11cd49e23469dcaa1819c561afbc6e196f917d1ca1b951594c289414d98d10ad

See more details on using hashes here.

File details

Details for the file red_yt_cipher_solver-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: red_yt_cipher_solver-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for red_yt_cipher_solver-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f08476ba5238981c8f63c0de5c2d667daf079ee1fc5cdd8889937035f12720d6
MD5 947c4110f0b2aacf3be9e8c47833b872
BLAKE2b-256 2a142e85c73917750ba3255aa57c647de81092960dc911a2d1595a3eb3aca7b2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page