Rework exporter to allow exporting individual files from library

This commit is contained in:
JonnyWong16 2020-10-14 12:48:08 -07:00
commit f3fa9601c0
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
6 changed files with 428 additions and 247 deletions

View file

@ -798,10 +798,10 @@ def dbcheck():
c_db.execute(
'CREATE TABLE IF NOT EXISTS exports (id INTEGER PRIMARY KEY AUTOINCREMENT, '
'timestamp INTEGER, section_id INTEGER, user_id INTEGER, rating_key INTEGER, media_type TEXT, '
'filename TEXT, file_format TEXT, '
'title TEXT, file_format TEXT, '
'metadata_level INTEGER, media_info_level INTEGER, '
'thumb_level INTEGER DEFAULT 0, art_level INTEGER DEFAULT 0, '
'custom_fields TEXT, '
'custom_fields TEXT, individual_files INTEGER DEFAULT 0, '
'file_size INTEGER DEFAULT 0, complete INTEGER DEFAULT 0)'
)
@ -2179,6 +2179,18 @@ def dbcheck():
'UPDATE exports SET art_level = 9 WHERE include_art = 1'
)
# Upgrade exports table from earlier versions
try:
c_db.execute('SELECT title FROM exports')
except sqlite3.OperationalError:
logger.debug("Altering database. Updating database table exports.")
c_db.execute(
'ALTER TABLE exports ADD COLUMN title TEXT'
)
c_db.execute(
'ALTER TABLE exports ADD COLUMN individual_files INTEGER DEFAULT 0'
)
# Add "Local" user to database as default unauthenticated user.
result = c_db.execute('SELECT id FROM users WHERE username = "Local"')
if not result.fetchone():