import streamlit as st from github import Github import requests # Set up the Streamlit app st.title("GitHub Repository Downloader") # Get user input for GitHub repository details owner = st.text_input("Enter the repository owner:") repo = st.text_input("Enter the repository name:") # Create a PyGitHub object for the repository g = Github() repository = g.get_repo(f"{owner}/{repo}") # Get all files in the repository files = repository.get_contents("") # Create a list to store the URLs of the files to download urls_to_download = [] # Loop through each file and check if it's a data file or markdown file for file in files: if file.name.endswith(".csv") or file.name.endswith(".md"): urls_to_download.append(file.download_url) # If there are files to download, create a button to start the download if len(urls_to_download) > 0: if st.button("Download Files"): for url in urls_to_download: # Download the file using the requests library response = requests.get(url) # Save the file with the original name in the current working directory with open(f"./{url.split('/')[-1]}", "wb") as file: file.write(response.content) st.success("Download complete!") else: st.write("No data or markdown files found in the repository.")