Musicbrainz Database

  1. Install package

sudo apt-get install python-psycopg2 python postgresql

 

git clone https://github.com/lalinsky/mbslave.git

  1. Make sure you have Python and psycopg2 installed.
  2. Setup a database and create mbslave.conf by copying and editing mbslave.conf.default. If you are starting completely from scratch, you can use the following commands to setup a clean database:
    sudo su - postgres
    createuser musicbrainz
    createdb -l C -E UTF-8 -T template0 -O musicbrainz musicbrainz
    createlang plpgsql musicbrainz
    
  3. Prepare empty schemas for the MusicBrainz database and create the table structure:
    echo 'CREATE SCHEMA musicbrainz;' | ./mbslave-psql.py -S
    echo 'CREATE SCHEMA statistics;' | ./mbslave-psql.py -S
    echo 'CREATE SCHEMA cover_art_archive;' | ./mbslave-psql.py -S
    echo 'CREATE SCHEMA wikidocs;' | ./mbslave-psql.py -S
    echo 'CREATE SCHEMA documentation;' | ./mbslave-psql.py -S
    ./mbslave-remap-schema.py <sql/CreateTables.sql | sed 's/CUBE/TEXT/' | ./mbslave-psql.py
    ./mbslave-remap-schema.py <sql/statistics/CreateTables.sql | ./mbslave-psql.py
    ./mbslave-remap-schema.py <sql/caa/CreateTables.sql | ./mbslave-psql.py
    ./mbslave-remap-schema.py <sql/wikidocs/CreateTables.sql | ./mbslave-psql.py
    ./mbslave-remap-schema.py <sql/documentation/CreateTables.sql | ./mbslave-psql.py
    
  4. Download the MusicBrainz database dump files from http://ftp.musicbrainz.org/pub/musicbrainz/data/fullexport/
  5. Import the data dumps, for example:
    ./mbslave-import.py mbdump.tar.bz2 mbdump-derived.tar.bz2
    
  6. Setup primary keys, indexes and views:
    ./mbslave-remap-schema.py <sql/CreatePrimaryKeys.sql | ./mbslave-psql.py
    ./mbslave-remap-schema.py <sql/statistics/CreatePrimaryKeys.sql | ./mbslave-psql.py
    ./mbslave-remap-schema.py <sql/caa/CreatePrimaryKeys.sql | ./mbslave-psql.py
    ./mbslave-remap-schema.py <sql/wikidocs/CreatePrimaryKeys.sql | ./mbslave-psql.py
    ./mbslave-remap-schema.py <sql/documentation/CreatePrimaryKeys.sql | ./mbslave-psql.py
    
    ./mbslave-remap-schema.py <sql/CreateIndexes.sql | grep -vE '(collate|page_index|medium_index)' | ./mbslave-psql.py
    ./mbslave-remap-schema.py <sql/statistics/CreateIndexes.sql | ./mbslave-psql.py
    ./mbslave-remap-schema.py <sql/caa/CreateIndexes.sql | ./mbslave-psql.py
    
    ./mbslave-remap-schema.py <sql/CreateViews.sql | ./mbslave-psql.py
    
  7. Vacuum the newly created database (optional)
    echo 'VACUUM ANALYZE;' | ./mbslave-psql.py
    

Read More

Download Files via PowerShell

The Invoke-WebRequest is used as weget method on Linux and the script below can get a serie of files on our web server and write to our local disk.

for($i=1; $i -le 10; $i++) {
    for($j = 1; $j -le 5; $j++) {
        $strFileName="File_" + $i.ToString() + "_"+ $j.ToString() + ".jpg"

        Invoke-WebRequest http://exemplo.com/$strFileName -OutFile c:\Temp\$strFileName 

    }
}

Read More