| Key points | Details to remember |
|---|---|
| 📝 Definition | Automate the import of covers and descriptions from Screenscraper |
| 🎮 Main benefits | Visually enrich your frontend, save valuable time |
| 🔧 How it works | Retrieve via the API, associate metadata and images |
| ⚙️ Prerequisites | Install Python, configure your Screenscraper API key |
| 🚀 Key steps | Run the script, test the output, validate the files |
| 📂 Organization | Structure folders for each system |
| 🛠️ Tools | Use a lightweight Python script and a cron for automation |
This tutorial guides you step by step to configure Screenscraper and automatically integrate covers and descriptions into your Retrogaming interface. With a few simple commands and settings, you can visually enrich your frontend while having precise information on each game. At the end, a cron will launch the operation without manual intervention.
Somaire
Prerequisites and installation of Screenscraper
First of all, make sure you have a valid account on Screenscraper and an API key. You will also need a Python 3.7+ environment on your machine or server.
To install the dedicated Python module, run:
pip install screenscraper-api
Then verify that the library responds correctly:
python -c "import screenscraper; print(screenscraper.__version__)". If an error appears, reinstall or update your pip.
Configuration of the import script
The Python script acts as a bridge between the Screenscraper API and your Retrogaming frontend. It retrieves covers and descriptions, then deposits them into dedicated folders.
Connecting to the Screenscraper API
Retrieve your key from your personal Screenscraper space and store it in an environment variable:
export SCREENSCRAPER_KEY="your_key"
Then, in your script:
from screenscraper import ScreenScraperAPI
api = ScreenScraperAPI(key=os.getenv("SCREENSCRAPER_KEY"))
You are now ready to query the API.
Customization of filters and formats
To adjust the output, you can specify:
- image size (small, medium, large)
- description language (fr, en, it)
- target platform (nes, snes, arc)
- output formats (png, jpg, txt)
These options are passed as parameters:
api.get_game_data(game_id, image_size='medium', language='fr')
Test several configurations to find the one that best integrates with your theme.
Integration into your Retrogaming frontend
Once the files are retrieved, you need to organize them and call the correct path in your frontend code. The idea is to standardize the location for each title.
Organization of covers and descriptions
Maintain a clear directory structure:
| Folder | Content |
|---|---|
| images/ | Covers named by game ID (.png) |
| descriptions/ | Text files by game ID (.txt or .md) |
| scripts/ | Python import code |
This allows the frontend to loop over the same ID and dynamically display the associated cover and description.
Automation via a cron task
To run the import periodically, create a cron entry:
0 3 * * * /usr/bin/python3 /home/user/scripts/import_screenscraper.py >> /var/log/ss_import.log 2>&1
This task runs every night at 3 a.m. You can adjust the frequency according to your needs.
Tip: monitor the logs to quickly fix an API failure or a schema change on the Screenscraper side.
Testing, debugging, and best practices
An automated import can encounter issues such as expired keys, changed formats, or exceeded quotas. Here are some tips to stay operational:
- Regularly check the validity of your API key
- Implement a retry system with backoff in case of error 429
- Keep a version history to roll back if needed
- Clean up old unreferenced files
- Manually validate some covers after each deployment
- Set up alerts for critical error codes
- Test locally before deploying to production
- Document every script modification
Key takeaways
- Create a Screenscraper account and retrieve your API key
- Install the dedicated Python module and test the connection
- Customize filters (size, language, platform)
- Organize covers and descriptions in a clear directory structure
- Automate with a cron job and monitor the logs
- Plan retry and alert strategies
FAQ
- How do I get my Screenscraper API key?
Log in to your account on the Screenscraper website, go to “My account” then “API” to generate or copy your key. - Which systems are supported by Screenscraper?
The platform covers more than 200 systems, from 8-bit consoles to arcade machines, including more recent devices. - Can I retrieve descriptions in multiple languages?
Yes: just modify thelanguageparameter when callingget_game_data(for example “en” or “it”). - How to manage API quotas?
Monitor the response headers to track your usage and implement a backoff system to avoid 429 errors. - Can the script replace existing covers?
Absolutely: you can add anoverwrite=Trueoption to overwrite previous files. - What to do if covers are missing?
Identify the IDs not returned, test manually on the Screenscraper site, and complete manually if necessary.