-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
54 lines (48 loc) · 1.91 KB
/
app.py
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import streamlit as st
import Youtube_functions as yf
from validators.url import url
import os
import Download_path as dp
st.title('Youtube Video and Audio Downloader!')
st.sidebar.title('You want Audio or Video:')
a_or_v=st.sidebar.radio("Select: ",("Audio","Video"))
link=st.text_input('Enter the URL of Youtube Video: ')
st.button('Check validity')
valid=url(link)
if valid and link:
title=yf.get_title(link)
streams=yf.get_streams(link)
res ={}
if a_or_v=='Video':
for i in streams:
res[i.resolution]=i.itag
# print(type(res.values()))
tag = st.selectbox("Select Resolution",list(res.keys()))
if tag!=None:
# path=st.text_input('Where do you want to download the video? Enter Path: ')
home=st.text_input("Enter Name of home folder: ")
if home:
path=st.radio("Select",dp.download_paths(home))
path=os.path.join(dp.get_home_path(home),path)
if path:
if st.button('Download video'):
yf.download_video(link=link,vid_path=path,tag=res[tag])
st.balloons()
st.success('VIDEO DOWNLOAD COMPLETE!')
else:
st.warning('Please Choose a Valid Path')
else:
# path=st.text_input('Where do you want to download the audio? Enter Path: ')
home=st.text_input("Enter Name of home folder: ")
if home:
path=st.radio("Select",dp.download_paths(home))
path=os.path.join(dp.get_home_path(home),path)
if path:
if st.button('Download Audio'):
yf.audio_from_video(link=link,aud_path=path)
st.balloons()
st.success('AUDIO DOWNLOAD COMPLETE!')
else:
st.warning('Please Choose a Valid Path')
else:
st.warning("Please enter valid link")