def __init__(self): self.cursor.execute('SELECT name FROM sqlite_master WHERE type=\'table\'') result=self.cursor.fetchall() if not ('config',) in result: CMP.warn('config table missing. Creating...') self.initalize_config() self.extract_settings()
def __init__(self,library_dir): self.library_create = 'CREATE TABLE library (song_id INTEGER PRIMARY KEY, file VARCHAR(255), tracknum INT(8), title VARCHAR(255), artist VARCHAR(255), album VARCHAR(255), year INT(16), modified VARCHAR(20))' self.library_insert = 'INSERT INTO library VALUES (null, ?, ?, ?, ?, ?, ?, ?)' self.library_dir = library_dir #add the library table if it doesn't exist self.cursor.execute('SELECT name FROM sqlite_master WHERE type=\'table\'') result=self.cursor.fetchall() if not ('library',) in result: CMP.warn('library table missing. Creating...') self.cursor.execute(self.library_create) self.connection.commit() self.check_for_changes()
def remove_from_library(self,songfile): CMP.warn("track "+songfile+" is missing. removing from database") self.cursor.execute('DELETE FROM library WHERE file =?',(songfile,))
def add_to_library(self,songfile): mytagger = tagger() tags = mytagger.get_track_info(songfile) CMP.warn("adding "+songfile) self.cursor.execute(self.library_insert, ( songfile, tags['tracknum'], tags["title"], tags["artist"], tags["album"], tags['year'], str(os.path.getmtime(songfile)) ) )