salomonsky commited on
Commit
b0877f0
·
1 Parent(s): 31ed2a8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -34
app.py CHANGED
@@ -5,51 +5,43 @@ from youtube import youtube, download_youtube
5
  from others import *
6
 
7
  # Navigasi Sidebar
8
- options = ['Youtube']
9
  with st.sidebar:
10
- selected = option_menu("Video Downloader", options,
11
  icons=['play'], menu_icon="cast", default_index=0)
12
 
13
- functions = [youtube]
14
 
15
- if selected:
16
- index = options.index(selected)
17
- fungsi = functions[index]
18
- st.title(f"{selected} Video Downloader and Cutter")
19
- st.write(f"Download and cut a portion of the {selected} video.")
20
- video_link = st.text_input("Video Link", value='https://www.youtube.com/watch?v=ZGltvcmVSAk')
21
- resolution = st.selectbox("Select Resolution", (360, 480, 720), 2)
22
 
23
- choice = st.radio('Select Process:', ['Cut Video', 'Compress Video', 'Just Download'], 2)
24
-
25
- start_time = st.text_input("Start Time", value='00:07:12.000')
26
- end_time = st.text_input("End Time", value='00:07:31.000')
27
-
28
- # Display video preview when the button is clicked
29
- if st.button(f"Download and Cut {selected}"):
30
- video_file, judul_video, video_info, thumbnail_file = fungsi(video_link, resolution)
31
- st.video(video_link)
32
 
33
- # Button to download the cutted part
34
- if st.button("Download Cutted"):
35
- video_file = cut_video(video_file, judul_video, start_time, end_time)
 
36
  file_size = os.path.getsize(video_file)
37
- session(video_info, video_file, thumbnail_file, choice)
38
- st.text_input(f"Video '{judul_video}' after processing:", convert_size(file_size))
39
 
40
- elif choice == 'Compress Video':
41
- compress = st.selectbox("Select Compression Resolution", (360, 480, 720), 2)
42
-
43
- if st.button(f"Download and Compress {selected}"):
44
- video_file, judul_video, video_info, thumbnail_file = fungsi(video_link, resolution)
45
  video_file = convert_videos(compress, video_file)
46
  file_size = os.path.getsize(video_file)
47
  session(video_info, video_file, thumbnail_file, choice)
48
- st.text_input(f"Video '{judul_video}' after processing:", convert_size(file_size))
49
 
50
- else:
51
- if st.button(f"Download {selected}"):
52
- video_file, judul_video, video_info, thumbnail_file = fungsi(video_link, resolution)
53
  file_size = os.path.getsize(video_file)
54
  session(video_info, video_file, thumbnail_file, choice)
55
- st.text_input(f"Video '{judul_video}' after processing:", convert_size(file_size))
 
5
  from others import *
6
 
7
  # Navigasi Sidebar
8
+ opciones = ['YouTube']
9
  with st.sidebar:
10
+ seleccionado = option_menu("Descargador de Videos", opciones,
11
  icons=['play'], menu_icon="cast", default_index=0)
12
 
13
+ funciones = [youtube]
14
 
15
+ if seleccionado:
16
+ indice = opciones.index(seleccionado)
17
+ funcion = funciones[indice]
18
+ st.title(f"{seleccionado} Descargador y Cortador de Videos")
19
+ st.write(f"Descarga y corta una parte aleatoria de un video de {seleccionado}.")
 
 
20
 
21
+ video_link = st.text_input("Enlace del Video", value='https://www.youtube.com/watch?v=ZGltvcmVSAk')
22
+
23
+ choice = st.radio('Seleccionar Proceso:', ['Cortar Video', 'Comprimir Video', 'Descargar Completo'], 0)
 
 
 
 
 
 
24
 
25
+ if choice == 'Cortar Video':
26
+ if st.button(f"Descargar y Cortar {seleccionado}"):
27
+ video_file, titulo_video, video_info, thumbnail_file = funcion(video_link)
28
+ start_time, end_time = random_cut(video_file, titulo_video, duration=60)
29
  file_size = os.path.getsize(video_file)
30
+ session(video_info, video_file, thumbnail_file, start_time, end_time)
31
+ st.text_input(f"Video '{titulo_video}' después de ser procesado:", convert_size(file_size))
32
 
33
+ elif choice == 'Comprimir Video':
34
+ compress = st.selectbox("Seleccionar Resolución para Comprimir", (360, 480, 720), 2)
35
+ if st.button(f"Descargar y Comprimir {seleccionado}"):
36
+ video_file, titulo_video, video_info, thumbnail_file = funcion(video_link)
 
37
  video_file = convert_videos(compress, video_file)
38
  file_size = os.path.getsize(video_file)
39
  session(video_info, video_file, thumbnail_file, choice)
40
+ st.text_input(f"Video '{titulo_video}' después de ser procesado:", convert_size(file_size))
41
 
42
+ else: # Descargar Completo
43
+ if st.button(f"Descargar {seleccionado}"):
44
+ video_file, titulo_video, video_info, thumbnail_file = funcion(video_link)
45
  file_size = os.path.getsize(video_file)
46
  session(video_info, video_file, thumbnail_file, choice)
47
+ st.text_input(f"Video '{titulo_video}' después de ser procesado:", convert_size(file_size))