JuanBindez / pytubefix

Python3 library for downloading YouTube Videos.
http://pytubefix.rtfd.io/
MIT License
537 stars 77 forks source link

Unsupported operand type in 6.4.2 #123

Closed BrololoCoding closed 2 months ago

BrololoCoding commented 2 months ago

Got this message when I tried running:


from pytubefix import YouTube from pytubefix.cli import on_progress

url = "(My video youtube link)"

yt = YouTube(url, on_progress_callback = on_progress) print(yt.title)

ys = yt.streams.get_highest_resolution() ys.download()


Logs:


Traceback (most recent call last): File "d:\tiktokvideos\automaticCode\downloadYoutubeVideo.py", line 27, in from pytubefix import YouTube File "C:\Users\me\Miniconda3\envs\tiktokBot\lib\site-packages\pytubefix__init.py", line 18, in from pytubefix.main import YouTube File "C:\Users\me\Miniconda3\envs\tiktokBot\lib\site-packages\pytubefix\main.py", line 48, in class YouTube: File "C:\Users\me\Miniconda3\envs\tiktokBot\lib\site-packages\pytubefix\main__.py", line 60, in YouTube token_file: str | None = None, TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'


FYI: Lines are hecked up because I have commented stuff before, error comes from line one "from pytubefix import YouTube" I use miniconda as you could see and I tried with both python 3.10 & 3.9 both didn't worked. It worked when I reversed to the version before 6.3.4 so might only come from the last update.

Have a nice one and sorry if it's a dumb error that I'm the only one to have.

JuanBindez commented 2 months ago

Thanks for reporting, it's an error related to the Python version below version 3.10, this error is on line 60 token_file: str | None = None , I'll fix it for token_file: Optional[str] = None,

JuanBindez commented 2 months ago

I ask you to test this version: pip install pytubefix==6.5a1

https://github.com/JuanBindez/pytubefix/commit/18a4dee8e958d41e05fb7c618d194acc5e75c1cf

glenn-jocher commented 2 months ago

Same error in today's Ultralytics CI in https://github.com/ultralytics/ultralytics/actions/runs/10024104632/job/27705778393.

I would recommend implementing Python version testing for all current versions (3.8 - 3.12) before pushing new releases to production, as even though some newer versions of Python support fancy features these are not supported by the older versions. https://devguide.python.org/versions/

glenn-jocher commented 2 months ago

@JuanBindez also when you spot a problem in a published release you should go to pypi.org and "yank" it as it's called to prevent people from installing it:

Screenshot 2024-07-21 at 13 38 43
JuanBindez commented 2 months ago

Hi, I'll keep it like this for now, I advise everyone to always use the latest updates,

JuanBindez commented 2 months ago

Hello, I made this tool to check the scripts for compatibility, anyone who wants to use it or contribute to improving it, I will leave the link https://pypi.org/project/pycompatibility/