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

Merge pull request #1269 from LinuxBozo/trakt-fixes

Trakt 2.0 API fixes
This commit is contained in:
Alexandre Beloin 2015-02-15 18:20:23 -05:00
commit 225b1171da
6 changed files with 35 additions and 22 deletions

View File

@ -1375,30 +1375,39 @@
<span class="component-title">Trakt username</span> <span class="component-title">Trakt username</span>
<input type="text" name="trakt_username" id="trakt_username" value="$sickbeard.TRAKT_USERNAME" class="form-control input-sm input250" /> <input type="text" name="trakt_username" id="trakt_username" value="$sickbeard.TRAKT_USERNAME" class="form-control input-sm input250" />
</label> </label>
<label> <p>
<span class="component-title">&nbsp;</span>
<span class="component-desc">username of your Trakt account.</span> <span class="component-desc">username of your Trakt account.</span>
</label> </p>
</div> </div>
<div class="field-pair"> <div class="field-pair">
<label for="trakt_password"> <label for="trakt_password">
<span class="component-title">Trakt password</span> <span class="component-title">Trakt password</span>
<input type="password" name="trakt_password" id="trakt_password" value="$sickbeard.TRAKT_PASSWORD" class="form-control input-sm input250" /> <input type="password" name="trakt_password" id="trakt_password" value="$sickbeard.TRAKT_PASSWORD" class="form-control input-sm input250" />
</label> </label>
<label> <p>
<span class="component-title">&nbsp;</span>
<span class="component-desc">password of your Trakt account.</span> <span class="component-desc">password of your Trakt account.</span>
</label> </p>
</div> </div>
<div class="field-pair"> <div class="field-pair">
<label for="trakt_disable_ssl_verify"> <label for="trakt_disable_ssl_verify">
<span class="component-title">Disable SSL Verification:</span> <span class="component-title">Disable SSL Verification:</span>
<span class="component-desc"> <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 ""# /> <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> <p>Disable SSL certificate verification for broken SSL installs (like QNAP NAS)</p>
</span> </span>
</label> </label>
</div> </div>
<div class="field-pair">
<label for="trakt_timeout">
<span class="component-title">API Timeout:</span>
<input type="text" name="trakt_timeout" id="trakt_timeout" value="$sickbeard.TRAKT_TIMEOUT" class="form-control input-sm input75" />
</label>
<p>
<span class="component-desc">
Seconds to wait for Trakt API to respond. (Use 0 to wait forever)
</span>
</p>
</div>
<div class="field-pair"> <div class="field-pair">
<label for="trakt_default_indexer"> <label for="trakt_default_indexer">
<span class="component-title">Default indexer:</span> <span class="component-title">Default indexer:</span>

View File

@ -9,7 +9,7 @@ class TraktAPI():
self.username = username self.username = username
self.password = password self.password = password
self.verify = not disable_ssl_verify self.verify = not disable_ssl_verify
self.timeout = timeout self.timeout = timeout if timeout else None
self.api_url = 'https://api.trakt.tv/' self.api_url = 'https://api.trakt.tv/'
self.headers = { self.headers = {
'Content-Type': 'application/json', 'Content-Type': 'application/json',

View File

@ -403,6 +403,7 @@ TRAKT_USE_RECOMMENDED = False
TRAKT_SYNC = False TRAKT_SYNC = False
TRAKT_DEFAULT_INDEXER = None TRAKT_DEFAULT_INDEXER = None
TRAKT_DISABLE_SSL_VERIFY = False TRAKT_DISABLE_SSL_VERIFY = False
TRAKT_TIMEOUT = 30
USE_PYTIVO = False USE_PYTIVO = False
PYTIVO_NOTIFY_ONSNATCH = False PYTIVO_NOTIFY_ONSNATCH = False
@ -505,7 +506,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, TORRENT_RPCURL, \ TORRENT_USERNAME, TORRENT_PASSWORD, TORRENT_HOST, TORRENT_PATH, TORRENT_SEED_TIME, TORRENT_PAUSED, TORRENT_HIGH_BANDWIDTH, TORRENT_LABEL, TORRENT_LABEL_ANIME, TORRENT_VERIFY_CERT, TORRENT_RPCURL, \
USE_KODI, KODI_ALWAYS_ON, KODI_NOTIFY_ONSNATCH, KODI_NOTIFY_ONDOWNLOAD, KODI_NOTIFY_ONSUBTITLEDOWNLOAD, KODI_UPDATE_FULL, KODI_UPDATE_ONLYFIRST, \ 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, \ 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, TRAKT_DISABLE_SSL_VERIFY, \ 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, TRAKT_TIMEOUT, \
USE_PLEX, PLEX_NOTIFY_ONSNATCH, PLEX_NOTIFY_ONDOWNLOAD, PLEX_NOTIFY_ONSUBTITLEDOWNLOAD, PLEX_UPDATE_LIBRARY, \ 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, \ 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, \ showUpdateScheduler, __INITIALIZED__, LAUNCH_BROWSER, UPDATE_SHOWS_ON_START, TRASH_REMOVE_SHOW, TRASH_ROTATE_LOGS, SORT_ARTICLE, showList, loadingShowList, \
@ -926,6 +927,7 @@ def initialize(consoleLogging=True):
TRAKT_SYNC = bool(check_setting_int(CFG, 'Trakt', 'trakt_sync', 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_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)) TRAKT_DISABLE_SSL_VERIFY = bool(check_setting_int(CFG, 'Trakt', 'trakt_disable_ssl_verify', 0))
TRAKT_TIMEOUT = check_setting_int(CFG, 'Trakt', 'trakt_timeout', 30)
CheckSection(CFG, 'pyTivo') CheckSection(CFG, 'pyTivo')
USE_PYTIVO = bool(check_setting_int(CFG, 'pyTivo', 'use_pytivo', 0)) USE_PYTIVO = bool(check_setting_int(CFG, 'pyTivo', 'use_pytivo', 0))
@ -1800,6 +1802,7 @@ def save_config():
new_config['Trakt']['trakt_sync'] = int(TRAKT_SYNC) new_config['Trakt']['trakt_sync'] = int(TRAKT_SYNC)
new_config['Trakt']['trakt_default_indexer'] = int(TRAKT_DEFAULT_INDEXER) new_config['Trakt']['trakt_default_indexer'] = int(TRAKT_DEFAULT_INDEXER)
new_config['Trakt']['trakt_disable_ssl_verify'] = int(TRAKT_DISABLE_SSL_VERIFY) new_config['Trakt']['trakt_disable_ssl_verify'] = int(TRAKT_DISABLE_SSL_VERIFY)
new_config['Trakt']['trakt_timeout'] = int(TRAKT_TIMEOUT)
new_config['pyTivo'] = {} new_config['pyTivo'] = {}
new_config['pyTivo']['use_pytivo'] = int(USE_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_id = sickbeard.indexerApi(ep_obj.show.indexer).config['trakt_id']
trakt_api = TraktAPI(sickbeard.TRAKT_API_KEY, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD, sickbeard.TRAKT_DISABLE_SSL_VERIFY) trakt_api = TraktAPI(sickbeard.TRAKT_API_KEY, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD, sickbeard.TRAKT_DISABLE_SSL_VERIFY, sickbeard.TRAKT_TIMEOUT)
if sickbeard.USE_TRAKT: if sickbeard.USE_TRAKT:
try: try:
@ -117,7 +117,7 @@ class TraktNotifier:
Returns: True if the request succeeded, False otherwise Returns: True if the request succeeded, False otherwise
""" """
try: try:
trakt_api = TraktAPI(sickbeard.TRAKT_API_KEY, username, password, disable_ssl) trakt_api = TraktAPI(sickbeard.TRAKT_API_KEY, username, password, disable_ssl, sickbeard.TRAKT_TIMEOUT)
trakt_api.validateAccount() trakt_api.validateAccount()
return "Test notice sent successfully to Trakt" return "Test notice sent successfully to Trakt"
except (traktException, traktAuthException, traktServerBusy) as e: except (traktException, traktAuthException, traktServerBusy) as e:

View File

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

View File

@ -51,7 +51,7 @@ from sickbeard.scene_numbering import get_scene_numbering, set_scene_numbering,
get_xem_numbering_for_show, get_scene_absolute_numbering_for_show, get_xem_absolute_numbering_for_show, \ get_xem_numbering_for_show, get_scene_absolute_numbering_for_show, get_xem_absolute_numbering_for_show, \
get_scene_absolute_numbering get_scene_absolute_numbering
from lib.dateutil import tz from lib.dateutil import tz, parser as dateutil_parser
from lib.unrar2 import RarFile from lib.unrar2 import RarFile
from lib import adba, subliminal from lib import adba, subliminal
from lib.trakt import TraktAPI from lib.trakt import TraktAPI
@ -2236,7 +2236,7 @@ class HomeAddShows(Home):
logger.log(u"Getting recommended shows from Trakt.tv", logger.DEBUG) logger.log(u"Getting recommended shows from Trakt.tv", logger.DEBUG)
trakt_api = TraktAPI(sickbeard.TRAKT_API_KEY, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD, sickbeard.TRAKT_DISABLE_SSL_VERIFY) trakt_api = TraktAPI(sickbeard.TRAKT_API_KEY, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD, sickbeard.TRAKT_DISABLE_SSL_VERIFY, sickbeard.TRAKT_TIMEOUT)
try: try:
recommendedlist = trakt_api.traktRequest("recommendations/shows?extended=full,images") recommendedlist = trakt_api.traktRequest("recommendations/shows?extended=full,images")
@ -2244,12 +2244,12 @@ class HomeAddShows(Home):
if recommendedlist: if recommendedlist:
indexers = ['tvdb', 'tvrage'] indexers = ['tvdb', 'tvrage']
map(final_results.append, ( map(final_results.append, (
[int(show['show']['ids'][indexers[sickbeard.TRAKT_DEFAULT_INDEXER - 1]]), [int(show['ids'][indexers[sickbeard.TRAKT_DEFAULT_INDEXER - 1]]),
'http://www.trakt.tv/shows/%s' % show['show']['ids']['slug'], show['show']['title'], 'http://www.trakt.tv/shows/%s' % show['ids']['slug'], show['title'],
show['show']['overview'], show['overview'],
datetime.date.fromtimestamp(int(show['show']['first_aired']) / 1000.0).strftime('%Y%m%d')] None if show['first_aired'] is None else dateutil_parser.parse(show['first_aired']).strftime('%Y%m%d')]
for show in recommendedlist if not helpers.findCertainShow(sickbeard.showList, [ for show in recommendedlist if not helpers.findCertainShow(sickbeard.showList, [
int(show['show']['ids'][indexers[sickbeard.TRAKT_DEFAULT_INDEXER - 1]])]))) int(show['ids'][indexers[sickbeard.TRAKT_DEFAULT_INDEXER - 1]])])))
except (traktException, traktAuthException, traktServerBusy) as e: except (traktException, traktAuthException, traktServerBusy) as e:
logger.log(u"Could not connect to Trakt service: %s" % ex(e), logger.WARNING) logger.log(u"Could not connect to Trakt service: %s" % ex(e), logger.WARNING)
@ -2292,7 +2292,7 @@ class HomeAddShows(Home):
t.trending_shows = [] t.trending_shows = []
trakt_api = TraktAPI(sickbeard.TRAKT_API_KEY, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD, sickbeard.TRAKT_DISABLE_SSL_VERIFY) trakt_api = TraktAPI(sickbeard.TRAKT_API_KEY, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD, sickbeard.TRAKT_DISABLE_SSL_VERIFY, sickbeard.TRAKT_TIMEOUT)
try: try:
shows = trakt_api.traktRequest("shows/trending?limit=50&extended=full,images") or [] shows = trakt_api.traktRequest("shows/trending?limit=50&extended=full,images") or []
@ -3527,7 +3527,7 @@ class ConfigGeneral(Config):
sickbeard.ENCRYPTION_VERSION = config.checkbox_to_value(encryption_version) sickbeard.ENCRYPTION_VERSION = config.checkbox_to_value(encryption_version)
sickbeard.WEB_USERNAME = web_username sickbeard.WEB_USERNAME = web_username
sickbeard.WEB_PASSWORD = web_password sickbeard.WEB_PASSWORD = web_password
sickbeard.DISPLAY_FILESIZE = config.checkbox_to_value(display_filesize) sickbeard.DISPLAY_FILESIZE = config.checkbox_to_value(display_filesize)
sickbeard.FUZZY_DATING = config.checkbox_to_value(fuzzy_dating) sickbeard.FUZZY_DATING = config.checkbox_to_value(fuzzy_dating)
sickbeard.TRIM_ZERO = config.checkbox_to_value(trim_zero) sickbeard.TRIM_ZERO = config.checkbox_to_value(trim_zero)
@ -4415,7 +4415,7 @@ class ConfigNotifications(Config):
use_trakt=None, trakt_username=None, trakt_password=None, use_trakt=None, trakt_username=None, trakt_password=None,
trakt_remove_watchlist=None, trakt_use_watchlist=None, trakt_method_add=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_start_paused=None, trakt_use_recommended=None, trakt_sync=None,
trakt_default_indexer=None, trakt_remove_serieslist=None, trakt_disable_ssl_verify=None, trakt_default_indexer=None, trakt_remove_serieslist=None, trakt_disable_ssl_verify=None, trakt_timeout=None,
use_synologynotifier=None, synologynotifier_notify_onsnatch=None, use_synologynotifier=None, synologynotifier_notify_onsnatch=None,
synologynotifier_notify_ondownload=None, synologynotifier_notify_onsubtitledownload=None, synologynotifier_notify_ondownload=None, synologynotifier_notify_onsubtitledownload=None,
use_pytivo=None, pytivo_notify_onsnatch=None, pytivo_notify_ondownload=None, use_pytivo=None, pytivo_notify_onsnatch=None, pytivo_notify_ondownload=None,
@ -4537,6 +4537,7 @@ class ConfigNotifications(Config):
sickbeard.TRAKT_SYNC = config.checkbox_to_value(trakt_sync) sickbeard.TRAKT_SYNC = config.checkbox_to_value(trakt_sync)
sickbeard.TRAKT_DEFAULT_INDEXER = int(trakt_default_indexer) sickbeard.TRAKT_DEFAULT_INDEXER = int(trakt_default_indexer)
sickbeard.TRAKT_DISABLE_SSL_VERIFY = config.checkbox_to_value(trakt_disable_ssl_verify) sickbeard.TRAKT_DISABLE_SSL_VERIFY = config.checkbox_to_value(trakt_disable_ssl_verify)
sickbeard.TRAKT_TIMEOUT = int(trakt_timeout)
if sickbeard.USE_TRAKT: if sickbeard.USE_TRAKT:
sickbeard.traktCheckerScheduler.silent = False sickbeard.traktCheckerScheduler.silent = False