-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
25 lines (21 loc) · 671 Bytes
/
test.py
File metadata and controls
25 lines (21 loc) · 671 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from pytube import YouTube
def descargayoutube(url, type:"audio"or"video"="audio"):
song = YouTube(url)
try:
if type == "audio":
streams = song.streams.filter(type=type, audio_codec='opus').order_by('abr').last()
if type== "video":
streams = song.streams.filter(type=type, video_codec='vp9').last()
except:
streams = song.streams.filter(type=type).order_by('abr').last()
finally:
print(streams)
file = streams.download()
print( streams
)
file_title = song.title
file_author = song.author
print(file)
print(song)
return file_title, file
descargayoutube("https://www.youtube.com/watch?v=F4neLJQC1_E", "video")