Script for scraping an Open Public Domain Exercise Database in JSON
format, 1300+ exercises.
ExerciseGifDownloader is a collection of PowerShell scripts designed to scrape data from a RapidAPI Exercise Database. The script downloads each GIF from a provided URL and stores it based on category. I originally developed the script to collect media for a larger project involving exercise demonstrations. While working on this project, I noticed a lack of free and well-organized exercise GIFs available online, so I created this tool to help download and categorize GIFs from a well structured, open source dataset.
- Large Exercise Database: Access to over 1300 exercises with individual exercise data.
- Generate JSON File: Request information regarding exercise information from the RapidAPI database.
- Download Exercise GIFs: Automatically downloads GIFs from their provided URLs.
- Organize by Category: Sorts and stores each downloaded GIF into its respective exercise category folder.
- Renames Files: Renames each downloaded GIF based on the exercise name for easy identification.
- Error Handling: Skips problematic entries (e.g., invalid URLs, invalid file names) and logs errors without stopping the script.
- PowerShell 5.0 or later
- Internet Access to download GIFs
-
Clone this repository to your local machine:
git clone https://github.com/XZE3N/ExerciseGifDownloader.git
-
Obtain a RapidAPI Private Key:
- Visit RapidAPI and sign up for a free account or log in if you already have one.
- In the RapidAPI dashboard, use the search bar to find the API (ExerciseDB).
- Choose a subscription plan (this API offers a free tier). Feel free to support the creator of the API - Justin.
- After subscribing, navigate to the "Endpoints" tab for that API. At the top of the page, you’ll see your X-RapidAPI-Key. This is your private key.
- Copy the API key and use it as a parameter when executing
Request-Exercises.ps1
.
-
Navigate to the directory where the scripts are located.
-
Run the
Request-Exercises.ps1
PowerShell script. Remember to pass your RapidAPI private key as a parameter as such:./Request-Exercises.ps1 -ApiKey 'YOUR-API-KEY-FROM-RAPIDAPI'
The script will now generate a JSON response file called
response.json
.The input JSON file should be structured as follows:
[ { "bodyPart": "waist", "equipment": "body weight", "gifUrl": "https://v2.exercisedb.io/image/UcvY9fRgNeiV4m", "id": "0001", "name": "3/4 sit-up", "target": "abs", "secondaryMuscles": [ "hip flexors", "lower back" ], "instructions": [ "Lie flat on your back with your knees bent and feet flat on the ground.", "Place your hands behind your head with your elbows pointing outwards.", "Engaging your abs, slowly lift your upper body off the ground, curling forward until your torso is at a 45-degree angle.", "Pause for a moment at the top, then slowly lower your upper body back down to the starting position.", "Repeat for the desired number of repetitions." ] }, ... ]
- name: The name of the exercise (used to rename the GIF).
- target: The category of the exercise (used to create a folder for organization).
- gifUrl: The direct URL for downloading the GIF.
-
Run the
Get-Exercises.ps1
PowerShell script../Get-Exercises.ps1
-
The script will:
- Parse the JSON file.
- Create folders for each exercise category (if not already present).
- Download each GIF and rename it according to the exercise name.
- Store the renamed GIF in its respective category folder.
After running the script, your directory will be organized like this:
categories/
├── abs/
│ ├── cable twist.gif
├── biceps/
│ ├── barbell curl.gif
- Invalid URLs: The script logs any invalid URLs and skips those entries without stopping execution.
- Invalid File Names: If a GIF name contains invalid characters, they are removed or replaced with valid ones.
Future enhancements could include:
- Adding multi-threading for faster downloads.
- CLI options for specifying output directories.
- Enhanced logging and reporting capabilities.
Contributions are welcome! Please open an issue or submit a pull request if you'd like to help improve this project.
This project is licensed under the MIT License. See the LICENSE file for details.
If you have any questions or suggestions, feel free to reach out to me at:
Email: [email protected]
Or open an issue in the GitHub repository.