GilbertClaus commited on
Commit
19f3a65
·
1 Parent(s): 3d3d1b5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -21
app.py CHANGED
@@ -1,7 +1,9 @@
1
  import streamlit as st
2
  from streamlit_option_menu import option_menu
3
  import streamlit as st
4
- from youtube import cut_video
 
 
5
 
6
  # Navigasi Sidebar
7
  with st.sidebar:
@@ -13,25 +15,18 @@ if selected == 'Youtube':
13
  st.write("Potong dan download sebagian video YouTube.")
14
  video_link = st.text_input("Link Video", value='https://www.youtube.com/watch?v=ZGltvcmVSAk')
15
  resolution = st.text_input("Resolusi", value='720')
16
- start_time = st.text_input("Start Time", value='00:07:12.750')
17
- end_time = st.text_input("End Time", value='00:09:31.000')
 
 
18
 
19
- if st.button("Download and Cut Video"):
20
- video_info, video_result, video_file = cut_video(video_link, resolution, start_time, end_time)
21
- st.session_state.video_info = video_info
22
- st.session_state.video_result = video_result
23
- st.session_state.video_file = video_file
 
 
 
24
 
25
- if 'video_info' in st.session_state:
26
- num_lines = st.session_state.video_info.count('\n') + 1
27
- text_area_height = 25 * num_lines
28
- st.text_area("Informasi Video", st.session_state.video_info, height=text_area_height)
29
- st.video(st.session_state.video_result)
30
- with open(st.session_state.video_file, 'rb') as f:
31
- file_contents = f.read()
32
- st.download_button(
33
- label="Download Hasil Potongan Video",
34
- data=file_contents,
35
- file_name=st.session_state.video_file.replace('/home/user/app/Hasil Potong', '').title().replace('Mp4', 'mp4'),
36
- mime='application/octet-stream'
37
- )
 
1
  import streamlit as st
2
  from streamlit_option_menu import option_menu
3
  import streamlit as st
4
+ from youtube import yt_down
5
+ from pornhub import ph_down
6
+ from other import cut_video
7
 
8
  # Navigasi Sidebar
9
  with st.sidebar:
 
15
  st.write("Potong dan download sebagian video YouTube.")
16
  video_link = st.text_input("Link Video", value='https://www.youtube.com/watch?v=ZGltvcmVSAk')
17
  resolution = st.text_input("Resolusi", value='720')
18
+ cut = st.checkbox("Potong Video")
19
+ if cut:
20
+ start_time = st.text_input("Start Time", value='00:07:12.750')
21
+ end_time = st.text_input("End Time", value='00:09:31.000')
22
 
23
+ if st.button("Download and Cut Youtube"):
24
+ filename, judul_video, video_info = yt_down(video_link, resolution)
25
+ output_file_path = cut_video(filename, start_time, end_time)
26
+ session(video_info, video_file, cut)
27
+ else:
28
+ if st.button("Download Youtube"):
29
+ video_info, video_file = yt_down(video_link, resolution, start_time, end_time)
30
+ session(video_info, video_file, cut)
31
 
32
+