From daa8a4d7ead4785823ff96a156038c648ca1e086 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 18 Jan 2021 18:50:19 +0000 Subject: patches/youtube-dl: fix YouTube quality choice An improved version of https://github.com/ytdl-org/youtube-dl/issues/14143#issuecomment-327678662 Reported-by: V Co-authored-by: V --- overlays/patches/default.nix | 2 ++ overlays/patches/youtube-dl/default.nix | 8 ++++++++ overlays/patches/youtube-dl/fix-youtube-bitrate.diff | 15 +++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 overlays/patches/youtube-dl/default.nix create mode 100644 overlays/patches/youtube-dl/fix-youtube-bitrate.diff (limited to 'overlays/patches') diff --git a/overlays/patches/default.nix b/overlays/patches/default.nix index 1aff7e80948a..1fd87159ee17 100644 --- a/overlays/patches/default.nix +++ b/overlays/patches/default.nix @@ -34,4 +34,6 @@ self: super: { }; tmux = self.callPackage ./tmux { inherit (super) tmux; }; + + youtube-dl = self.callPackage ./youtube-dl { inherit (super) youtube-dl; }; } diff --git a/overlays/patches/youtube-dl/default.nix b/overlays/patches/youtube-dl/default.nix new file mode 100644 index 000000000000..c2014726b623 --- /dev/null +++ b/overlays/patches/youtube-dl/default.nix @@ -0,0 +1,8 @@ +{ youtube-dl, ... } @ args: + +(youtube-dl.override (builtins.removeAttrs args [ "youtube-dl" ])).overrideAttrs ( + { patches ? [], ... }: + { + patches = patches ++ [ ./fix-youtube-bitrate.diff ]; + } +) diff --git a/overlays/patches/youtube-dl/fix-youtube-bitrate.diff b/overlays/patches/youtube-dl/fix-youtube-bitrate.diff new file mode 100644 index 000000000000..b633d6410160 --- /dev/null +++ b/overlays/patches/youtube-dl/fix-youtube-bitrate.diff @@ -0,0 +1,15 @@ +--- a/youtube_dl/extractor/common.py ++++ b/youtube_dl/extractor/common.py +@@ -1367,10 +1367,8 @@ + raise ExtractorError('No video formats found') + + for f in formats: +- # Automatically determine tbr when missing based on abr and vbr (improves +- # formats sorting in some cases) +- if 'tbr' not in f and f.get('abr') is not None and f.get('vbr') is not None: +- f['tbr'] = f['abr'] + f['vbr'] ++ if f.get('vcodec') != 'none': ++ f['tbr'] = None + + def _formats_key(f): + # TODO remove the following workaround -- cgit 1.4.1