Spaces:
Sleeping
Sleeping
Commit ·
b0877f0
1
Parent(s): 31ed2a8
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,51 +5,43 @@ from youtube import youtube, download_youtube
|
|
| 5 |
from others import *
|
| 6 |
|
| 7 |
# Navigasi Sidebar
|
| 8 |
-
|
| 9 |
with st.sidebar:
|
| 10 |
-
|
| 11 |
icons=['play'], menu_icon="cast", default_index=0)
|
| 12 |
|
| 13 |
-
|
| 14 |
|
| 15 |
-
if
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
st.title(f"{
|
| 19 |
-
st.write(f"
|
| 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 |
-
|
| 24 |
-
|
| 25 |
-
|
| 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 |
-
|
| 34 |
-
if st.button("
|
| 35 |
-
video_file
|
|
|
|
| 36 |
file_size = os.path.getsize(video_file)
|
| 37 |
-
session(video_info, video_file, thumbnail_file,
|
| 38 |
-
st.text_input(f"Video '{
|
| 39 |
|
| 40 |
-
elif choice == '
|
| 41 |
-
compress = st.selectbox("
|
| 42 |
-
|
| 43 |
-
|
| 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 '{
|
| 49 |
|
| 50 |
-
else:
|
| 51 |
-
if st.button(f"
|
| 52 |
-
video_file,
|
| 53 |
file_size = os.path.getsize(video_file)
|
| 54 |
session(video_info, video_file, thumbnail_file, choice)
|
| 55 |
-
st.text_input(f"Video '{
|
|
|
|
| 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))
|