JuanBindez / pytubefix

Python3 library for downloading YouTube Videos.
https://pytubefix.readthedocs.io
MIT License
729 stars 101 forks source link

There is just one option to download video with audio/its quality is bad (not confident whether it is bug or it is expected response) #257

Closed markokovalua closed 1 month ago

markokovalua commented 1 month ago

:exclamation: DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE :exclamation:

There is just one option to download video with audio (not confident whether it is bug or it is expected response).


Describe the bug

Hello, I have tried to download youtube video via pytubefix and got just one option to download video with audio. The resolution of the video is bad. Could you please help whether it is possible to download video with audio and with good resolution, thanks in advance.


code that was used that resulted in the bug


from pytubefix import YouTube
from pytubefix.cli import on_progress

url = "https://www.youtube.com/watch?v=MBMz-eIU04M"

yt = YouTube(url, on_progress_callback=on_progress)
ys = yt.streams.get_highest_resolution()
ys.download()

# put your code here

Expected behavior

video with audio but bad quality

https://drive.google.com/file/d/1k0b_q9fOiK2ESW-G3qWST3xuQrc0oFxY/view?usp=sharing

video without audio but good quality

https://drive.google.com/file/d/1zgjoai47uvdNX4QkqoNRBscGSuksmqFL/view?usp=sharing

would like to download a video with good quality and with audio


Screenshots If applicable, add screenshots to help explain your problem.

`-> ys.download() (Pdb) ys

` ``` (Pdb) yt.streams [, , , , , , , , , , , , , , , , , ] ``` ` (Pdb) yt.streams.filter(progressive=True) [] ` ![Screenshot 2024-10-01 at 18 18 24](https://github.com/user-attachments/assets/cd8928ae-487e-4b44-be2a-72c9d7fd848a) __________ **Desktop (please complete the following information):** - OS: Macos Montarey - Python Version Python 3.11.3 - Pytubefix Version pytubefix==7.1.3 __________ **Additional context** Add any other context about the problem here.
fedetony commented 1 month ago

Its because the youtube accepts progressive (video and audio together) and adaptive( video and audio separated) formats. You can download them both and join them together. In the combination you want. You can see the code for doing that here: class_pytubefix_use, you can use the class in your own code, or use mine. I made this GUI that interacts with pytubefix for me to fast download all the stuff and avoid the advertisement, in it you can click in the resolution and select any resolution you want. 2024-10-02 00_26_32-Gui for pytubefix by FG V1 0 0 Beta

It is a work in progress, and needs some documentation, but is somehow working.

jhanley-com commented 1 month ago

Not a bug.

Your code is downloading the Progressive stream. For your URL that is 360p.

Suggestion. Learn about audio and video streams and how to work with them.