2017-12-05 00:01:10 +00:00
import os
import sqlite3
# Check if database exist
if os . path . exists ( os . path . join ( os . path . dirname ( __file__ ) , ' data/db/bazarr.db ' ) ) == True :
# Open database connection
db = sqlite3 . connect ( os . path . join ( os . path . dirname ( __file__ ) , ' data/db/bazarr.db ' ) , timeout = 30 )
c = db . cursor ( )
2018-01-10 16:44:47 +00:00
# Execute tables modifications
2017-12-05 00:01:10 +00:00
try :
c . execute ( ' alter table table_settings_providers add column " username " " text " ' )
except :
pass
2018-01-10 16:44:47 +00:00
else :
c . execute ( ' UPDATE table_settings_providers SET username= " " ' )
2017-12-05 00:01:10 +00:00
try :
c . execute ( ' alter table table_settings_providers add column " password " " text " ' )
except :
pass
2018-01-10 16:44:47 +00:00
else :
c . execute ( ' UPDATE table_settings_providers SET password= " " ' )
2017-12-19 01:24:04 +00:00
try :
c . execute ( ' alter table table_shows add column " audio_language " " text " ' )
except :
pass
2017-12-23 03:40:14 +00:00
try :
c . execute ( ' alter table table_settings_general add column " configured " " integer " ' )
c . execute ( ' alter table table_settings_general add column " updated " " integer " ' )
except :
pass
2018-01-10 16:44:47 +00:00
try :
c . execute ( ' alter table table_settings_general add column " single_language " " text " ' )
except :
pass
else :
c . execute ( ' UPDATE table_settings_general SET single_language= " False " ' )
2018-01-23 04:25:58 +00:00
try :
c . execute ( ' CREATE TABLE `table_settings_notifier` (`name` TEXT, `url` TEXT, `enabled` INTEGER); ' )
except :
pass
else :
providers = [ ' Boxcar ' , ' Faast ' , ' Growl ' , ' Join ' , ' KODI ' , ' Mattermost ' , ' Notify My Android ' , ' Prowl ' , ' Pushalot ' , ' PushBullet ' , ' Pushjet ' , ' Pushover ' , ' Rocket.Chat ' , ' Slack ' , ' Super Toasty ' , ' Telegram ' , ' Twitter ' , ' XBMC ' ]
for provider in providers :
c . execute ( ' INSERT INTO `table_settings_notifier` (name, enabled) VALUES (?, ?); ' , ( provider , ' 0 ' ) )
2018-03-14 20:28:42 +00:00
try :
c . execute ( ' alter table table_settings_general add column " minimum_score " " text " ' )
except :
pass
else :
c . execute ( ' UPDATE table_settings_general SET minimum_score= " 0 " ' )
try :
c . execute ( ' alter table table_settings_general add column " use_scenename " " text " ' )
except :
pass
else :
c . execute ( ' UPDATE table_settings_general SET use_scenename= " True " ' )
2018-03-24 00:00:50 +00:00
try :
c . execute ( ' alter table table_settings_general add column " use_postprocessing " " text " ' )
except :
pass
else :
c . execute ( ' UPDATE table_settings_general SET use_postprocessing= " False " ' )
try :
c . execute ( ' alter table table_settings_general add column " postprocessing_cmd " " text " ' )
except :
pass
2018-04-09 03:45:53 +00:00
try :
c . execute ( ' alter table table_settings_sonarr add column " full_update " " text " ' )
except :
pass
else :
c . execute ( ' UPDATE table_settings_sonarr SET full_update= " Daily " ' )
2018-04-21 12:40:33 +00:00
try :
c . execute ( ' alter table table_shows add column " sortTitle " " text " ' )
except :
pass
2017-12-05 00:01:10 +00:00
# Commit change to db
db . commit ( )
2018-03-27 02:24:40 +00:00
try :
c . execute ( ' alter table table_episodes add column " scene_name " TEXT ' )
db . commit ( )
except :
pass
else :
from scheduler import execute_now
execute_now ( ' update_all_episodes ' )
2017-12-05 00:01:10 +00:00
# Close database connection
db . close ( )