JuanBindez / pytubefix

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

Unable to download videos with a question mark in the title. #171

Closed h33k closed 1 month ago

h33k commented 1 month ago

Hello. I noticed that it is impossible to download videos with a question mark ("?") in the video title. I'm not sure about others special characters.

Error OSError: [Errno 22] Invalid argument: "C:\\question mark?.mp3"

Quick fix Add filename = filename.replace('?','') in the streams.py (~314 line) before

file_path = self.get_file_path(
    filename=filename,
    output_path=output_path,
    filename_prefix=filename_prefix,
)
JuanBindez commented 1 month ago

in version 6.2.2, problematic characters were removed https://github.com/JuanBindez/pytubefix/commit/b2ac8550da2b73421bde43838b96d7cace979c29 , what we can do is add the "?" in the list this already solves the problem, in the next releases we will test this.

JuanBindez commented 1 month ago

I need you to do a test, use pip install pytubefix==6.10a3 and try the code that I will give you as an example, instead of updating the table I added a method so that the user who has problems with characters can remove the character, because not all OS will have problems with the same characters

from pytubefix import YouTube
from pytubefix.cli import on_progress

url = "url"

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

ys = yt.streams.get_audio_only()
ys.download(mp3=True, remove_problematic_chars="?")
h33k commented 1 month ago

works perfect. I use win11 btw