From b6bcece0e9912004ed2a6b8fadf8215e52e5bf08 Mon Sep 17 00:00:00 2001 From: Halali Date: Mon, 22 Oct 2018 18:10:38 +0200 Subject: [PATCH 1/5] Trying fix update process --- bazarr/check_update.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bazarr/check_update.py b/bazarr/check_update.py index a6999c92a..4de2fe303 100644 --- a/bazarr/check_update.py +++ b/bazarr/check_update.py @@ -44,8 +44,8 @@ def check_and_apply_update(): updated() def updated(): - from scheduler import shutdown_scheduler - from main import restart + # from scheduler import shutdown_scheduler + # from main import restart conn = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) c = conn.cursor() @@ -54,7 +54,7 @@ def updated(): c.close() # Shutdown the scheduler waiting for jobs to finish - shutdown_scheduler() + # shutdown_scheduler() # Restart Bazarr - restart() \ No newline at end of file + # restart() \ No newline at end of file From 7f1bc4ac1633a4b71d7ce5f133bb196e8de8e6dd Mon Sep 17 00:00:00 2001 From: Halali Date: Mon, 22 Oct 2018 18:12:14 +0200 Subject: [PATCH 2/5] bump --- bazarr/check_update.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bazarr/check_update.py b/bazarr/check_update.py index 4de2fe303..62a906bc5 100644 --- a/bazarr/check_update.py +++ b/bazarr/check_update.py @@ -46,7 +46,7 @@ def check_and_apply_update(): def updated(): # from scheduler import shutdown_scheduler # from main import restart - + conn = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) c = conn.cursor() c.execute("UPDATE system SET updated = 1") @@ -57,4 +57,5 @@ def updated(): # shutdown_scheduler() # Restart Bazarr - # restart() \ No newline at end of file + # restart() + \ No newline at end of file From dccf6da3f9ad1bc9bbf42b60f9c601009885aa0c Mon Sep 17 00:00:00 2001 From: Halali Date: Mon, 22 Oct 2018 18:38:17 +0200 Subject: [PATCH 3/5] Revert "bump" This reverts commit 7f1bc4ac1633a4b71d7ce5f133bb196e8de8e6dd. --- bazarr/check_update.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bazarr/check_update.py b/bazarr/check_update.py index 62a906bc5..4de2fe303 100644 --- a/bazarr/check_update.py +++ b/bazarr/check_update.py @@ -46,7 +46,7 @@ def check_and_apply_update(): def updated(): # from scheduler import shutdown_scheduler # from main import restart - + conn = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) c = conn.cursor() c.execute("UPDATE system SET updated = 1") @@ -57,5 +57,4 @@ def updated(): # shutdown_scheduler() # Restart Bazarr - # restart() - \ No newline at end of file + # restart() \ No newline at end of file From 32f790960516a82c269b5933cb38f658ec849ec8 Mon Sep 17 00:00:00 2001 From: Halali Date: Mon, 22 Oct 2018 18:38:21 +0200 Subject: [PATCH 4/5] Revert "Trying fix update process" This reverts commit b6bcece0e9912004ed2a6b8fadf8215e52e5bf08. --- bazarr/check_update.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bazarr/check_update.py b/bazarr/check_update.py index 4de2fe303..a6999c92a 100644 --- a/bazarr/check_update.py +++ b/bazarr/check_update.py @@ -44,8 +44,8 @@ def check_and_apply_update(): updated() def updated(): - # from scheduler import shutdown_scheduler - # from main import restart + from scheduler import shutdown_scheduler + from main import restart conn = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) c = conn.cursor() @@ -54,7 +54,7 @@ def updated(): c.close() # Shutdown the scheduler waiting for jobs to finish - # shutdown_scheduler() + shutdown_scheduler() # Restart Bazarr - # restart() \ No newline at end of file + restart() \ No newline at end of file From 4d372670780e9fc7e7f9c618b748f2f034ba3a0b Mon Sep 17 00:00:00 2001 From: Halali Date: Mon, 22 Oct 2018 18:39:11 +0200 Subject: [PATCH 5/5] Dynamic notification providers provisioning --- bazarr/create_db.sql | 6 + bazarr/main.py | 205 ++---------------- bazarr/notifier.py | 35 +++ bazarr/update_db.py | 60 ++--- libs/apprise/Apprise.py | 50 +++++ libs/apprise/AppriseAsset.py | 22 +- libs/apprise/plugins/NotifyBase.py | 17 +- libs/apprise/plugins/NotifyBoxcar.py | 9 + libs/apprise/plugins/NotifyDiscord.py | 8 + libs/apprise/plugins/NotifyEmail.py | 16 +- libs/apprise/plugins/NotifyEmby.py | 8 + libs/apprise/plugins/NotifyFaast.py | 9 + .../plugins/NotifyGrowl/NotifyGrowl.py | 9 + libs/apprise/plugins/NotifyIFTTT.py | 15 +- libs/apprise/plugins/NotifyJSON.py | 6 + libs/apprise/plugins/NotifyJoin.py | 9 + libs/apprise/plugins/NotifyMatterMost.py | 9 + libs/apprise/plugins/NotifyProwl.py | 9 + libs/apprise/plugins/NotifyPushBullet.py | 9 + libs/apprise/plugins/NotifyPushalot.py | 9 + .../plugins/NotifyPushjet/NotifyPushjet.py | 9 + libs/apprise/plugins/NotifyPushover.py | 9 + libs/apprise/plugins/NotifyRocketChat.py | 9 + libs/apprise/plugins/NotifySlack.py | 9 + libs/apprise/plugins/NotifyStride.py | 8 + libs/apprise/plugins/NotifyTelegram.py | 8 + libs/apprise/plugins/NotifyToasty.py | 9 + .../plugins/NotifyTwitter/NotifyTwitter.py | 9 + libs/apprise/plugins/NotifyWindows.py | 6 + libs/apprise/plugins/NotifyXBMC.py | 9 + libs/apprise/plugins/NotifyXML.py | 6 + libs/version.txt | 5 +- 32 files changed, 364 insertions(+), 252 deletions(-) diff --git a/bazarr/create_db.sql b/bazarr/create_db.sql index 786b58a3e..ba67d3dd9 100644 --- a/bazarr/create_db.sql +++ b/bazarr/create_db.sql @@ -20,6 +20,12 @@ CREATE TABLE "table_settings_providers" ( `password` "text", PRIMARY KEY(`name`) ); +CREATE TABLE "table_settings_notifier" ( + `name` TEXT, + `url` TEXT, + `enabled` INTEGER, + PRIMARY KEY(`name`) +); CREATE TABLE "table_settings_languages" ( `code3` TEXT NOT NULL UNIQUE, `code2` TEXT, diff --git a/bazarr/main.py b/bazarr/main.py index 4fb89e423..075ff7019 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -17,6 +17,8 @@ import signal import sqlite3 from init import * from update_db import * +from notifier import update_notifier +update_notifier() from get_settings import get_general_settings, get_proxy_settings @@ -248,7 +250,7 @@ def wizard(): @route(base_url + 'save_wizard', method='POST') @custom_auth_basic(check_credentials) -def save_settings(): +def save_wizard(): authorize() conn = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) @@ -1323,197 +1325,16 @@ def save_settings(): with open(config_file, 'wb') as f: cfg.write(f) - settings_notifier_Boxcar_enabled = request.forms.get('settings_notifier_Boxcar_enabled') - if settings_notifier_Boxcar_enabled == 'on': - settings_notifier_Boxcar_enabled = 1 - else: - settings_notifier_Boxcar_enabled = 0 - settings_notifier_Boxcar_url = request.forms.get('settings_notifier_Boxcar_url') - c.execute("UPDATE table_settings_notifier SET enabled = ?, url = ? WHERE name = 'Boxcar'", (settings_notifier_Boxcar_enabled, settings_notifier_Boxcar_url)) - - settings_notifier_Faast_enabled = request.forms.get('settings_notifier_Faast_enabled') - if settings_notifier_Faast_enabled == 'on': - settings_notifier_Faast_enabled = 1 - else: - settings_notifier_Faast_enabled = 0 - settings_notifier_Faast_url = request.forms.get('settings_notifier_Faast_url') - c.execute("UPDATE table_settings_notifier SET enabled = ?, url = ? WHERE name = 'Faast'", (settings_notifier_Faast_enabled, settings_notifier_Faast_url)) - - settings_notifier_Growl_enabled = request.forms.get('settings_notifier_Growl_enabled') - if settings_notifier_Growl_enabled == 'on': - settings_notifier_Growl_enabled = 1 - else: - settings_notifier_Growl_enabled = 0 - settings_notifier_Growl_url = request.forms.get('settings_notifier_Growl_url') - c.execute("UPDATE table_settings_notifier SET enabled = ?, url = ? WHERE name = 'Growl'", (settings_notifier_Growl_enabled, settings_notifier_Growl_url)) - - settings_notifier_Join_enabled = request.forms.get('settings_notifier_Join_enabled') - if settings_notifier_Join_enabled == 'on': - settings_notifier_Join_enabled = 1 - else: - settings_notifier_Join_enabled = 0 - settings_notifier_Join_url = request.forms.get('settings_notifier_Join_url') - c.execute("UPDATE table_settings_notifier SET enabled = ?, url = ? WHERE name = 'Join'", (settings_notifier_Join_enabled, settings_notifier_Join_url)) - - settings_notifier_KODI_enabled = request.forms.get('settings_notifier_KODI_enabled') - if settings_notifier_KODI_enabled == 'on': - settings_notifier_KODI_enabled = 1 - else: - settings_notifier_KODI_enabled = 0 - settings_notifier_KODI_url = request.forms.get('settings_notifier_KODI_url') - c.execute("UPDATE table_settings_notifier SET enabled = ?, url = ? WHERE name = 'KODI'", (settings_notifier_KODI_enabled, settings_notifier_KODI_url)) - - settings_notifier_Mattermost_enabled = request.forms.get('settings_notifier_Mattermost_enabled') - if settings_notifier_Mattermost_enabled == 'on': - settings_notifier_Mattermost_enabled = 1 - else: - settings_notifier_Mattermost_enabled = 0 - settings_notifier_Mattermost_url = request.forms.get('settings_notifier_Mattermost_url') - c.execute("UPDATE table_settings_notifier SET enabled = ?, url = ? WHERE name = 'Mattermost'", (settings_notifier_Mattermost_enabled, settings_notifier_Mattermost_url)) - - settings_notifier_NMA_enabled = request.forms.get('settings_notifier_Notify My Android_enabled') - if settings_notifier_NMA_enabled == 'on': - settings_notifier_NMA_enabled = 1 - else: - settings_notifier_NMA_enabled = 0 - settings_notifier_NMA_url = request.forms.get('settings_notifier_Notify My Android_url') - c.execute("UPDATE table_settings_notifier SET enabled = ?, url = ? WHERE name = 'Notify My Android'", (settings_notifier_NMA_enabled, settings_notifier_NMA_url)) - - settings_notifier_Prowl_enabled = request.forms.get('settings_notifier_Prowl_enabled') - if settings_notifier_Prowl_enabled == 'on': - settings_notifier_Prowl_enabled = 1 - else: - settings_notifier_Prowl_enabled = 0 - settings_notifier_Prowl_url = request.forms.get('settings_notifier_Prowl_url') - c.execute("UPDATE table_settings_notifier SET enabled = ?, url = ? WHERE name = 'Prowl'", (settings_notifier_Prowl_enabled, settings_notifier_Prowl_url)) - - settings_notifier_Pushalot_enabled = request.forms.get('settings_notifier_Pushalot_enabled') - if settings_notifier_Pushalot_enabled == 'on': - settings_notifier_Pushalot_enabled = 1 - else: - settings_notifier_Pushalot_enabled = 0 - settings_notifier_Pushalot_url = request.forms.get('settings_notifier_Pushalot_url') - c.execute("UPDATE table_settings_notifier SET enabled = ?, url = ? WHERE name = 'Pushalot'", (settings_notifier_Pushalot_enabled, settings_notifier_Pushalot_url)) - - settings_notifier_PushBullet_enabled = request.forms.get('settings_notifier_PushBullet_enabled') - if settings_notifier_PushBullet_enabled == 'on': - settings_notifier_PushBullet_enabled = 1 - else: - settings_notifier_PushBullet_enabled = 0 - settings_notifier_PushBullet_url = request.forms.get('settings_notifier_PushBullet_url') - c.execute("UPDATE table_settings_notifier SET enabled = ?, url = ? WHERE name = 'PushBullet'", (settings_notifier_PushBullet_enabled, settings_notifier_PushBullet_url)) - - settings_notifier_Pushjet_enabled = request.forms.get('settings_notifier_Pushjet_enabled') - if settings_notifier_Pushjet_enabled == 'on': - settings_notifier_Pushjet_enabled = 1 - else: - settings_notifier_Pushjet_enabled = 0 - settings_notifier_Pushjet_url = request.forms.get('settings_notifier_Pushjet_url') - c.execute("UPDATE table_settings_notifier SET enabled = ?, url = ? WHERE name = 'Pushjet'", (settings_notifier_Pushjet_enabled, settings_notifier_Pushjet_url)) - - settings_notifier_Pushover_enabled = request.forms.get('settings_notifier_Pushover_enabled') - if settings_notifier_Pushover_enabled == 'on': - settings_notifier_Pushover_enabled = 1 - else: - settings_notifier_Pushover_enabled = 0 - settings_notifier_Pushover_url = request.forms.get('settings_notifier_Pushover_url') - c.execute("UPDATE table_settings_notifier SET enabled = ?, url = ? WHERE name = 'Pushover'", (settings_notifier_Pushover_enabled, settings_notifier_Pushover_url)) - - settings_notifier_RocketChat_enabled = request.forms.get('settings_notifier_Rocket.Chat_enabled') - if settings_notifier_RocketChat_enabled == 'on': - settings_notifier_RocketChat_enabled = 1 - else: - settings_notifier_RocketChat_enabled = 0 - settings_notifier_RocketChat_url = request.forms.get('settings_notifier_Rocket.Chat_url') - c.execute("UPDATE table_settings_notifier SET enabled = ?, url = ? WHERE name = 'Rocket.Chat'", (settings_notifier_RocketChat_enabled, settings_notifier_RocketChat_url)) - - settings_notifier_Slack_enabled = request.forms.get('settings_notifier_Slack_enabled') - if settings_notifier_Slack_enabled == 'on': - settings_notifier_Slack_enabled = 1 - else: - settings_notifier_Slack_enabled = 0 - settings_notifier_Slack_url = request.forms.get('settings_notifier_Slack_url') - c.execute("UPDATE table_settings_notifier SET enabled = ?, url = ? WHERE name = 'Slack'", (settings_notifier_Slack_enabled, settings_notifier_Slack_url)) - - settings_notifier_SuperToasty_enabled = request.forms.get('settings_notifier_Super Toasty_enabled') - if settings_notifier_SuperToasty_enabled == 'on': - settings_notifier_SuperToasty_enabled = 1 - else: - settings_notifier_SuperToasty_enabled = 0 - settings_notifier_SuperToasty_url = request.forms.get('settings_notifier_Super Toasty_url') - c.execute("UPDATE table_settings_notifier SET enabled = ?, url = ? WHERE name = 'Super Toasty'", (settings_notifier_SuperToasty_enabled, settings_notifier_SuperToasty_url)) - - settings_notifier_Telegram_enabled = request.forms.get('settings_notifier_Telegram_enabled') - if settings_notifier_Telegram_enabled == 'on': - settings_notifier_Telegram_enabled = 1 - else: - settings_notifier_Telegram_enabled = 0 - settings_notifier_Telegram_url = request.forms.get('settings_notifier_Telegram_url') - c.execute("UPDATE table_settings_notifier SET enabled = ?, url = ? WHERE name = 'Telegram'", (settings_notifier_Telegram_enabled, settings_notifier_Telegram_url)) - - settings_notifier_Twitter_enabled = request.forms.get('settings_notifier_Twitter_enabled') - if settings_notifier_Twitter_enabled == 'on': - settings_notifier_Twitter_enabled = 1 - else: - settings_notifier_Twitter_enabled = 0 - settings_notifier_Twitter_url = request.forms.get('settings_notifier_Twitter_url') - c.execute("UPDATE table_settings_notifier SET enabled = ?, url = ? WHERE name = 'Twitter'", (settings_notifier_Twitter_enabled, settings_notifier_Twitter_url)) - - settings_notifier_XBMC_enabled = request.forms.get('settings_notifier_XBMC_enabled') - if settings_notifier_XBMC_enabled == 'on': - settings_notifier_XBMC_enabled = 1 - else: - settings_notifier_XBMC_enabled = 0 - settings_notifier_XBMC_url = request.forms.get('settings_notifier_XBMC_url') - c.execute("UPDATE table_settings_notifier SET enabled = ?, url = ? WHERE name = 'XBMC'", (settings_notifier_XBMC_enabled, settings_notifier_XBMC_url)) - - settings_notifier_Discord_enabled = request.forms.get('settings_notifier_Discord_enabled') - if settings_notifier_Discord_enabled == 'on': - settings_notifier_Discord_enabled = 1 - else: - settings_notifier_Discord_enabled = 0 - settings_notifier_Discord_url = request.forms.get('settings_notifier_Discord_url') - c.execute("UPDATE table_settings_notifier SET enabled = ?, url = ? WHERE name = 'Discord'", (settings_notifier_Discord_enabled, settings_notifier_Discord_url)) - - settings_notifier_E_Mail_enabled = request.forms.get('settings_notifier_E-Mail_enabled') - if settings_notifier_E_Mail_enabled == 'on': - settings_notifier_E_Mail_enabled = 1 - else: - settings_notifier_E_Mail_enabled = 0 - settings_notifier_E_Mail_url = request.forms.get('settings_notifier_E-Mail_url') - c.execute("UPDATE table_settings_notifier SET enabled = ?, url = ? WHERE name = 'E-Mail'", (settings_notifier_E_Mail_enabled, settings_notifier_E_Mail_url)) - - settings_notifier_Emby_enabled = request.forms.get('settings_notifier_Emby_enabled') - if settings_notifier_Emby_enabled == 'on': - settings_notifier_Emby_enabled = 1 - else: - settings_notifier_Emby_enabled = 0 - settings_notifier_Emby_url = request.forms.get('settings_notifier_Emby_url') - c.execute("UPDATE table_settings_notifier SET enabled = ?, url = ? WHERE name = 'Emby'", (settings_notifier_Emby_enabled, settings_notifier_Emby_url)) - - settings_notifier_IFTTT_enabled = request.forms.get('settings_notifier_IFTTT_enabled') - if settings_notifier_IFTTT_enabled == 'on': - settings_notifier_IFTTT_enabled = 1 - else: - settings_notifier_IFTTT_enabled = 0 - settings_notifier_IFTTT_url = request.forms.get('settings_notifier_IFTTT_url') - c.execute("UPDATE table_settings_notifier SET enabled = ?, url = ? WHERE name = 'IFTTT'", (settings_notifier_IFTTT_enabled, settings_notifier_IFTTT_url)) - - settings_notifier_Stride_enabled = request.forms.get('settings_notifier_Stride_enabled') - if settings_notifier_Stride_enabled == 'on': - settings_notifier_Stride_enabled = 1 - else: - settings_notifier_Stride_enabled = 0 - settings_notifier_Stride_url = request.forms.get('settings_notifier_Stride_url') - c.execute("UPDATE table_settings_notifier SET enabled = ?, url = ? WHERE name = 'Stride'", (settings_notifier_Stride_enabled, settings_notifier_Stride_url)) - - settings_notifier_Windows_enabled = request.forms.get('settings_notifier_Windows_enabled') - if settings_notifier_Windows_enabled == 'on': - settings_notifier_Windows_enabled = 1 - else: - settings_notifier_Windows_enabled = 0 - settings_notifier_Windows_url = request.forms.get('settings_notifier_Windows_url') - c.execute("UPDATE table_settings_notifier SET enabled = ?, url = ? WHERE name = 'Windows'", (settings_notifier_Windows_enabled, settings_notifier_Windows_url)) + notifiers = c.execute("SELECT * FROM table_settings_notifier ORDER BY name").fetchall() + for notifier in notifiers: + enabled = request.forms.get('settings_notifier_' + notifier[0] + '_enabled') + if enabled == 'on': + enabled = 1 + else: + enabled = 0 + notifier_url = request.forms.get('settings_notifier_' + notifier[0] + '_url') + c.execute("UPDATE table_settings_notifier SET enabled = ?, url = ? WHERE name = ?", + (enabled, notifier_url, notifier[0])) conn.commit() c.close() diff --git a/bazarr/notifier.py b/bazarr/notifier.py index 6109e1fa7..52d7533c1 100644 --- a/bazarr/notifier.py +++ b/bazarr/notifier.py @@ -3,6 +3,41 @@ from get_argv import config_dir import apprise import os import sqlite3 +import logging + + +def update_notifier(): + # define apprise object + a = apprise.Apprise() + + # Retrieve all of the details + results = a.details() + + notifiers_new = [] + notifiers_old = [] + + conn_db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) + c_db = conn_db.cursor() + notifiers_current = c_db.execute('SELECT name FROM table_settings_notifier').fetchall() + for x in results['schemas']: + if x['service_name'] not in str(notifiers_current): + notifiers_new.append(x['service_name']) + logging.debug('Adding new notifier agent: ' + x['service_name']) + else: + notifiers_old.append(x['service_name']) + notifier_current = [i[0] for i in notifiers_current] + + notifiers_to_delete = list(set(notifier_current) - set(notifiers_old)) + + for notifier_new in notifiers_new: + c_db.execute('INSERT INTO `table_settings_notifier` (name, enabled) VALUES (?, ?);', (notifier_new, '0')) + + for notifier_to_delete in notifiers_to_delete: + c_db.execute('DELETE FROM `table_settings_notifier` WHERE name=?', (notifier_to_delete,)) + + conn_db.commit() + c_db.close() + def get_notifier_providers(): conn_db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) diff --git a/bazarr/update_db.py b/bazarr/update_db.py index 9c77a56f9..91b9ec5e6 100644 --- a/bazarr/update_db.py +++ b/bazarr/update_db.py @@ -16,69 +16,43 @@ if os.path.exists(os.path.join(config_dir, 'db/bazarr.db')) == True: pass else: c.execute('UPDATE table_settings_providers SET username=""') - + try: c.execute('alter table table_settings_providers add column "password" "text"') except: pass else: c.execute('UPDATE table_settings_providers SET password=""') - + try: c.execute('alter table table_shows add column "audio_language" "text"') except: pass - - 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')) - + try: c.execute('alter table table_shows add column "sortTitle" "text"') except: pass - - try: - c.execute('CREATE TABLE "table_movies" ( `tmdbId` TEXT NOT NULL UNIQUE, `title` TEXT NOT NULL, `path` TEXT NOT NULL UNIQUE, `languages` TEXT, `subtitles` TEXT, `missing_subtitles` TEXT, `hearing_impaired` TEXT, `radarrId` INTEGER NOT NULL UNIQUE, `overview` TEXT, `poster` TEXT, `fanart` TEXT, "audio_language" "text", `sceneName` TEXT, PRIMARY KEY(`tmdbId`) )') - except: - pass - - try: - c.execute('CREATE TABLE "table_history_movie" ( `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE, `action` INTEGER NOT NULL, `radarrId` INTEGER NOT NULL, `timestamp` INTEGER NOT NULL, `description` TEXT NOT NULL )') - except: - pass - + try: - c.execute('DELETE FROM table_settings_notifier WHERE rowid > 24') #Modify this if we add more notification provider - rows = c.execute('SELECT name FROM table_settings_notifier WHERE name = "Discord"').fetchall() + rows = c.execute('SELECT name FROM table_settings_notifier WHERE name = "Kodi/XBMC"').fetchall() if len(rows) == 0: - providers = ['Discord', 'E-Mail', 'Emby', 'IFTTT', 'Stride', 'Windows'] - for provider in providers: - c.execute('INSERT INTO `table_settings_notifier` (name, enabled) VALUES (?, ?);', (provider, '0')) - except: - pass - - try: - c.execute('CREATE TABLE `system` ( `configured` TEXT, `updated` TEXT)') - c.execute('INSERT INTO `system` (configured, updated) VALUES (?, ?);', ('0', '0')) + providers = [['KODI', 'Kodi/XBMC'], ['Windows', 'Windows Notification'], ['Super Toasty', 'Toasty'], + ['PushBullet', 'Pushbullet'], ['Mattermost', 'MatterMost']] + for provider_old, provider_new in providers: + c.execute('UPDATE table_settings_notifier SET name=? WHERE name=?', (provider_new, provider_old)) except: pass - + try: c.execute('alter table table_movies add column "failedAttempts" "text"') c.execute('alter table table_episodes add column "failedAttempts" "text"') except: pass - - + # Commit change to db db.commit() - + try: c.execute('alter table table_episodes add column "scene_name" TEXT') db.commit() @@ -87,13 +61,13 @@ if os.path.exists(os.path.join(config_dir, 'db/bazarr.db')) == True: else: from scheduler import execute_now from get_settings import get_general_settings + integration = get_general_settings() if integration[12] is True: execute_now('sync_episodes') if integration[13] is True: execute_now('update_movies') - - + try: c.execute('alter table table_episodes add column "monitored" TEXT') db.commit() @@ -102,10 +76,11 @@ if os.path.exists(os.path.join(config_dir, 'db/bazarr.db')) == True: else: from scheduler import execute_now from get_settings import get_general_settings + integration = get_general_settings() if integration[12] is True: execute_now('sync_episodes') - + try: c.execute('alter table table_movies add column "monitored" TEXT') db.commit() @@ -114,8 +89,9 @@ if os.path.exists(os.path.join(config_dir, 'db/bazarr.db')) == True: else: from scheduler import execute_now from get_settings import get_general_settings + integration = get_general_settings() if integration[13] is True: execute_now('update_movies') - + db.close() \ No newline at end of file diff --git a/libs/apprise/Apprise.py b/libs/apprise/Apprise.py index 8512ea145..73adf6299 100644 --- a/libs/apprise/Apprise.py +++ b/libs/apprise/Apprise.py @@ -32,6 +32,7 @@ from .AppriseAsset import AppriseAsset from . import NotifyBase from . import plugins +from . import __version__ logger = logging.getLogger(__name__) @@ -54,6 +55,9 @@ def __load_matrix(): # Get our plugin plugin = getattr(plugins, entry) + if not hasattr(plugin, 'app_id'): # pragma: no branch + # Filter out non-notification modules + continue # Load protocol(s) if defined proto = getattr(plugin, 'protocol', None) @@ -277,6 +281,52 @@ class Apprise(object): return status + def details(self): + """ + Returns the details associated with the Apprise object + + """ + + # general object returned + response = { + # Defines the current version of Apprise + 'version': __version__, + # Lists all of the currently supported Notifications + 'schemas': [], + # Includes the configured asset details + 'asset': self.asset.details(), + } + + # to add it's mapping to our hash table + for entry in sorted(dir(plugins)): + + # Get our plugin + plugin = getattr(plugins, entry) + if not hasattr(plugin, 'app_id'): # pragma: no branch + # Filter out non-notification modules + continue + + # Standard protocol(s) should be None or a tuple + protocols = getattr(plugin, 'protocol', None) + if compat_is_basestring(protocols): + protocols = (protocols, ) + + # Secure protocol(s) should be None or a tuple + secure_protocols = getattr(plugin, 'secure_protocol', None) + if compat_is_basestring(secure_protocols): + secure_protocols = (secure_protocols, ) + + # Build our response object + response['schemas'].append({ + 'service_name': getattr(plugin, 'service_name', None), + 'service_url': getattr(plugin, 'service_url', None), + 'setup_url': getattr(plugin, 'setup_url', None), + 'protocols': protocols, + 'secure_protocols': secure_protocols, + }) + + return response + def __len__(self): """ Returns the number of servers loaded diff --git a/libs/apprise/AppriseAsset.py b/libs/apprise/AppriseAsset.py index 5bbba2a9b..ee845f726 100644 --- a/libs/apprise/AppriseAsset.py +++ b/libs/apprise/AppriseAsset.py @@ -62,12 +62,13 @@ class AppriseAsset(object): # Image URL Mask image_url_mask = \ - 'http://nuxref.com/apprise/themes/{THEME}/' \ - 'apprise-{TYPE}-{XY}{EXTENSION}' + 'https://github.com/caronc/apprise/raw/master/apprise/assets/' \ + 'themes/{THEME}/apprise-{TYPE}-{XY}{EXTENSION}' # Application Logo image_url_logo = \ - 'http://nuxref.com/apprise/themes/{THEME}/apprise-logo.png' + 'https://github.com/caronc/apprise/raw/master/apprise/assets/' \ + 'themes/{THEME}/apprise-logo.png' # Image Path Mask image_path_mask = abspath(join( @@ -216,6 +217,21 @@ class AppriseAsset(object): return None + def details(self): + """ + Returns the details associated with the AppriseAsset object + + """ + return { + 'app_id': self.app_id, + 'app_desc': self.app_desc, + 'default_extension': self.default_extension, + 'theme': self.theme, + 'image_path_mask': self.image_url_mask, + 'image_url_mask': self.image_url_mask, + 'image_url_logo': self.image_url_logo, + } + @staticmethod def hex_to_rgb(value): """ diff --git a/libs/apprise/plugins/NotifyBase.py b/libs/apprise/plugins/NotifyBase.py index 9f0284999..0a8a3687b 100644 --- a/libs/apprise/plugins/NotifyBase.py +++ b/libs/apprise/plugins/NotifyBase.py @@ -34,7 +34,6 @@ except ImportError: from ..utils import parse_url from ..utils import parse_bool from ..utils import is_hostname -from ..common import NOTIFY_IMAGE_SIZES from ..common import NOTIFY_TYPES from ..common import NotifyFormat from ..common import NOTIFY_FORMATS @@ -70,7 +69,8 @@ PATHSPLIT_LIST_DELIM = re.compile(r'[ \t\r\n,\\/]+') # Regular expression retrieved from: # http://www.regular-expressions.info/email.html IS_EMAIL_RE = re.compile( - r"(?P[a-z0-9$%+=_~-]+" + r"((?P