Spaces:
Runtime error
Runtime error
File size: 1,054 Bytes
e03a0f4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
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()
|