Unverified Commit e6f986b1 authored by Sandro Jäckel's avatar Sandro Jäckel Committed by GitHub
Browse files

yt-dlp: fix impersonation with curl-cffi (#460076)

parents 68011bf2 d2862efc
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -32,6 +32,10 @@ python3Packages.buildPythonApplication rec {
  postPatch = ''
    substituteInPlace yt_dlp/version.py \
      --replace-fail "UPDATE_HINT = None" 'UPDATE_HINT = "Nixpkgs/NixOS likely already contain an updated version.\n       To get it run nix-channel --update or nix flake update in your config directory."'
    # Until yt-dlp supports curl-cffi 0.14.x, this patch is needed:
    substituteInPlace yt_dlp/networking/_curlcffi.py \
      --replace-fail "if curl_cffi_version != (0, 5, 10) and not (0, 10) <= curl_cffi_version < (0, 14)" \
      "if curl_cffi_version != (0, 5, 10) and not (0, 10) <= curl_cffi_version"
  '';

  build-system = with python3Packages; [ hatchling ];
@@ -94,8 +98,14 @@ python3Packages.buildPythonApplication rec {
      ''--prefix PATH : "${lib.makeBinPath packagesToBinPath}"''
    ];

  # Requires network
  doCheck = false;
  checkPhase = ''
    # Check for "unsupported" string in yt-dlp -v output.
    output=$($out/bin/yt-dlp -v 2>&1 || true)
    if echo $output | grep -q "unsupported"; then
      echo "ERROR: Found \"unsupported\" string in yt-dlp -v output."
      exit 1
    fi
  '';

  postInstall = ''
    installManPage yt-dlp.1