mirror of
https://github.com/moparisthebest/SickRage
synced 2025-01-08 12:28:05 -05:00
SQL Query performance gains added and memory footprint reduced.
This commit is contained in:
parent
b19aafb807
commit
4575c58348
@ -83,6 +83,7 @@ def loadShowsFromDB():
|
|||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
sqlResults = myDB.select("SELECT * FROM tv_shows")
|
sqlResults = myDB.select("SELECT * FROM tv_shows")
|
||||||
|
|
||||||
|
sickbeard.showList = []
|
||||||
for sqlShow in sqlResults:
|
for sqlShow in sqlResults:
|
||||||
try:
|
try:
|
||||||
curShow = TVShow(int(sqlShow["indexer"]), int(sqlShow["indexer_id"]))
|
curShow = TVShow(int(sqlShow["indexer"]), int(sqlShow["indexer_id"]))
|
||||||
|
@ -22,7 +22,8 @@ import webbrowser
|
|||||||
import time
|
import time
|
||||||
import datetime
|
import datetime
|
||||||
import socket
|
import socket
|
||||||
import os, sys, subprocess, re
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
from urllib2 import getproxies
|
from urllib2 import getproxies
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
@ -90,10 +91,10 @@ traktCheckerScheduler = None
|
|||||||
showList = None
|
showList = None
|
||||||
loadingShowList = None
|
loadingShowList = None
|
||||||
|
|
||||||
providerList = None
|
providerList = []
|
||||||
newznabProviderList = None
|
newznabProviderList = []
|
||||||
torrentRssProviderList = None
|
torrentRssProviderList = []
|
||||||
metadata_provider_dict = None
|
metadata_provider_dict = {}
|
||||||
|
|
||||||
NEWEST_VERSION = None
|
NEWEST_VERSION = None
|
||||||
NEWEST_VERSION_STRING = None
|
NEWEST_VERSION_STRING = None
|
||||||
@ -102,7 +103,6 @@ AUTO_UPDATE = None
|
|||||||
CUR_COMMIT_HASH = None
|
CUR_COMMIT_HASH = None
|
||||||
|
|
||||||
INIT_LOCK = Lock()
|
INIT_LOCK = Lock()
|
||||||
__INITIALIZED__ = False
|
|
||||||
started = False
|
started = False
|
||||||
restarted = False
|
restarted = False
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ INDEXER_DEFAULT = None
|
|||||||
INDEXER_TIMEOUT = None
|
INDEXER_TIMEOUT = None
|
||||||
SCENE_DEFAULT = None
|
SCENE_DEFAULT = None
|
||||||
ANIME_DEFAULT = None
|
ANIME_DEFAULT = None
|
||||||
PROVIDER_ORDER = None
|
PROVIDER_ORDER = []
|
||||||
|
|
||||||
NAMING_MULTI_EP = None
|
NAMING_MULTI_EP = None
|
||||||
NAMING_PATTERN = None
|
NAMING_PATTERN = None
|
||||||
@ -413,17 +413,17 @@ TIME_PRESET_W_SECONDS = None
|
|||||||
TIMEZONE_DISPLAY = None
|
TIMEZONE_DISPLAY = None
|
||||||
|
|
||||||
USE_SUBTITLES = False
|
USE_SUBTITLES = False
|
||||||
SUBTITLES_LANGUAGES = None
|
SUBTITLES_LANGUAGES = []
|
||||||
SUBTITLES_DIR = ''
|
SUBTITLES_DIR = ''
|
||||||
SUBTITLES_SERVICES_LIST = None
|
SUBTITLES_SERVICES_LIST = []
|
||||||
SUBTITLES_SERVICES_ENABLED = None
|
SUBTITLES_SERVICES_ENABLED = []
|
||||||
SUBTITLES_HISTORY = False
|
SUBTITLES_HISTORY = False
|
||||||
SUBTITLES_FINDER_FREQUENCY = 1
|
SUBTITLES_FINDER_FREQUENCY = 1
|
||||||
|
|
||||||
USE_FAILED_DOWNLOADS = False
|
USE_FAILED_DOWNLOADS = False
|
||||||
DELETE_FAILED = False
|
DELETE_FAILED = False
|
||||||
|
|
||||||
EXTRA_SCRIPTS = None
|
EXTRA_SCRIPTS = []
|
||||||
|
|
||||||
GIT_PATH = None
|
GIT_PATH = None
|
||||||
|
|
||||||
@ -433,8 +433,8 @@ CALENDAR_UNPROTECTED = False
|
|||||||
|
|
||||||
TMDB_API_KEY = 'edc5f123313769de83a71e157758030b'
|
TMDB_API_KEY = 'edc5f123313769de83a71e157758030b'
|
||||||
|
|
||||||
__INITIALIZED__ = False
|
|
||||||
|
|
||||||
|
__INITIALIZED__ = False
|
||||||
def initialize(consoleLogging=True):
|
def initialize(consoleLogging=True):
|
||||||
with INIT_LOCK:
|
with INIT_LOCK:
|
||||||
|
|
||||||
@ -478,7 +478,7 @@ def initialize(consoleLogging=True):
|
|||||||
USE_FAILED_DOWNLOADS, DELETE_FAILED, ANON_REDIRECT, LOCALHOST_IP, TMDB_API_KEY, DEBUG, PROXY_SETTING, \
|
USE_FAILED_DOWNLOADS, DELETE_FAILED, ANON_REDIRECT, LOCALHOST_IP, TMDB_API_KEY, DEBUG, PROXY_SETTING, \
|
||||||
AUTOPOSTPROCESSER_FREQUENCY, DEFAULT_AUTOPOSTPROCESSER_FREQUENCY, MIN_AUTOPOSTPROCESSER_FREQUENCY, \
|
AUTOPOSTPROCESSER_FREQUENCY, DEFAULT_AUTOPOSTPROCESSER_FREQUENCY, MIN_AUTOPOSTPROCESSER_FREQUENCY, \
|
||||||
ANIME_DEFAULT, NAMING_ANIME, ANIMESUPPORT, USE_ANIDB, ANIDB_USERNAME, ANIDB_PASSWORD, ANIDB_USE_MYLIST, \
|
ANIME_DEFAULT, NAMING_ANIME, ANIMESUPPORT, USE_ANIDB, ANIDB_USERNAME, ANIDB_PASSWORD, ANIDB_USE_MYLIST, \
|
||||||
ANIME_SPLIT_HOME, maintenanceScheduler, SCENE_DEFAULT, RES
|
ANIME_SPLIT_HOME, maintenanceScheduler, SCENE_DEFAULT
|
||||||
|
|
||||||
if __INITIALIZED__:
|
if __INITIALIZED__:
|
||||||
return False
|
return False
|
||||||
@ -1791,17 +1791,3 @@ def getEpList(epIDs, showid=None):
|
|||||||
epList.append(curEpObj)
|
epList.append(curEpObj)
|
||||||
|
|
||||||
return epList
|
return epList
|
||||||
|
|
||||||
|
|
||||||
def autoreload_shutdown():
|
|
||||||
logger.log('SickRage is now auto-reloading, please stand by ...')
|
|
||||||
|
|
||||||
# halt all tasks
|
|
||||||
halt()
|
|
||||||
|
|
||||||
# save settings
|
|
||||||
saveAll()
|
|
||||||
|
|
||||||
if CREATEPID:
|
|
||||||
logger.log(u"Removing pidfile " + str(PIDFILE))
|
|
||||||
remove_pid_file(PIDFILE)
|
|
||||||
|
@ -63,7 +63,7 @@ class DBConnection(object):
|
|||||||
def reconnect(self):
|
def reconnect(self):
|
||||||
"""Closes the existing database connection and re-opens it."""
|
"""Closes the existing database connection and re-opens it."""
|
||||||
self.close()
|
self.close()
|
||||||
self.connection = sqlite3.connect(dbFilename(self.filename, self.suffix), 20)
|
self.connection = sqlite3.connect(dbFilename(self.filename, self.suffix), 20, check_same_thread=False)
|
||||||
self.connection.isolation_level = None
|
self.connection.isolation_level = None
|
||||||
|
|
||||||
if self.row_type == "dict":
|
if self.row_type == "dict":
|
||||||
@ -164,9 +164,6 @@ class DBConnection(object):
|
|||||||
logger.log(u"Fatal error executing query: " + ex(e), logger.ERROR)
|
logger.log(u"Fatal error executing query: " + ex(e), logger.ERROR)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# cleanup
|
|
||||||
del querylist
|
|
||||||
|
|
||||||
return sqlResult
|
return sqlResult
|
||||||
|
|
||||||
def action(self, query, args=None, fetchall=False, fetchone=False):
|
def action(self, query, args=None, fetchall=False, fetchone=False):
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
|
import threading
|
||||||
import sickbeard
|
import sickbeard
|
||||||
|
|
||||||
from lib import adba
|
from lib import adba
|
||||||
@ -26,6 +27,8 @@ from sickbeard import name_cache
|
|||||||
from sickbeard import logger
|
from sickbeard import logger
|
||||||
from sickbeard import db
|
from sickbeard import db
|
||||||
|
|
||||||
|
scene_lock = threading.Lock()
|
||||||
|
|
||||||
def shouldRefresh(list):
|
def shouldRefresh(list):
|
||||||
MAX_REFRESH_AGE_SECS = 86400 # 1 day
|
MAX_REFRESH_AGE_SECS = 86400 # 1 day
|
||||||
|
|
||||||
@ -59,6 +62,7 @@ def get_scene_exceptions(indexer_id, season=-1):
|
|||||||
if season == 1: # if we where looking for season 1 we can add generic names
|
if season == 1: # if we where looking for season 1 we can add generic names
|
||||||
exceptionsList += get_scene_exceptions(indexer_id, season=-1)
|
exceptionsList += get_scene_exceptions(indexer_id, season=-1)
|
||||||
|
|
||||||
|
del exceptions
|
||||||
return exceptionsList
|
return exceptionsList
|
||||||
|
|
||||||
|
|
||||||
@ -74,6 +78,7 @@ def get_all_scene_exceptions(indexer_id):
|
|||||||
exceptionsList[cur_exception["season"]] = []
|
exceptionsList[cur_exception["season"]] = []
|
||||||
exceptionsList[cur_exception["season"]].append(cur_exception["show_name"])
|
exceptionsList[cur_exception["season"]].append(cur_exception["show_name"])
|
||||||
|
|
||||||
|
del exceptions
|
||||||
return exceptionsList
|
return exceptionsList
|
||||||
|
|
||||||
|
|
||||||
@ -121,6 +126,10 @@ def get_scene_exception_by_name_multiple(show_name):
|
|||||||
sickbeard.helpers.sanitizeSceneName(cur_exception_name).lower().replace('.', ' ')):
|
sickbeard.helpers.sanitizeSceneName(cur_exception_name).lower().replace('.', ' ')):
|
||||||
logger.log(u"Scene exception lookup got indexer id " + str(cur_indexer_id) + u", using that", logger.DEBUG)
|
logger.log(u"Scene exception lookup got indexer id " + str(cur_indexer_id) + u", using that", logger.DEBUG)
|
||||||
out.append((cur_indexer_id, cur_season))
|
out.append((cur_indexer_id, cur_season))
|
||||||
|
|
||||||
|
# cleanup
|
||||||
|
del all_exception_results
|
||||||
|
|
||||||
if out:
|
if out:
|
||||||
return out
|
return out
|
||||||
else:
|
else:
|
||||||
@ -210,7 +219,6 @@ def retrieve_exceptions():
|
|||||||
logger.log(u"No scene exceptions update needed")
|
logger.log(u"No scene exceptions update needed")
|
||||||
|
|
||||||
# cleanup
|
# cleanup
|
||||||
del existing_exceptions
|
|
||||||
del exception_dict
|
del exception_dict
|
||||||
|
|
||||||
def update_scene_exceptions(indexer_id, scene_exceptions):
|
def update_scene_exceptions(indexer_id, scene_exceptions):
|
||||||
@ -222,7 +230,7 @@ def update_scene_exceptions(indexer_id, scene_exceptions):
|
|||||||
myDB.action('DELETE FROM scene_exceptions WHERE indexer_id=? and custom=1', [indexer_id])
|
myDB.action('DELETE FROM scene_exceptions WHERE indexer_id=? and custom=1', [indexer_id])
|
||||||
|
|
||||||
logger.log(u"Updating scene exceptions", logger.MESSAGE)
|
logger.log(u"Updating scene exceptions", logger.MESSAGE)
|
||||||
for cur_season in [-1] + sickbeard.scene_exceptions.get_scene_seasons(indexer_id):
|
for cur_season in [-1] + get_scene_seasons(indexer_id):
|
||||||
for cur_exception in scene_exceptions:
|
for cur_exception in scene_exceptions:
|
||||||
myDB.action("INSERT INTO scene_exceptions (indexer_id, show_name, season, custom) VALUES (?,?,?,?)",
|
myDB.action("INSERT INTO scene_exceptions (indexer_id, show_name, season, custom) VALUES (?,?,?,?)",
|
||||||
[indexer_id, cur_exception, cur_season, 1])
|
[indexer_id, cur_exception, cur_season, 1])
|
||||||
|
Loading…
Reference in New Issue
Block a user