1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-04 15:12:23 -05:00

Update to provide option to disable SSL certificate verification

This commit is contained in:
M. Adam Kendall 2015-01-27 14:26:53 -05:00
parent 3c9adc4590
commit 94d17c286e
7 changed files with 66 additions and 46 deletions

View File

@ -12,9 +12,9 @@
<script type="text/javascript" src="$sbRoot/js/configNotifications.js?$sbPID"></script>
<script type="text/javascript" src="$sbRoot/js/config.js?$sbPID"></script>
#if $varExists('header')
#if $varExists('header')
<h1 class="header">$header</h1>
#else
#else
<h1 class="title">$title</h1>
#end if
@ -30,7 +30,7 @@
<div id="tabs-1">
<div class="component-group">
<div class="component-group-desc">
<img class="notifier-icon" src="$sbRoot/images/notifiers/kodi.png" alt="" title="KODI" />
<h3><a href="<%= anon_url('http://kodi.tv/') %>" rel="noreferrer" onclick="window.open(this.href, '_blank'); return false;">KODI</a></h3>
@ -110,7 +110,7 @@
<p>only send library updates to the first active host ?</p>
</span>
</label>
</div>
</div>
<div class="field-pair">
<label for="kodi_host">
<span class="component-title">KODI IP:Port</span>
@ -123,7 +123,7 @@
<label>
<span class="component-title">&nbsp;</span>
<span class="component-desc">(multiple host strings must be separated by commas)</span>
</label>
</label>
</div>
<div class="field-pair">
<label for="kodi_username">
@ -151,7 +151,7 @@
</div><!-- /content_use_kodi //-->
</fieldset>
</div><!-- /kodi component-group //-->
@ -232,7 +232,7 @@
<label>
<span class="component-title">&nbsp;</span>
<span class="component-desc">(multiple host strings must be separated by commas)</span>
</label>
</label>
</div>
<div class="field-pair">
<label for="plex_username">
@ -365,9 +365,9 @@
</label>
<label for="NMJV2_DBLOC_B">
<input type="radio" NAME="nmjv2_dbloc" VALUE="network" id="NMJV2_DBLOC_B" #if $sickbeard.NMJv2_DBLOC=="network" then "checked=\"checked\"" else ""#/>PCH Network Media
</label>
</label>
</span>
</div>
</div>
<div class="field-pair">
<label for="NMJv2db_instance">
<span class="component-title">Database instance</span>
@ -415,7 +415,7 @@
</fieldset>
</div><!-- /nmjv2 component-group //-->
<div class="component-group">
<div class="component-group-desc">
@ -430,7 +430,7 @@
<label for="use_synoindex">
<span class="component-title">Enable</span>
<span class="component-desc">
<input type="checkbox" class="enabler" name="use_synoindex" id="use_synoindex" #if $sickbeard.USE_SYNOINDEX then "checked=\"checked\"" else ""# />
<input type="checkbox" class="enabler" name="use_synoindex" id="use_synoindex" #if $sickbeard.USE_SYNOINDEX then "checked=\"checked\"" else ""# />
<p>should SickRage send Synology notifications ?</p>
</span>
</label>
@ -446,8 +446,8 @@
</fieldset>
</div><!-- /synoindex component-group //-->
<div class="component-group">
<div class="component-group-desc">
<img class="notifier-icon" src="$sbRoot/images/notifiers/synologynotifier.png" alt="" title="Synology Indexer" />
@ -563,7 +563,7 @@
</div>
<div id="tabs-2">
<div class="component-group">
<div class="component-group-desc">
@ -576,7 +576,7 @@
<label for="use_growl">
<span class="component-title">Enable</span>
<span class="component-desc">
<input type="checkbox" class="enabler" name="use_growl" id="use_growl" #if $sickbeard.USE_GROWL then "checked=\"checked\"" else ""# />
<input type="checkbox" class="enabler" name="use_growl" id="use_growl" #if $sickbeard.USE_GROWL then "checked=\"checked\"" else ""# />
<p>should SickRage send Growl notifications ?</p>
</span>
</label>
@ -587,7 +587,7 @@
<label for="growl_notify_onsnatch">
<span class="component-title">Notify on snatch</span>
<span class="component-desc">
<input type="checkbox" name="growl_notify_onsnatch" id="growl_notify_onsnatch" #if $sickbeard.GROWL_NOTIFY_ONSNATCH then "checked=\"checked\"" else ""# />
<input type="checkbox" name="growl_notify_onsnatch" id="growl_notify_onsnatch" #if $sickbeard.GROWL_NOTIFY_ONSNATCH then "checked=\"checked\"" else ""# />
<p>send a notification when a download starts ?</p>
</span>
</label>
@ -1203,7 +1203,7 @@
<label for="use_freemobile">
<span class="component-title">Enable</span>
<span class="component-desc">
<input type="checkbox" class="enabler" name="use_freemobile" id="use_freemobile" #if $sickbeard.USE_FREEMOBILE then "checked=\"checked\"" else ""# />
<input type="checkbox" class="enabler" name="use_freemobile" id="use_freemobile" #if $sickbeard.USE_FREEMOBILE then "checked=\"checked\"" else ""# />
<p>should SickRage send SMS notifications ?</p>
</span>
</label>
@ -1214,7 +1214,7 @@
<label for="freemobile_notify_onsnatch">
<span class="component-title">Notify on snatch</span>
<span class="component-desc">
<input type="checkbox" name="freemobile_notify_onsnatch" id="freemobile_notify_onsnatch" #if $sickbeard.FREEMOBILE_NOTIFY_ONSNATCH then "checked=\"checked\"" else ""# />
<input type="checkbox" name="freemobile_notify_onsnatch" id="freemobile_notify_onsnatch" #if $sickbeard.FREEMOBILE_NOTIFY_ONSNATCH then "checked=\"checked\"" else ""# />
<p>send a SMS when a download starts ?</p>
</span>
</label>
@ -1266,7 +1266,7 @@
</div><!-- /freemobile component-group //-->
</div>
<div id="tabs-3">
<div class="component-group">
<div class="component-group-desc">
@ -1390,6 +1390,15 @@
<span class="component-desc">password of your Trakt account.</span>
</label>
</div>
<div class="field-pair">
<label for="trakt_disable_ssl_verify">
<span class="component-title">Disable SSL Verification:</span>
<span class="component-desc">
<input type="checkbox" class="enabler" name="trakt_disable_ssl_verify" id="trakt_disable_ssl_verify" #if $sickbeard.TRAKT_DISABLE_SSL_VERIFY then "checked=\"checked\"" else ""# />
<p>Disable SSL certificate verification on systems with broken SSL implementations, like the QNAP NAS.</p>
</span>
</label>
</div>
<div class="field-pair">
<label for="trakt_default_indexer">
<span class="component-title">Default indexer:</span>
@ -1434,7 +1443,7 @@
<span class="component-title">&nbsp;</span>
<span class="component-desc">method in which to download episodes for new show's.</span>
</label>
</div>
</div>
<div class="field-pair">
<label for="trakt_remove_watchlist">
<span class="component-title">Remove episode:</span>
@ -1443,8 +1452,8 @@
<p>remove an episode from your watchlist after it is downloaded.</p>
</span>
</label>
</div>
<div class="field-pair">
</div>
<div class="field-pair">
<label for="trakt_remove_serieslist">
<span class="component-title">Remove series:</span>
<span class="component-desc">

View File

@ -36,7 +36,7 @@ $(document).ready(function(){
$('#testProwl').prop('disabled', false);
});
});
$('#testKODI').click(function () {
var kodi_host = $.trim($('#kodi_host').val());
var kodi_username = $.trim($('#kodi_username').val());
@ -91,7 +91,7 @@ $(document).ready(function(){
$('#testBoxcar').prop('disabled', false);
});
});
$('#testBoxcar2').click(function () {
var boxcar2_accesstoken = $.trim($('#boxcar2_accesstoken').val());
if (!boxcar2_accesstoken) {
@ -141,7 +141,7 @@ $(document).ready(function(){
$.get(sbRoot + '/home/testLibnotify',
function (data) { $('#testLibnotify-result').html(data); });
});
$('#twitterStep1').click(function() {
$('#testTwitter-result').html(loading);
$.get(sbRoot + '/home/twitterStep1', function (data) {window.open(data); })
@ -174,7 +174,7 @@ $(document).ready(function(){
}
$('#testNMJ-result').html(loading);
var nmj_host = $('#nmj_host').val();
$.get(sbRoot + '/home/settingsNMJ', {'host': nmj_host},
function (data) {
if (data === null) {
@ -236,7 +236,7 @@ $(document).ready(function(){
}
var nmjv2_dbinstance=$('#NMJv2db_instance').val();
$.get(sbRoot + '/home/settingsNMJv2', {'host': nmjv2_host,'dbloc': nmjv2_dbloc,'instance': nmjv2_dbinstance},
$.get(sbRoot + '/home/settingsNMJv2', {'host': nmjv2_host,'dbloc': nmjv2_dbloc,'instance': nmjv2_dbinstance},
function (data){
if (data == null) {
$('#nmjv2_database').removeAttr('readonly');
@ -244,7 +244,7 @@ $(document).ready(function(){
var JSONData = $.parseJSON(data);
$('#testNMJv2-result').html(JSONData.message);
$('#nmjv2_database').val(JSONData.database);
if (JSONData.database)
$('#nmjv2_database').attr('readonly', true);
else
@ -268,7 +268,7 @@ $(document).ready(function(){
$('#testNMJv2').prop('disabled', false);
});
});
$('#testFreeMobile').click(function () {
var freemobile_id = $.trim($('#freemobile_id').val());
var freemobile_apikey = $.trim($('#freemobile_apikey').val());
@ -299,6 +299,7 @@ $(document).ready(function(){
$('#testTrakt').click(function () {
var trakt_username = $.trim($('#trakt_username').val());
var trakt_password = $.trim($('#trakt_password').val());
var trakt_disable_ssl_verify = $('#trakt_disable_ssl_verify').is(':checked');
if (!trakt_username || !trakt_password) {
$('#testTrakt-result').html('Please fill out the necessary fields above.');
if (!trakt_username) {
@ -316,7 +317,7 @@ $(document).ready(function(){
$('#trakt_username,#trakt_password').removeClass('warning');
$(this).prop('disabled', true);
$('#testTrakt-result').html(loading);
$.get(sbRoot + '/home/testTrakt', {'username': trakt_username, 'password': trakt_password})
$.get(sbRoot + '/home/testTrakt', {'username': trakt_username, 'password': trakt_password, 'disable_ssl': trakt_disable_ssl_verify})
.done(function (data) {
$('#testTrakt-result').html(data);
$('#testTrakt').prop('disabled', false);
@ -416,7 +417,7 @@ $(document).ready(function(){
if(msg){
$('#testPushbullet-result').html(loading);
}
var pushbullet_api = $("#pushbullet_api").val();
if(!pushbullet_api) {
@ -454,7 +455,7 @@ $(document).ready(function(){
$('#getPushbulletDevices').click(function(){
get_pushbullet_devices("Device list updated. Please choose a device to push to.");
});
// we have to call this function on dom ready to create the devices select
get_pushbullet_devices();

View File

@ -5,9 +5,10 @@ from sickbeard import logger
from exceptions import traktException, traktAuthException, traktServerBusy
class TraktAPI():
def __init__(self, apikey, username=None, password=None, timeout=5):
def __init__(self, apikey, username=None, password=None, disable_ssl_verify=False, timeout=30):
self.username = username
self.password = password
self.verify = not disable_ssl_verify
self.timeout = timeout
self.api_url = 'https://api.trakt.tv/'
self.headers = {
@ -24,8 +25,8 @@ class TraktAPI():
'password': self.password
}
try:
resp = requests.request('POST', self.api_url+"auth/login",
headers=self.headers, data=json.dumps(data))
resp = requests.request('POST', self.api_url+"auth/login", headers=self.headers,
data=json.dumps(data), timeout=self.timeout, verify=self.verify)
resp.raise_for_status()
resp = resp.json()
except (requests.HTTPError, requests.ConnectionError) as e:
@ -59,7 +60,8 @@ class TraktAPI():
# request the URL from trakt and parse the result as json
try:
resp = requests.request(method, url, headers=headers, data=json.dumps(data) if data else [])
resp = requests.request(method, url, headers=headers, timeout=self.timeout,
data=json.dumps(data) if data else [], verify=self.verify)
# check for http errors and raise if any are present
resp.raise_for_status()

View File

@ -400,6 +400,7 @@ TRAKT_START_PAUSED = False
TRAKT_USE_RECOMMENDED = False
TRAKT_SYNC = False
TRAKT_DEFAULT_INDEXER = None
TRAKT_DISABLE_SSL_VERIFY = False
USE_PYTIVO = False
PYTIVO_NOTIFY_ONSNATCH = False
@ -501,7 +502,7 @@ def initialize(consoleLogging=True):
TORRENT_USERNAME, TORRENT_PASSWORD, TORRENT_HOST, TORRENT_PATH, TORRENT_SEED_TIME, TORRENT_PAUSED, TORRENT_HIGH_BANDWIDTH, TORRENT_LABEL, TORRENT_LABEL_ANIME, TORRENT_VERIFY_CERT, \
USE_KODI, KODI_ALWAYS_ON, KODI_NOTIFY_ONSNATCH, KODI_NOTIFY_ONDOWNLOAD, KODI_NOTIFY_ONSUBTITLEDOWNLOAD, KODI_UPDATE_FULL, KODI_UPDATE_ONLYFIRST, \
KODI_UPDATE_LIBRARY, KODI_HOST, KODI_USERNAME, KODI_PASSWORD, BACKLOG_FREQUENCY, \
USE_TRAKT, TRAKT_USERNAME, TRAKT_PASSWORD, TRAKT_REMOVE_WATCHLIST, TRAKT_USE_WATCHLIST, TRAKT_METHOD_ADD, TRAKT_START_PAUSED, traktCheckerScheduler, TRAKT_USE_RECOMMENDED, TRAKT_SYNC, TRAKT_DEFAULT_INDEXER, TRAKT_REMOVE_SERIESLIST, \
USE_TRAKT, TRAKT_USERNAME, TRAKT_PASSWORD, TRAKT_REMOVE_WATCHLIST, TRAKT_USE_WATCHLIST, TRAKT_METHOD_ADD, TRAKT_START_PAUSED, traktCheckerScheduler, TRAKT_USE_RECOMMENDED, TRAKT_SYNC, TRAKT_DEFAULT_INDEXER, TRAKT_REMOVE_SERIESLIST, TRAKT_DISABLE_SSL_VERIFY, \
USE_PLEX, PLEX_NOTIFY_ONSNATCH, PLEX_NOTIFY_ONDOWNLOAD, PLEX_NOTIFY_ONSUBTITLEDOWNLOAD, PLEX_UPDATE_LIBRARY, \
PLEX_SERVER_HOST, PLEX_HOST, PLEX_USERNAME, PLEX_PASSWORD, DEFAULT_BACKLOG_FREQUENCY, MIN_BACKLOG_FREQUENCY, BACKLOG_STARTUP, SKIP_REMOVED_FILES, \
showUpdateScheduler, __INITIALIZED__, LAUNCH_BROWSER, UPDATE_SHOWS_ON_START, TRASH_REMOVE_SHOW, TRASH_ROTATE_LOGS, SORT_ARTICLE, showList, loadingShowList, \
@ -917,6 +918,7 @@ def initialize(consoleLogging=True):
TRAKT_USE_RECOMMENDED = bool(check_setting_int(CFG, 'Trakt', 'trakt_use_recommended', 0))
TRAKT_SYNC = bool(check_setting_int(CFG, 'Trakt', 'trakt_sync', 0))
TRAKT_DEFAULT_INDEXER = check_setting_int(CFG, 'Trakt', 'trakt_default_indexer', 1)
TRAKT_DISABLE_SSL_VERIFY = bool(check_setting_int(CFG, 'Trakt', 'trakt_disable_ssl_verify', 0))
CheckSection(CFG, 'pyTivo')
USE_PYTIVO = bool(check_setting_int(CFG, 'pyTivo', 'use_pytivo', 0))
@ -1787,6 +1789,7 @@ def save_config():
new_config['Trakt']['trakt_use_recommended'] = int(TRAKT_USE_RECOMMENDED)
new_config['Trakt']['trakt_sync'] = int(TRAKT_SYNC)
new_config['Trakt']['trakt_default_indexer'] = int(TRAKT_DEFAULT_INDEXER)
new_config['Trakt']['trakt_disable_ssl_verify'] = int(TRAKT_DISABLE_SSL_VERIFY)
new_config['pyTivo'] = {}
new_config['pyTivo']['use_pytivo'] = int(USE_PYTIVO)

View File

@ -47,7 +47,7 @@ class TraktNotifier:
"""
trakt_id = sickbeard.indexerApi(ep_obj.show.indexer).config['trakt_id']
trakt_api = TraktAPI(sickbeard.TRAKT_API_KEY, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD)
trakt_api = TraktAPI(sickbeard.TRAKT_API_KEY, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD, TRAKT_DISABLE_SSL_VERIFY)
if sickbeard.USE_TRAKT:
try:
@ -105,7 +105,7 @@ class TraktNotifier:
except (traktException, traktAuthException, traktServerBusy) as e:
logger.log(u"Could not connect to Trakt service: %s" % ex(e), logger.WARNING)
def test_notify(self, username, password):
def test_notify(self, username, password, disable_ssl):
"""
Sends a test notification to trakt with the given authentication info and returns a boolean
representing success.
@ -117,7 +117,7 @@ class TraktNotifier:
Returns: True if the request succeeded, False otherwise
"""
try:
trakt_api = TraktAPI(sickbeard.TRAKT_API_KEY, username, password)
trakt_api = TraktAPI(sickbeard.TRAKT_API_KEY, username, password, disable_ssl)
trakt_api.validateAccount()
return "Test notice sent successfully to Trakt"
except (traktException, traktAuthException, traktServerBusy) as e:

View File

@ -37,7 +37,7 @@ class TraktChecker():
def __init__(self):
self.todoWanted = []
self.trakt_api = TraktAPI(sickbeard.TRAKT_API_KEY, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD)
self.trakt_api = TraktAPI(sickbeard.TRAKT_API_KEY, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD, sickbeard.TRAKT_DISABLE_SSL_VERIFY)
def run(self, force=False):
try:

View File

@ -928,9 +928,13 @@ class Home(WebRoot):
"dbloc": dbloc}
def testTrakt(self, username=None, password=None):
def testTrakt(self, username=None, password=None, disable_ssl=None):
# self.set_header('Cache-Control', 'max-age=0,no-cache,no-store')
return notifiers.trakt_notifier.test_notify(username, password)
if disable_ssl == 'true':
disable_ssl = True
else:
disable_ssl = False
return notifiers.trakt_notifier.test_notify(username, password, disable_ssl)
def loadShowNotifyLists(self):
@ -2218,7 +2222,7 @@ class HomeAddShows(Home):
logger.log(u"Getting recommended shows from Trakt.tv", logger.DEBUG)
trakt_api = TraktAPI(sickbeard.TRAKT_API_KEY, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD)
trakt_api = TraktAPI(sickbeard.TRAKT_API_KEY, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD, sickbeard.TRAKT_DISABLE_SSL_VERIFY)
try:
recommendedlist = trakt_api.traktRequest("recommendations/shows?extended=full,images")
@ -2274,7 +2278,7 @@ class HomeAddShows(Home):
t.trending_shows = []
trakt_api = TraktAPI(sickbeard.TRAKT_API_KEY, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD)
trakt_api = TraktAPI(sickbeard.TRAKT_API_KEY, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD, sickbeard.TRAKT_DISABLE_SSL_VERIFY)
try:
shows = trakt_api.traktRequest("shows/trending?limit=50&extended=full,images") or []
@ -4380,7 +4384,7 @@ class ConfigNotifications(Config):
use_trakt=None, trakt_username=None, trakt_password=None,
trakt_remove_watchlist=None, trakt_use_watchlist=None, trakt_method_add=None,
trakt_start_paused=None, trakt_use_recommended=None, trakt_sync=None,
trakt_default_indexer=None, trakt_remove_serieslist=None,
trakt_default_indexer=None, trakt_remove_serieslist=None, trakt_disable_ssl_verify=None,
use_synologynotifier=None, synologynotifier_notify_onsnatch=None,
synologynotifier_notify_ondownload=None, synologynotifier_notify_onsubtitledownload=None,
use_pytivo=None, pytivo_notify_onsnatch=None, pytivo_notify_ondownload=None,
@ -4501,6 +4505,7 @@ class ConfigNotifications(Config):
sickbeard.TRAKT_USE_RECOMMENDED = config.checkbox_to_value(trakt_use_recommended)
sickbeard.TRAKT_SYNC = config.checkbox_to_value(trakt_sync)
sickbeard.TRAKT_DEFAULT_INDEXER = int(trakt_default_indexer)
sickbeard.TRAKT_DISABLE_SSL_VERIFY = config.checkbox_to_value(trakt_disable_ssl_verify)
if sickbeard.USE_TRAKT:
sickbeard.traktCheckerScheduler.silent = False