fix: more on database migration, fixed #134
This commit is contained in:
parent
b33e6c6dda
commit
5447a0d132
14
database.py
14
database.py
@ -514,8 +514,7 @@ class MusicDatabase:
|
|||||||
music_dict['type'] = result[1]
|
music_dict['type'] = result[1]
|
||||||
music_dict['title'] = result[2]
|
music_dict['title'] = result[2]
|
||||||
music_dict['id'] = result[0]
|
music_dict['id'] = result[0]
|
||||||
music_dict['tags'] = result[4].strip(",").split(",")
|
music_dict['tags'] = result[4].strip(",").split(",") if result[4] else ''
|
||||||
if 'path' not in music_dict or result[5]:
|
|
||||||
music_dict['path'] = result[5]
|
music_dict['path'] = result[5]
|
||||||
music_dict['keywords'] = result[6]
|
music_dict['keywords'] = result[6]
|
||||||
|
|
||||||
@ -566,10 +565,14 @@ class MusicDatabaseMigration:
|
|||||||
current_version = self.migrate_func[current_version](conn)
|
current_version = self.migrate_func[current_version](conn)
|
||||||
log.info(f"database: migration done.")
|
log.info(f"database: migration done.")
|
||||||
|
|
||||||
|
cursor.execute("UPDATE music SET title=? "
|
||||||
|
"WHERE id='info'", (MUSIC_DB_VERSION,))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
log.info(f"database: no music table found. Creating music table version {MUSIC_DB_VERSION}.")
|
log.info(f"database: no music table found. Creating music table version {MUSIC_DB_VERSION}.")
|
||||||
self.create_table_version_2(conn)
|
self.create_table_version_2(conn)
|
||||||
|
|
||||||
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
def has_table(self, table, conn):
|
def has_table(self, table, conn):
|
||||||
@ -620,6 +623,13 @@ class MusicDatabaseMigration:
|
|||||||
item['keywords'] = item['title']
|
item['keywords'] = item['title']
|
||||||
if 'artist' in item:
|
if 'artist' in item:
|
||||||
item['keywords'] += ' ' + item['artist']
|
item['keywords'] += ' ' + item['artist']
|
||||||
|
|
||||||
|
tags = []
|
||||||
|
for tag in item['tags']:
|
||||||
|
if tag:
|
||||||
|
tags.append(tag)
|
||||||
|
item['tags'] = tags
|
||||||
|
|
||||||
self.db.insert_music(item)
|
self.db.insert_music(item)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user