diff --git a/jamendoparser.py b/jamendoparser.py index d650359..82103ce 100644 --- a/jamendoparser.py +++ b/jamendoparser.py @@ -1,4 +1,4 @@ -import urllib, gzip, sys, argparse +import urllib, gzip, sys, argparse, sqlite3 from lxml.etree import iterparse xml_url = "http://img.jamendo.com/data/dbdump_artistalbumtrack.xml.gz" @@ -19,9 +19,6 @@ def get_attribute(element, tagname): else: 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.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) print "" +database = sqlite3.connect(options['database']) +cursor = database.cursor() + xml = gzip.open(xml_file) for event, element in iterparse(xml, tag="artist"):