mirror of
https://github.com/moparisthebest/SickRage
synced 2024-12-13 03:22:22 -05:00
Fixes for DB issues
This commit is contained in:
parent
d00d55fdfc
commit
a1da7df12e
@ -1,4 +1,5 @@
|
||||
#import sickbeard
|
||||
#import psutil
|
||||
#from sickbeard import db
|
||||
#import os.path
|
||||
#set global $title="Configuration"
|
||||
@ -14,6 +15,17 @@
|
||||
<h1 class="title">$title</h1>
|
||||
#end if
|
||||
|
||||
#set cpu_usage = $psutil.cpu_percent()
|
||||
#set ram = $psutil.phymem_usage()
|
||||
#set ram_total = $ram.total / 2**20
|
||||
#set ram_used = $ram.used / 2**20
|
||||
#set ram_free = $ram.free / 2**20
|
||||
#set ram_percent_used = $ram.percent
|
||||
#set disk = $psutil.disk_usage('/')
|
||||
#set disk_total = $disk.total / 2**30
|
||||
#set disk_used = $disk.used / 2**30
|
||||
#set disk_free = $disk.free / 2**30
|
||||
#set disk_percent_used = $disk.percent
|
||||
|
||||
<div id="summary" class="align-left">
|
||||
<table class="infoTable" cellspacing="1" border="0" cellpadding="0">
|
||||
@ -25,6 +37,7 @@
|
||||
#end if
|
||||
<font color="red">You are using BETA software</font>
|
||||
</td></tr>
|
||||
<tr><td class="infoTableHeader">Memory Used: </td><td class="infoTableCell">$ram_percent_used</td></tr>
|
||||
<tr><td class="infoTableHeader">SR Config file: </td><td class="infoTableCell">$sickbeard.CONFIG_FILE</td></tr>
|
||||
<tr><td class="infoTableHeader">SR Database file: </td><td class="infoTableCell">$db.dbFilename()</td></tr>
|
||||
<tr><td class="infoTableHeader">SR Cache Dir: </td><td class="infoTableCell">$sickbeard.CACHE_DIR</td></tr>
|
||||
|
@ -343,8 +343,8 @@ class BTNCache(tvcache.TVCache):
|
||||
cl.append(ci)
|
||||
|
||||
if cl:
|
||||
myDB = self._getDB()
|
||||
myDB.mass_action(cl)
|
||||
with self._getDB() as myDB:
|
||||
myDB.mass_action(cl)
|
||||
|
||||
else:
|
||||
raise AuthException(
|
||||
|
@ -255,8 +255,8 @@ class HDBitsCache(tvcache.TVCache):
|
||||
ql.append(ci)
|
||||
|
||||
if ql:
|
||||
myDB = self._getDB()
|
||||
myDB.mass_action(ql)
|
||||
with self._getDB() as myDB:
|
||||
myDB.mass_action(ql)
|
||||
|
||||
else:
|
||||
raise exceptions.AuthException(
|
||||
|
@ -377,8 +377,8 @@ class HDTorrentsCache(tvcache.TVCache):
|
||||
cl.append(ci)
|
||||
|
||||
if cl:
|
||||
myDB = self._getDB()
|
||||
myDB.mass_action(cl)
|
||||
with self._getDB() as myDB:
|
||||
myDB.mass_action(cl)
|
||||
|
||||
def _parseItem(self, item):
|
||||
|
||||
|
@ -318,8 +318,8 @@ class IPTorrentsCache(tvcache.TVCache):
|
||||
cl.append(ci)
|
||||
|
||||
if cl:
|
||||
myDB = self._getDB()
|
||||
myDB.mass_action(cl)
|
||||
with self._getDB() as myDB:
|
||||
myDB.mass_action(cl)
|
||||
|
||||
def _parseItem(self, item):
|
||||
|
||||
|
@ -455,8 +455,8 @@ class KATCache(tvcache.TVCache):
|
||||
cl.append(ci)
|
||||
|
||||
if cl:
|
||||
myDB = self._getDB()
|
||||
myDB.mass_action(cl)
|
||||
with self._getDB() as myDB:
|
||||
myDB.mass_action(cl)
|
||||
|
||||
def _parseItem(self, item):
|
||||
|
||||
|
@ -342,8 +342,8 @@ class NewznabCache(tvcache.TVCache):
|
||||
ql.append(ci)
|
||||
|
||||
if ql:
|
||||
myDB = self._getDB()
|
||||
myDB.mass_action(ql)
|
||||
with self._getDB() as myDB:
|
||||
myDB.mass_action(ql)
|
||||
|
||||
else:
|
||||
raise AuthException(
|
||||
|
@ -367,8 +367,8 @@ class NextGenCache(tvcache.TVCache):
|
||||
cl.append(ci)
|
||||
|
||||
if cl:
|
||||
myDB = self._getDB()
|
||||
myDB.mass_action(cl)
|
||||
with self._getDB() as myDB:
|
||||
myDB.mass_action(cl)
|
||||
|
||||
def _parseItem(self, item):
|
||||
|
||||
|
@ -340,8 +340,8 @@ class PublicHDCache(tvcache.TVCache):
|
||||
ql.append(ci)
|
||||
|
||||
if ql:
|
||||
myDB = self._getDB()
|
||||
myDB.mass_action(ql)
|
||||
with self._getDB() as myDB:
|
||||
myDB.mass_action(ql)
|
||||
|
||||
def _parseItem(self, item):
|
||||
|
||||
|
@ -362,8 +362,8 @@ class SCCCache(tvcache.TVCache):
|
||||
cl.append(ci)
|
||||
|
||||
if cl:
|
||||
myDB = self._getDB()
|
||||
myDB.mass_action(cl)
|
||||
with self._getDB() as myDB:
|
||||
myDB.mass_action(cl)
|
||||
|
||||
def _parseItem(self, item):
|
||||
|
||||
|
@ -302,8 +302,8 @@ class SpeedCDCache(tvcache.TVCache):
|
||||
ql.append(ci)
|
||||
|
||||
if ql:
|
||||
myDB = self._getDB()
|
||||
myDB.mass_action(ql)
|
||||
with self._getDB() as myDB:
|
||||
myDB.mass_action(ql)
|
||||
|
||||
def _parseItem(self, item):
|
||||
|
||||
|
@ -435,8 +435,8 @@ class ThePirateBayCache(tvcache.TVCache):
|
||||
cl.append(ci)
|
||||
|
||||
if cl:
|
||||
myDB = self._getDB()
|
||||
myDB.mass_action(cl)
|
||||
with self._getDB() as myDB:
|
||||
myDB.mass_action(cl)
|
||||
|
||||
def _parseItem(self, item):
|
||||
|
||||
|
@ -326,8 +326,8 @@ class TorrentDayCache(tvcache.TVCache):
|
||||
cl.append(ci)
|
||||
|
||||
if cl:
|
||||
myDB = self._getDB()
|
||||
myDB.mass_action(cl)
|
||||
with self._getDB() as myDB:
|
||||
myDB.mass_action(cl)
|
||||
|
||||
def _parseItem(self, item):
|
||||
|
||||
|
@ -321,8 +321,8 @@ class TorrentLeechCache(tvcache.TVCache):
|
||||
cl.append(ci)
|
||||
|
||||
if cl:
|
||||
myDB = self._getDB()
|
||||
myDB.mass_action(cl)
|
||||
with self._getDB() as myDB:
|
||||
myDB.mass_action(cl)
|
||||
|
||||
def _parseItem(self, item):
|
||||
|
||||
|
@ -693,4 +693,5 @@ def fix_xem_numbering(indexer_id, indexer):
|
||||
update_scene_absolute_number = False
|
||||
|
||||
if ql:
|
||||
myDB.mass_action(ql)
|
||||
with db.DBConnection() as myDB:
|
||||
myDB.mass_action(ql)
|
@ -203,7 +203,7 @@ class TVShow(object):
|
||||
if self.is_anime and absolute_number and not season and not episode:
|
||||
with db.DBConnection() as myDB:
|
||||
sql = "SELECT * FROM tv_episodes WHERE showid = ? and absolute_number = ? and season != 0"
|
||||
sqlResults = myDB.select(sql, [self.indexerid, absolute_number])
|
||||
sqlResults = myDB.select(sql, [self.indexerid, absolute_number])
|
||||
|
||||
if len(sqlResults) == 1:
|
||||
episode = int(sqlResults[0]["episode"])
|
||||
|
@ -82,11 +82,10 @@ class TVCache():
|
||||
if not self.shouldClearCache():
|
||||
return
|
||||
|
||||
myDB = self._getDB()
|
||||
|
||||
curDate = datetime.date.today() - datetime.timedelta(weeks=1)
|
||||
|
||||
myDB.action("DELETE FROM [" + self.providerID + "] WHERE time < ?", [int(time.mktime(curDate.timetuple()))])
|
||||
with self._getDB() as myDB:
|
||||
myDB.action("DELETE FROM [" + self.providerID + "] WHERE time < ?", [int(time.mktime(curDate.timetuple()))])
|
||||
|
||||
def _getRSSData(self):
|
||||
|
||||
@ -127,8 +126,8 @@ class TVCache():
|
||||
cl.append(ci)
|
||||
|
||||
if cl:
|
||||
myDB = self._getDB()
|
||||
myDB.mass_action(cl)
|
||||
with self._getDB() as myDB:
|
||||
myDB.mass_action(cl)
|
||||
|
||||
else:
|
||||
raise AuthException(
|
||||
@ -194,8 +193,8 @@ class TVCache():
|
||||
|
||||
|
||||
def _getLastUpdate(self):
|
||||
myDB = self._getDB()
|
||||
sqlResults = myDB.select("SELECT time FROM lastUpdate WHERE provider = ?", [self.providerID])
|
||||
with self._getDB() as myDB:
|
||||
sqlResults = myDB.select("SELECT time FROM lastUpdate WHERE provider = ?", [self.providerID])
|
||||
|
||||
if sqlResults:
|
||||
lastTime = int(sqlResults[0]["time"])
|
||||
@ -207,8 +206,8 @@ class TVCache():
|
||||
return datetime.datetime.fromtimestamp(lastTime)
|
||||
|
||||
def _getLastSearch(self):
|
||||
myDB = self._getDB()
|
||||
sqlResults = myDB.select("SELECT time FROM lastSearch WHERE provider = ?", [self.providerID])
|
||||
with self._getDB() as myDB:
|
||||
sqlResults = myDB.select("SELECT time FROM lastSearch WHERE provider = ?", [self.providerID])
|
||||
|
||||
if sqlResults:
|
||||
lastTime = int(sqlResults[0]["time"])
|
||||
@ -224,19 +223,19 @@ class TVCache():
|
||||
if not toDate:
|
||||
toDate = datetime.datetime.today()
|
||||
|
||||
myDB = self._getDB()
|
||||
myDB.upsert("lastUpdate",
|
||||
{'time': int(time.mktime(toDate.timetuple()))},
|
||||
{'provider': self.providerID})
|
||||
with self._getDB() as myDB:
|
||||
myDB.upsert("lastUpdate",
|
||||
{'time': int(time.mktime(toDate.timetuple()))},
|
||||
{'provider': self.providerID})
|
||||
|
||||
def setLastSearch(self, toDate=None):
|
||||
if not toDate:
|
||||
toDate = datetime.datetime.today()
|
||||
|
||||
myDB = self._getDB()
|
||||
myDB.upsert("lastSearch",
|
||||
{'time': int(time.mktime(toDate.timetuple()))},
|
||||
{'provider': self.providerID})
|
||||
with self._getDB() as myDB:
|
||||
myDB.upsert("lastSearch",
|
||||
{'time': int(time.mktime(toDate.timetuple()))},
|
||||
{'provider': self.providerID})
|
||||
|
||||
lastUpdate = property(_getLastUpdate)
|
||||
lastSearch = property(_getLastSearch)
|
||||
@ -316,25 +315,23 @@ class TVCache():
|
||||
return neededEps
|
||||
|
||||
def listPropers(self, date=None, delimiter="."):
|
||||
myDB = self._getDB()
|
||||
with self._getDB() as myDB:
|
||||
sql = "SELECT * FROM [" + self.providerID + "] WHERE name LIKE '%.PROPER.%' OR name LIKE '%.REPACK.%'"
|
||||
|
||||
sql = "SELECT * FROM [" + self.providerID + "] WHERE name LIKE '%.PROPER.%' OR name LIKE '%.REPACK.%'"
|
||||
if date != None:
|
||||
sql += " AND time >= " + str(int(time.mktime(date.timetuple())))
|
||||
|
||||
if date != None:
|
||||
sql += " AND time >= " + str(int(time.mktime(date.timetuple())))
|
||||
|
||||
return filter(lambda x: x['indexerid'] != 0, myDB.select(sql))
|
||||
return filter(lambda x: x['indexerid'] != 0, myDB.select(sql))
|
||||
|
||||
|
||||
def findNeededEpisodes(self, episodes, manualSearch=False):
|
||||
neededEps = {}
|
||||
|
||||
cacheDB = self._getDB()
|
||||
|
||||
for epObj in episodes:
|
||||
sqlResults = cacheDB.select(
|
||||
"SELECT * FROM [" + self.providerID + "] WHERE indexerid = ? AND season = ? AND episodes LIKE ?",
|
||||
[epObj.show.indexerid, epObj.season, "%|" + str(epObj.episode) + "|%"])
|
||||
with self._getDB() as myDB:
|
||||
sqlResults = myDB.select(
|
||||
"SELECT * FROM [" + self.providerID + "] WHERE indexerid = ? AND season = ? AND episodes LIKE ?",
|
||||
[epObj.show.indexerid, epObj.season, "%|" + str(epObj.episode) + "|%"])
|
||||
|
||||
# for each cache entry
|
||||
for curResult in sqlResults:
|
||||
|
Loading…
Reference in New Issue
Block a user