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

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.2.0.tar.gz (12.7 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.2.0-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: red_yt_cipher_solver-0.2.0.tar.gz
  • Upload date:
  • Size: 12.7 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.2.0.tar.gz
Algorithm Hash digest
SHA256 ad12c4e19e4f27257cd6a9fd685341ad2cf68cb7f5cc845094ddb04038b4bb1a
MD5 583232867fcd98bc1d1573d6d09369ea
BLAKE2b-256 9556d764230056a983991c5f3d52430dc3916f806836516ed26b95edcb0a81f1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: red_yt_cipher_solver-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.6 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 298149338533d35c8202bad5f8eb59dba58321ce4b8658eb2d5b3e19b141d388
MD5 bcf2ebc2682c4499bb167cd636b2867e
BLAKE2b-256 b31317edb991ed1c2aff1cd60581fc5daf862b4a87214739bf815ce6fe57da2b

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