awacke1's picture
Create app.py
e03a0f4 verified
import streamlit as st
import os
import glob
import zipfile
def extract_zip(zip_path, extract_to="extracted_videos"):
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
zip_ref.extractall(extract_to)
return extract_to
def main():
st.title('Zip File Video Gallery')
# Check for zip files in the current directory
zip_files = glob.glob('*.zip')
if zip_files:
zip_file = zip_files[0]
st.write(f"Found zip file: {zip_file}")
file_size = os.path.getsize(zip_file)
st.write(f"Size: {file_size / (1024 * 1024):.2f} MB")
# Extract the zip file
if st.button('Extract Zip File'):
extract_path = extract_zip(zip_file)
st.success(f'Extracted to {extract_path}')
# Display video gallery
videos = glob.glob(f'{extract_path}/*.mp4')
for video in videos:
st.video(video, format="video/mp4", start_time=0)
else:
st.write("No zip files found in the directory.")
if __name__ == "__main__":
main()