Chango 1.0 jsl@absynth.com 2000 July 03 Chango is a system for cacheing MP3 files from multidisc cdrom drives. Since you can't actually mount different discs in the same physical device simultaneously, this software will cache the files you need off to a predetermined cache, so that all of the needed files will be available simultaneously. Prerequisite software: properly configured cdrom drives. 'eject' 'id3ed', by Matt Mueller freshmeat index 922229360 This set of scripts is free. If you use it, try to give me some sort of credit. If you find it useful, drop me some e-mail! No warranty is either expressed or implied. If this somehow kills your grandmother, it's not my fault. Don't do dumb things with this. btw. it's pronounced "change-oh". Here's how to configure it for your system; - Edit the 'drives.conf' file in accordance to how your machine is set up. The included .conf file shows two drives, each holding a max of 4 discs. /dev/cdrom0:/mnt/cdrom0:4 /dev/cdrom1:/mnt/cdrom1:4 I setup symlinks in /dev from /dev/cdrom0 to /dev/hdc and a second one from /dev/cdrom1 to /dev/hdd. Make sure these are read/execute by the user who will be running the software. I am using a RedHat distro, so all mounted devices will end up in /mnt. so, my /etc/fstab shows the following: /dev/cdrom0 /mnt/cdrom0 iso9660 noauto,owner,ro 0 0 /dev/cdrom1 /mnt/cdrom1 iso9660 noauto,owner,ro 0 0 So, by looking at both files, you should see that there is a corrolation between the two. - At this point, you should be able to 'mount /mnt/cdrom0' as whatever user will be running the script. As well, you should be able to change disks using 'eject -c 2 /dev/cdrom0' to swap disks. - Run the 'scandrives.pl' script. 'perl scandrives.pl' This will scan the CD's in the drives, and create the database files based on the mp3s. It should show you the directories it is working through as its working. If it notices that the cd is the same as the one it had already scanned, it will skip it. (This is so that if you change just one disc, you can re-run the app, and it will only do the full work on the new or changed discs.) The files it creates (in "db/") are of the following form: The filenames themselves are the mountpoint, then a period, then the disc number. The path for the mountpoint has the slashes changed into colons. So, if you wanted to look at the file for /mnt/cdrom1, disk 3, you would look in "db/:mnt:cdrom1.3" The files themselves are of the following form: Header information a blank line database entries The header information currently is just a single line, which is composed by the amount and content of the disc. This is how I identify one disc from another. It's simple, and is pretty effective. The blank line is there so that in the future, if more header information is added, it will be easy to seperate it out from the rest of the file. Here's an example: /dev/cdrom1##::##/mnt/cdrom1##::##2##::##/mnt/cdrom1/Hack/08 Hard Currency.mp3##::##Hard Currency##::##Information Society##::##Hack##::##1999##::##, AG# E6A59D0A##::##Pop(13) The database entries are fields seperated by the string "##::##". That is, pound, pound, colon, colon, pound, pound. A string that probably won't appear anywhere in the filenames. The fields, in order are: (with examples) Device path /dev/cdrom1 Mount point /mnt/cdrom1 Disk Number 2 path to file /mnt/cdrom1/Hack/08 Hard Currency.mp3 ID3 Title Hard Currency ID3 Band Information Society ID3 Album Hack ID3 Year 1999 ID3 Comment , AG# E6A59D0A ID3 Genre Pop(13) Writing a playlist editor using these files should be trivial. - In any event, by this point, you should have valid database files, all filled out with all of the above info (assuming the MP3's have correct ID3 tags.) - To cache in a file, just send cache.pl the database entry (like the above line). ie: perl cache.pl /dev/cdrom1##::##/mnt/cdrom1##::##.....etc.... Or, say you want to cache all files with the word "Talking" somewhere in their entry, you could do this: grep --no-filename -i Talking db/* | perl cache.pl If the file that it is about to copy is already in the cache, it will just touch the file instead of re-copying it. - It is assumed that some external timeout mechanism or expiration mechanism will be used to remove the files from the cache.