Spaces:
Paused
Paused
Commit ·
3e61cb2
1
Parent(s): cfdf719
Baru
Browse files
app.py
CHANGED
|
@@ -30,61 +30,92 @@ if selected:
|
|
| 30 |
elif selected == 'Iwara' or selected == 'Mega':
|
| 31 |
name = st.text_input("Nama File")
|
| 32 |
video_link = st.text_input("Link Video")
|
| 33 |
-
elif selected == 'Cek
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
st.write('Folder is empty!')
|
| 38 |
else:
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
else:
|
| 44 |
video_link = st.text_input("Link Video")
|
| 45 |
|
| 46 |
-
|
|
|
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
elif selected == 'Iwara' or selected == 'Mega':
|
| 31 |
name = st.text_input("Nama File")
|
| 32 |
video_link = st.text_input("Link Video")
|
| 33 |
+
elif selected == 'Cek Video Penyimpanan':
|
| 34 |
+
|
| 35 |
+
tempat = st.selectbox("Pilih Tempat", ("Hasil Potong", "Hasil Konversi", "Hasil Download"), 2)
|
| 36 |
+
tempat_path = os.path.join('/home/user/app', tempat)
|
| 37 |
+
|
| 38 |
+
# Buat list untuk menyimpan semua file
|
| 39 |
+
all_files = []
|
| 40 |
+
|
| 41 |
+
# Iterasi melalui semua direktori dan sub-direktori
|
| 42 |
+
for root, dirs, files in os.walk(tempat_path):
|
| 43 |
+
for file in files:
|
| 44 |
+
file_path = os.path.join(root, file)
|
| 45 |
+
# Tambahkan path file ke list
|
| 46 |
+
all_files.append(file_path)
|
| 47 |
+
|
| 48 |
+
# Buat variabel untuk menyimpan jumlah baris dalam text area
|
| 49 |
+
num_lines = len(all_files)
|
| 50 |
+
|
| 51 |
+
# Jika tidak ada file dalam direktori
|
| 52 |
+
if not all_files:
|
| 53 |
st.write('Folder is empty!')
|
| 54 |
else:
|
| 55 |
+
# Tampilkan semua file dalam text area
|
| 56 |
+
st.write('Files in directory:', tempat_path)
|
| 57 |
+
st.text_area("Files", "\n".join(all_files), height=25*num_lines)
|
| 58 |
+
|
| 59 |
else:
|
| 60 |
video_link = st.text_input("Link Video")
|
| 61 |
|
| 62 |
+
if selected != 'Cek Konversi':
|
| 63 |
+
choice = st.radio('Pilih Proses:', ['Potong Video', 'Compress Video', 'Cuma Download'], 2)
|
| 64 |
|
| 65 |
+
if choice == 'Potong Video':
|
| 66 |
+
start_time = st.text_input("Start Time", value='00:07:12.000')
|
| 67 |
+
end_time = st.text_input("End Time", value='00:07:31.000')
|
| 68 |
+
|
| 69 |
+
if st.button(f"Download and Cut {selected}"):
|
| 70 |
+
if selected == 'Youtube' or selected == 'Pornhub':
|
| 71 |
+
video_file, judul_video, video_info, thumbnail_file = fungsi(video_link, resolution)
|
| 72 |
+
elif selected == 'Iwara' or selected == 'Mega':
|
| 73 |
+
video_file, judul_video, video_info, thumbnail_file = fungsi(video_link, name)
|
| 74 |
+
else:
|
| 75 |
+
video_file, judul_video, video_info, thumbnail_file = fungsi(video_link)
|
| 76 |
+
video_file = cut_video(video_file, judul_video, start_time, end_time)
|
| 77 |
+
file_size = os.path.getsize(video_file)
|
| 78 |
+
session(video_info, video_file, thumbnail_file, choice)
|
| 79 |
+
st.text_input(f"Video '{judul_video}' setelah diproses:", convert_size(file_size))
|
| 80 |
|
| 81 |
+
elif choice == 'Compress Video':
|
| 82 |
+
compress = st.selectbox("Pilih Resolusi Compress", (360, 480, 720), 2)
|
| 83 |
+
|
| 84 |
+
if st.button(f"Download and Compress {selected}"):
|
| 85 |
+
if selected == 'Youtube' or selected == 'Pornhub':
|
| 86 |
+
video_file, judul_video, video_info, thumbnail_file = fungsi(video_link, resolution)
|
| 87 |
+
elif selected == 'Iwara' or selected == 'Mega':
|
| 88 |
+
video_file, judul_video, video_info, thumbnail_file = fungsi(video_link, name)
|
| 89 |
+
else:
|
| 90 |
+
video_file, judul_video, video_info, thumbnail_file = fungsi(video_link)
|
| 91 |
+
video_file = convert_videos(compress, video_file)
|
| 92 |
+
file_size = os.path.getsize(video_file)
|
| 93 |
+
session(video_info, video_file, thumbnail_file, choice)
|
| 94 |
+
st.text_input(f"Video '{judul_video}' setelah diproses:", convert_size(file_size))
|
| 95 |
|
| 96 |
+
else:
|
| 97 |
+
if st.button(f"Download {selected}"):
|
| 98 |
+
if selected == 'Youtube' or selected == 'Pornhub':
|
| 99 |
+
video_file, judul_video, video_info, thumbnail_file = fungsi(video_link, resolution)
|
| 100 |
+
elif selected == 'Iwara' or selected == 'Mega':
|
| 101 |
+
video_file, judul_video, video_info, thumbnail_file = fungsi(video_link, name)
|
| 102 |
+
else:
|
| 103 |
+
video_file, judul_video, video_info, thumbnail_file = fungsi(video_link)
|
| 104 |
+
file_size = os.path.getsize(video_file)
|
| 105 |
+
session(video_info, video_file, thumbnail_file, choice)
|
| 106 |
+
st.text_input(f"Video '{judul_video}' setelah diproses:", convert_size(file_size))
|
| 107 |
|
| 108 |
+
else:
|
| 109 |
+
video_file = st.text_input("Pilih File", value='Best Dark Hentai Anime Series.mp4')
|
| 110 |
+
video_path = os.path.join(tempat_path, video_file)
|
| 111 |
+
thumbnail_path = cari_file(video_path.replace("mp4", "jpg"), '/home/user/app/Hasil Download')
|
| 112 |
+
if tempat =="Hasil Potong":
|
| 113 |
+
choice = 'Potong Video'
|
| 114 |
+
elif tempat =="Hasil Konversi":
|
| 115 |
+
choice = 'Compress Video'
|
| 116 |
+
else:
|
| 117 |
+
choice = ''
|
| 118 |
+
if st.button(f"Dapatkan File"):
|
| 119 |
+
file_size = os.path.getsize(video_path)
|
| 120 |
+
session("", video_path, thumbnail_path, choice)
|
| 121 |
+
st.text_input(f"Video '{video_file}' dengan size:", convert_size(file_size))
|
others.py
CHANGED
|
@@ -68,6 +68,21 @@ def session(video_info, video_file, thumbnail_file, choice):
|
|
| 68 |
mime='video/mp4'
|
| 69 |
)
|
| 70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
def convert_size(size_bytes):
|
| 72 |
units = ["B", "KB", "MB", "GB", "TB"]
|
| 73 |
index = 0
|
|
|
|
| 68 |
mime='video/mp4'
|
| 69 |
)
|
| 70 |
|
| 71 |
+
def cari_file (judul, directory):
|
| 72 |
+
# Inisialisasi variabel untuk menyimpan thumbnail path
|
| 73 |
+
file_path = None
|
| 74 |
+
|
| 75 |
+
# Iterasi melalui semua direktori dan sub-direktori di directory
|
| 76 |
+
for root, dirs, files in os.walk(directory):
|
| 77 |
+
for file in files:
|
| 78 |
+
# Periksa apakah nama file sesuai dengan video_file dan berakhiran .jpg
|
| 79 |
+
if judul in file:
|
| 80 |
+
# Simpan thumbnail path
|
| 81 |
+
file_path = os.path.join(root, file)
|
| 82 |
+
# Hentikan pencarian setelah menemukan thumbnail
|
| 83 |
+
break
|
| 84 |
+
return file_path
|
| 85 |
+
|
| 86 |
def convert_size(size_bytes):
|
| 87 |
units = ["B", "KB", "MB", "GB", "TB"]
|
| 88 |
index = 0
|