A simple script to copy enough random audio files for an LP4 MD (MD-LP).
LP4 encoding handles lofi stuff really well and Web MiniDisc Pro takes whatever ffmpeg can handle as input. This script takes a directory of audio files and randomly selects enough of them to fill a 74-minute MD with LP4 encoding.
In principle this script supports any audio files ffmpeg does. That can vary depending on the particular version of ffmpeg so if you desperately want support for .GSM files or something then you'll need to ensure the version of ffmpeg the script has access to supports the format. Also add the file extension to the list of extensions for it to look for.
The code isn't built to handle all eventualities. For example, it looks at artists and titles in the ID3 tags to create a list of what's already been included - skipping files that have the same tags. If your files don't have tags then the filename is used but that does mean that duplicate checking isn't going to work quite as well. I'd use something like EasyTag or Kid3 to batch tag and rename files.
When using Web MiniDisc Pro I'd drag and drop the tracks into it and select "use track names" (from the ID3 tags). In doing so the files will end up in alphabetical order which isn't what I wanted. Of course, you could use your MD's shuffle setting, if it has one (my old car radio doesn't!), but the way I handle this in the code is by adding a random integer as a prefix to the filenames. This means the filenames become fairly random which is good enough here (and as the filenames aren't used for the track names it doesn't impact the automatic tagging that Web MiniDisc Pro does).
I think there's some rounding issues at play as the total output always seems to be about 1.5% under the desired length. I've added a 1.013 multiplier to combat this (under is still better than over) but it annoys me that it's necessary.
Filename case sensitivity could be an issue. If your file extensions aren't lower case then it's not guaranteed that glob will find them. From what I understand this will depend on whether your filesystem is case-sensitive or not. I could write some convoluted code to deal with that, but it feels like enough of an edge case to not be worth the additional complexity.
Also, if you're filling an LP4 disc with lots of short tracks you will run out of characters for titles when using Web MiniDisc Pro. MD tables of contents (ToCs) weren't designed to handle 100+ track names! It'll just mean that once the ToC is full the rest of the tracks won't have titles. Even though it's not an issue with this script it's something you'll run into if using it as intended, so I figured I'd flag it up.