This script is designed to automate the process of renaming and tagging audio files, using the Discogs API to assist in naming validation. It cleans up the filenames, extracts artist and album information, and updates the metadata of the audio files.
- Python 3.x
- Required libraries:
requests
,mutagen
,python-dotenv
,python-Levenshtein
-
Clone this repository or download the
renamer.py
script. -
Install the required libraries by running the following command:
pip install requests mutagen python-dotenv python-Levenshtein
- Obtain a Discogs API token:
- Sign up for a Discogs account if you don't have one already.
- Go to the Discogs Developer Settings page: https://www.discogs.com/settings/developers
- Create a new application and obtain the API token.
- Create a
.env
file in the same directory as the script and add your Discogs API token:
DISCOGS_ACCESS_TOKEN=your_api_token_here
-
Place the audio files you want to process in a directory.
-
Open a terminal or command prompt and navigate to the directory containing the
renamer.py
script. -
Run the script using the following command:
python renamer.py
-
The script will process each audio file in the specified directory, cleaning up the filenames and retrieving metadata from the Discogs API.
-
If the confidence level of the retrieved metadata is below the threshold, the script will prompt you to manually approve or provide the correct artist and album information.
-
The script will rename the audio files based on the cleaned-up artist and album names and update the metadata accordingly.
-
Processed files will be skipped in subsequent runs unless they have been modified.
-
You can adjust the
confidence_threshold
parameter in theprocess_files()
function to control the level of automation. A higher threshold will result in more manual intervention, while a lower threshold will allow more files to be processed automatically. -
The script uses a JSON file (
processed_files.json
) to keep track of processed files. You can modify the file path or use a different storage mechanism if needed.
If you encounter any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request on the GitHub repository. This suits a niche use case for me, and I hope it can be useful to others as well in the cleaning and preprocessing of audio data collections.
This script is released under the MIT License.