@ -1,4 +1,4 @@
import urllib , gzip , sys , argparse
import urllib , gzip , sys , argparse , sqlite3
from lxml . etree import iterparse
from lxml . etree import iterparse
xml_url = " http://img.jamendo.com/data/dbdump_artistalbumtrack.xml.gz "
xml_url = " http://img.jamendo.com/data/dbdump_artistalbumtrack.xml.gz "
@ -19,9 +19,6 @@ def get_attribute(element, tagname):
else :
else :
return val . text
return val . text
database = sqlite3 . connect ( options [ ' database ' ] )
cursor = database . cursor ( )
parser = argparse . ArgumentParser ( description = ' Downloads and parses the Jamendo XML dump, and creates an SQLite database with all artist, album, track, and tag data. ' )
parser = argparse . ArgumentParser ( description = ' Downloads and parses the Jamendo XML dump, and creates an SQLite database with all artist, album, track, and tag data. ' )
parser . add_argument ( ' -D ' , dest = ' no_download ' , action = ' store_true ' ,
parser . add_argument ( ' -D ' , dest = ' no_download ' , action = ' store_true ' ,
@ -43,6 +40,9 @@ if options['no_download'] == False:
urllib . urlretrieve ( xml_url , xml_file , reporthook = update_progress )
urllib . urlretrieve ( xml_url , xml_file , reporthook = update_progress )
print " "
print " "
database = sqlite3 . connect ( options [ ' database ' ] )
cursor = database . cursor ( )
xml = gzip . open ( xml_file )
xml = gzip . open ( xml_file )
for event , element in iterparse ( xml , tag = " artist " ) :
for event , element in iterparse ( xml , tag = " artist " ) :