Spaces:
Paused
Paused
| import streamlit as st | |
| from streamlit_option_menu import option_menu | |
| import streamlit as st | |
| from youtube import cut_video | |
| # Navigasi Sidebar | |
| with st.sidebar: | |
| selected = option_menu("Video Downloader", ['Youtube', 'Pornhub', 'Iwara', 'Mega', 'Rule34', 'Trailer'], | |
| icons=['play', 'fire', 'star', 'star', 'moon','gear', 'lightning'], menu_icon="cast", default_index=0) | |
| if selected == 'Youtube': | |
| st.title("YouTube Video Cutter") | |
| st.write("Potong dan download sebagian video YouTube.") | |
| video_link = st.text_input("Link Video", value='https://www.youtube.com/watch?v=ZGltvcmVSAk') | |
| resolution = st.text_input("Resolusi", value='720') | |
| start_time = st.text_input("Start Time", value='00:07:12.750') | |
| end_time = st.text_input("End Time", value='00:09:31.000') | |
| if st.button("Download and Cut Video"): | |
| video_info, video_result, video_file = cut_video(video_link, resolution, start_time, end_time) | |
| st.session_state.video_info = video_info | |
| st.session_state.video_result = video_result | |
| st.session_state.video_file = video_file | |
| if 'video_info' in st.session_state: | |
| num_lines = st.session_state.video_info.count('\n') + 1 | |
| text_area_height = 25 * num_lines | |
| st.text_area("Informasi Video", st.session_state.video_info, height=text_area_height) | |
| st.video(st.session_state.video_result) | |
| with open(st.session_state.video_file, 'rb') as f: | |
| file_contents = f.read() | |
| st.download_button( | |
| label="Download Hasil Potongan Video", | |
| data=file_contents, | |
| file_name=st.session_state.video_file.replace('/home/user/app/Hasil Potong', '').title().replace('Mp4', 'mp4'), | |
| mime='application/octet-stream' | |
| ) | |