From 6be823dd77ecd67bc335c272b6892bb5d7e24d7b Mon Sep 17 00:00:00 2001 From: Mauricio Collares Date: Sat, 11 Jun 2022 17:41:36 +0200 Subject: [PATCH] youtube-dl: fallback to throttled downloads instead of aborting --- pkgs/tools/misc/youtube-dl/default.nix | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/pkgs/tools/misc/youtube-dl/default.nix b/pkgs/tools/misc/youtube-dl/default.nix index faf4b558ad64..4d907094653b 100644 --- a/pkgs/tools/misc/youtube-dl/default.nix +++ b/pkgs/tools/misc/youtube-dl/default.nix @@ -25,8 +25,8 @@ buildPythonPackage rec { }; patches = [ - # Fixes throttling on youtube.com. Without the patch downloads are capped at - # about 80KiB/s. See, e.g., + # Fixes throttling on youtube.com by decoding a "n-parameter". Without the patch + # downloads are capped at about 80KiB/s. See, e.g., # # https://github.com/ytdl-org/youtube-dl/issues/29326 # @@ -37,6 +37,20 @@ buildPythonPackage rec { url = "https://github.com/ytdl-org/youtube-dl/compare/57044eacebc6f2f3cd83c345e1b6e659a22e4773...1e677567cd083d43f55daef0cc74e5fa24575ae3.diff"; sha256 = "11s0j3w60r75xx20p0x2j3yc4d3yvz99r0572si8b5qd93lqs4pr"; }) + # The above patch may fail to decode the n-parameter (if, say, YouTube is updated). Failure to decode + # it blocks the download instead of falling back to the throttled version. The patch below implements + # better fallback behaviour. + (fetchpatch { + name = "avoid-crashing-if-nsig-decode-fails.patch"; + url = "https://github.com/ytdl-org/youtube-dl/commit/41f0043983c831b7c0c3614340d2f66ec153087b.diff"; + sha256 = "sha256-a72gWhBXCLjuBBD36PpZ5F/AHBdiBv4W8Wf9g4P/aBY="; + }) + # YouTube changed the n-parameter format in April 2022, so decoder updates are required. + (fetchpatch { + name = "fix-n-descrambling.patch"; + url = "https://github.com/ytdl-org/youtube-dl/commit/a0068bd6bec16008bda7a39caecccbf84881c603.diff"; + sha256 = "sha256-tSuEns4jputa2nOOo6JsFXpK3hvJ/+z1/ymcLsd3A6w="; + }) ]; nativeBuildInputs = [ installShellFiles makeWrapper ];