about summary refs log tree commit diff
path: root/overlays/patches
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-01-18 18:50:19 +0000
committerAlyssa Ross <hi@alyssa.is>2021-01-18 18:50:19 +0000
commitdaa8a4d7ead4785823ff96a156038c648ca1e086 (patch)
tree682c2fbc9d1fa06645dd71d14799bf413dda527d /overlays/patches
parent480e1a43ae2bdc0b5ee2c8832be5531dd2aa56c1 (diff)
downloadnixlib-daa8a4d7ead4785823ff96a156038c648ca1e086.tar
nixlib-daa8a4d7ead4785823ff96a156038c648ca1e086.tar.gz
nixlib-daa8a4d7ead4785823ff96a156038c648ca1e086.tar.bz2
nixlib-daa8a4d7ead4785823ff96a156038c648ca1e086.tar.lz
nixlib-daa8a4d7ead4785823ff96a156038c648ca1e086.tar.xz
nixlib-daa8a4d7ead4785823ff96a156038c648ca1e086.tar.zst
nixlib-daa8a4d7ead4785823ff96a156038c648ca1e086.zip
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 <v@anomalous.eu>
Co-authored-by: V <v@anomalous.eu>
Diffstat (limited to 'overlays/patches')
-rw-r--r--overlays/patches/default.nix2
-rw-r--r--overlays/patches/youtube-dl/default.nix8
-rw-r--r--overlays/patches/youtube-dl/fix-youtube-bitrate.diff15
3 files changed, 25 insertions, 0 deletions
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