C:\Users\pooti\Desktop\python_projects\Game Utilities\MC\YouTubeVideoToMusicDisc\DiscDownloader.py
The current version of pytube (15.0.0) is broken due to YT chaning their JS code, breaking the regex parsing. Here are the steps to fix the library:
Answer gotten from issue on the pytube github: pytube/pytube#1954 (comment)
- Make sure you've the newest version of pytube,
pip install --upgrade pytube
- Open
cmd
- Type
pip show pip
- Find the
Location
field yourcmd
prints out - Copy the
Location
path
. - Press
Win+R
- Paste your copied location into the
Win+R
prompt - Find
pytube
within your installed packages (either by looking it up in the search bar, or just type it whilst in folder view to get the quick result - Open the
pytube
folder - Find
cipher.py
(by the same steps as 7) - Open
cipher.py
- Go to line
264-274
- Replace that code with this:
function_patterns = [
# https://github.com/ytdl-org/youtube-dl/issues/29326#issuecomment-865985377
# https://github.com/yt-dlp/yt-dlp/commit/48416bc4a8f1d5ff07d5977659cb8ece7640dcd8
# var Bpa = [iha];
# ...
# a.C && (b = a.get("n")) && (b = Bpa[0](b), a.set("n", b),
# Bpa.length || iha("")) }};
# In the above case, `iha` is the relevant function name
r'a\.[a-zA-Z]\s*&&\s*\([a-z]\s*=\s*a\.get\("n"\)\)\s*&&.*?\|\|\s*([a-z]+)',
r'\([a-z]\s*=\s*([a-zA-Z0-9$]+)(\[\d+\])?\([a-z]\)',
r'\([a-z]\s*=\s*([a-zA-Z0-9$]+)(\[\d+\])\([a-z]\)',
]