## # filename: POPULATE_DB (part of CouchMan - music playing and management system) # # Instructions on gathering music file information and populating the Database. # # Copyright 2009 Pete Nesbitt (pete@linux1.ca) # # This file is part of CouchMan. # # CouchMan is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # CouchMan is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with CouchMan; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## Directory Structure: CouchMan is set up to work with the following format: BASE_PATH -holds directories of each artist ARTIST -directory of albums or cd's for this artist ALBUM -directory of the song files (.mp3 or .flac) eg: /data/music/couchman/ |-- Alan_Parsons_Project | |-- IROBOT | | |-- IROBOT-77_1.flac | | `-- IROBOT-77_2.flac | `-- Pyramid | |-- Pyramid-78_1.flac | `-- Pyramid-78_2.flac |-- BB_King |-- Deuces_Wild |-- Ain't_Nobody_Home_w-D'Angelo.mp3 |-- Baby_I_Love_You_w-Bonnie_Rait.mp3 |-- Confessin'_The_Blues_w-Marty_Stuart.mp3 Important: You will need to modify the cm_admin_gather_musicdata-cgi.sh script to match different file structures. Year and Genre: Optionally, each album directory (like IROBOT in the example) can include two additional files. The first should be named "cm_year" and contain only the 4 digit year of the album. The second file should be named "cm_genre". Intended for the Genre of the album, it has a 20 character max size, and can be used for any information. Steps: Since you probably have a lot of music to set up initially, you can use the steps below which walk you thru doing small sets of music. I had about 100 artists directories, many with several albums. They were not in a consitand layout either. I broke my tasks into 3 sets as follows: mkdir -p /data/music/couchman mkdir -p /data/music/couchman_done cd /data/music/couchman 1) for about 1/3 of the artist I did this: mkdir -p / mv //* // echo > //cm_year -if not "rock": echo > //cm_genre -once each artist was done I removed the old empty dir: rmdir (if you missed something, and the dir is not empty, this will fail) Example: (sitting in the couchman music directory) mkdir -p Stanley_Clarke/School_Days mv ../albums/Stanley_Clarke/School_Days/* Stanley_Clarke/School_Days rmdir ../albums/Stanley_Clarke/ echo 1976 > Stanley_Clarke/School_Days/cm_year echo Jazz > Stanley_Clarke/School_Days/cm_genre 2) run cm_admin_gather_musicdata-cgi.sh (located inn the cgi-bin dir) -first check the Variables near the top -by default it will output to: "/tmp/cm_db_populate_sqlfile" -you may want to check the output file for sanity before moving on. 3) populate the data base by running (using default user/pass for db): mysql -u cm_user -pmusicman -D cm_web_db < /tmp/cm_db_populate_sqlfile 4) save your file (optonal): mv /tmp/cm_db_populate_sqlfile /tmp/cm_db_populate_sqlfile_batch1 (use a different output name each round!) 5) We need to start with an empty directory for the next round. mv * ../couchman_done/ 6) Start at step #1 for the next group of artists, continue until all done 7) Once all artists have been inventoried (steps 1-5), we need to put them all back where the databse expects them: cd /data/music/ mv couchman_batch1/* couchman_batch2/* ...couchman_batch/* couchman/ Testing: log into mysql and see what is there: mysql -u cm_user -pmusicman -D cm_web_db then run: (substitute 'bowie' with something appropriate) select * from music where Artist like '%bowie%'; # EOF