awacke1 commited on
Commit
e03a0f4
1 Parent(s): 2d9ddb0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import os
3
+ import glob
4
+ import zipfile
5
+
6
+ def extract_zip(zip_path, extract_to="extracted_videos"):
7
+ with zipfile.ZipFile(zip_path, 'r') as zip_ref:
8
+ zip_ref.extractall(extract_to)
9
+ return extract_to
10
+
11
+ def main():
12
+ st.title('Zip File Video Gallery')
13
+
14
+ # Check for zip files in the current directory
15
+ zip_files = glob.glob('*.zip')
16
+ if zip_files:
17
+ zip_file = zip_files[0]
18
+ st.write(f"Found zip file: {zip_file}")
19
+ file_size = os.path.getsize(zip_file)
20
+ st.write(f"Size: {file_size / (1024 * 1024):.2f} MB")
21
+
22
+ # Extract the zip file
23
+ if st.button('Extract Zip File'):
24
+ extract_path = extract_zip(zip_file)
25
+ st.success(f'Extracted to {extract_path}')
26
+
27
+ # Display video gallery
28
+ videos = glob.glob(f'{extract_path}/*.mp4')
29
+ for video in videos:
30
+ st.video(video, format="video/mp4", start_time=0)
31
+
32
+ else:
33
+ st.write("No zip files found in the directory.")
34
+
35
+ if __name__ == "__main__":
36
+ main()