Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alisaesage/88625f41f4e77e70a74a3896d0304b1e to your computer and use it in GitHub Desktop.
Save alisaesage/88625f41f4e77e70a74a3896d0304b1e to your computer and use it in GitHub Desktop.
KeyError_QV
How to hotpatch "KeyError: 'QV'" on YT
1. The patch just landed 50 minutes ago here: https://github.com/ytdl-org/youtube-dl/commit/ae8ba2c31977b68b75221f80c488c0b12385269c
2. Packaged release of youtube-dl is not updated yet, and it is not known when it will be. Meaning that you can't update it via package manager or official website
3. Official instruction to patch is quite complicated: https://github.com/ytdl-org/youtube-dl/issues/31530#issuecomment-1435975611
Therefore we will manually cherry-pick the patch...
4. Find this file: extractor/youtube.py (mine was in /opt due to homebrew installation)
5. Back it up
6. Open it in the editor
7. Locate the line "jsi = JSInterpreter(jscode)" and comment it out
8. Insert these two lines underneath:
ah = 'var AH={LR:function(a,b){var c=a[0];a[0]=a[b%a.length];a[b%a.length]=c},QV:function(a){a.reverse()},pO:function(a,b){a.splice(0,b)}};'
jsi = JSInterpreter(ah + jscode)
Note: ^ these must be spaces, not tabs - aligned with the rest of the code
9. Save
10. Done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment