OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

PyTube not downloading correct quality audio file

  • Thread starter Thread starter Liam Harvey
  • Start date Start date
L

Liam Harvey

Guest
When I first wrote this code it worked fine and would download me the 160kbps OPUS WEBM file for the URL selected but now for some reason will only download lower a quality than asked for and I can't work out why.

My code is;

Code:
from pytube import YouTube 
from sys import argv

link = argv[1]
yt = YouTube(link)

print("Title: ", yt.title)

print("Ciew:", yt.views)

print(yt.streams.filter(only_audio=True))

video = yt.streams.filter(only_audio=True).last()

print(video)

video.download(r'E:\Users\XXXX\Desktop\YTDTEST')

print("DONE")

and the terminal output is

Code:
PS E:\Users\XXX\Desktop\PyTube> python pydl2.py "https://www.youtube.com/watch?v=GaJcBJQi7bY"
Title:  Prince & The Revolution - Purple Rain (Official Video), HD (Digitally Remastered and Upscaled)
Ciew: 56547
[<Stream: itag="139" mime_type="audio/mp4" abr="48kbps" acodec="mp4a.40.5" progressive="False" type="audio">, <Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2" progressive="False" type="audio">, <Stream: itag="249" mime_type="audio/webm" abr="50kbps" acodec="opus" progressive="False" type="audio">, <Stream: itag="250" mime_type="audio/webm" abr="70kbps" acodec="opus" progressive="False" type="audio">, <Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus" progressive="False" type="audio">]
<Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus" progressive="False" type="audio">
DONE

for some reason it just downloads a 64kbps version of the audio even though as we see from the output I believe have used the right code so can't work out whats gone wrong.
<p>When I first wrote this code it worked fine and would download me the 160kbps OPUS WEBM file for the URL selected but now for some reason will only download lower a quality than asked for and I can't work out why.</p>
<p>My code is;</p>
<pre><code>from pytube import YouTube
from sys import argv

link = argv[1]
yt = YouTube(link)

print("Title: ", yt.title)

print("Ciew:", yt.views)

print(yt.streams.filter(only_audio=True))

video = yt.streams.filter(only_audio=True).last()

print(video)

video.download(r'E:\Users\XXXX\Desktop\YTDTEST')

print("DONE")
</code></pre>
<p>and the terminal output is</p>
<pre><code>PS E:\Users\XXX\Desktop\PyTube> python pydl2.py "
"
Title: Prince & The Revolution - Purple Rain (Official Video), HD (Digitally Remastered and Upscaled)
Ciew: 56547
[<Stream: itag="139" mime_type="audio/mp4" abr="48kbps" acodec="mp4a.40.5" progressive="False" type="audio">, <Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2" progressive="False" type="audio">, <Stream: itag="249" mime_type="audio/webm" abr="50kbps" acodec="opus" progressive="False" type="audio">, <Stream: itag="250" mime_type="audio/webm" abr="70kbps" acodec="opus" progressive="False" type="audio">, <Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus" progressive="False" type="audio">]
<Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus" progressive="False" type="audio">
DONE
</code></pre>
<p>for some reason it just downloads a 64kbps version of the audio even though as we see from the output I believe have used the right code so can't work out whats gone wrong.</p>
 

Latest posts

I
Replies
0
Views
1
impact christian
I
Top