jitendra.kasaudhan commited on
Commit
7236f0d
·
1 Parent(s): df87c98

Can enter url and download audio file

Browse files
Files changed (3) hide show
  1. .devcontainer/devcontainer.json +22 -0
  2. app.py +49 -0
  3. requirements.txt +2 -0
.devcontainer/devcontainer.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the
2
+ // README at: https://github.com/devcontainers/templates/tree/main/src/python
3
+ {
4
+ "name": "Python 3",
5
+ // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6
+ "image": "mcr.microsoft.com/devcontainers/python:1-3.9-bookworm"
7
+
8
+ // Features to add to the dev container. More info: https://containers.dev/features.
9
+ // "features": {},
10
+
11
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
12
+ // "forwardPorts": [],
13
+
14
+ // Use 'postCreateCommand' to run commands after the container is created.
15
+ // "postCreateCommand": "pip3 install --user -r requirements.txt",
16
+
17
+ // Configure tool-specific properties.
18
+ // "customizations": {},
19
+
20
+ // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
21
+ // "remoteUser": "root"
22
+ }
app.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from pytube import YouTube
3
+ import os
4
+
5
+ def main():
6
+ # Set the title and background color
7
+ st.title("YouTube To MP3 Converter 🎥")
8
+ st.markdown('<style>h1{color: orange; text-align: center;}</style>', unsafe_allow_html=True)
9
+ # st.subheader('Built with the Llama 2 🦙, Haystack, Streamlit and ❤️')
10
+ # st.markdown('<style>h3{color: pink; text-align: center;}</style>', unsafe_allow_html=True)
11
+
12
+ # Expander for app details
13
+ with st.expander("About the App"):
14
+ st.write("This app allows you to download MP3 audio from YouTube video url.")
15
+ st.write("Enter a YouTube URL in the input box below and click on 'Submit'")
16
+
17
+ # Input box for YouTube URL
18
+ youtube_url = st.text_input("Enter YouTube URL")
19
+
20
+ # Submit button
21
+ if st.button("Submit") and youtube_url:
22
+ yt = YouTube(youtube_url)
23
+ # extract only audio
24
+ video = yt.streams.filter(only_audio=True).first()
25
+
26
+ # download the file
27
+ destination = '.' # current folder
28
+ out_file = video.download(output_path=destination)
29
+
30
+ # save the file
31
+ base, ext = os.path.splitext(out_file)
32
+ new_file = base[0:10] + '.mp3'
33
+ os.rename(out_file, new_file)
34
+
35
+ # Display layout with 2 columns
36
+ col1, col2 = st.columns([1,1])
37
+
38
+ # Column 1: Video view
39
+ with col1:
40
+ st.video(youtube_url)
41
+
42
+ # Column 2: Audio file name view
43
+ with col2:
44
+ st.header("Audio file in MP3 format")
45
+ st.write(new_file)
46
+ st.success('Successfull!!')
47
+
48
+ if __name__ == "__main__":
49
+ main()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ streamlit
2
+ pytube