1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-14 03:52:22 -05:00

Fix for scene name repeat bug when displaying show.

Added scene exceptions feature, hover over the show name with your mouse to see ALL scene exceceptions currently set for the show.
This commit is contained in:
echel0n 2014-05-26 11:07:10 -07:00
parent f7b11e1e98
commit de01fa1e37
6 changed files with 57 additions and 64 deletions

View File

@ -22,7 +22,7 @@
<script type="text/javascript" src="$sbRoot/js/displayShow.js?$sbPID"></script> <script type="text/javascript" src="$sbRoot/js/displayShow.js?$sbPID"></script>
<script type="text/javascript" src="$sbRoot/js/plotTooltip.js?$sbPID"></script> <script type="text/javascript" src="$sbRoot/js/plotTooltip.js?$sbPID"></script>
<script type="text/javascript" src="$sbRoot/js/sceneExceptionsTooltip.js"></script> <script type="text/javascript" src="$sbRoot/js/sceneExceptionsTooltip.js?$sbPID"></script>
<script type="text/javascript" src="$sbRoot/js/ajaxEpSearch.js?$sbPID"></script> <script type="text/javascript" src="$sbRoot/js/ajaxEpSearch.js?$sbPID"></script>
<script type="text/javascript" src="$sbRoot/js/ajaxEpSubtitles.js?$sbPID"></script> <script type="text/javascript" src="$sbRoot/js/ajaxEpSubtitles.js?$sbPID"></script>
<script type="text/javascript" src="$sbRoot/js/ajaxEpRetry.js?$sbPID"></script> <script type="text/javascript" src="$sbRoot/js/ajaxEpRetry.js?$sbPID"></script>
@ -54,7 +54,7 @@
</div> </div>
<div class="showInfo"> <div class="showInfo">
<h1 class="title"><a>$show.name</a></h1> <h1 class="title" id="scene_exception_$show.indexerid"><a>$show.name</a></h1>
<span class="headerInfo" style="color: #b7b7b7; line-height: 16px;"> <span class="headerInfo" style="color: #b7b7b7; line-height: 16px;">
#if not $show.imdbid #if not $show.imdbid
($show.startyear) - $show.runtime min ($show.startyear) - $show.runtime min

View File

@ -1,5 +1,5 @@
$(function () { $(function () {
$('.showTitle a').each(function () { $('.title a').each(function () {
match = $(this).parent().attr("id").match(/^scene_exception_(\d+)$/); match = $(this).parent().attr("id").match(/^scene_exception_(\d+)$/);
$(this).qtip({ $(this).qtip({
content: { content: {
@ -32,7 +32,7 @@ $(function () {
corner: true, corner: true,
method: 'polygon' method: 'polygon'
}, },
classes: 'ui-tooltip-rounded ui-tooltip-shadow ui-tooltip-sb' classes: 'qtip-rounded qtip-shadow ui-tooltip-sb'
} }
}); });
}); });

View File

@ -42,9 +42,6 @@ class DailySearcher():
self.amActive = True self.amActive = True
# remove names from cache that link back to active shows that we watch
sickbeard.name_cache.syncNameCache()
logger.log(u"Searching for coming episodes and 1 weeks worth of previously WANTED episodes ...") logger.log(u"Searching for coming episodes and 1 weeks worth of previously WANTED episodes ...")
fromDate = datetime.date.today() - datetime.timedelta(weeks=1) fromDate = datetime.date.today() - datetime.timedelta(weeks=1)
@ -88,6 +85,10 @@ class DailySearcher():
if len(todaysEps): if len(todaysEps):
for show in todaysEps: for show in todaysEps:
segment = todaysEps[show] segment = todaysEps[show]
# remove show from name cache if marked invalid
sickbeard.name_cache.clearCache(show)
dailysearch_queue_item = sickbeard.search_queue.DailySearchQueueItem(show, segment) dailysearch_queue_item = sickbeard.search_queue.DailySearchQueueItem(show, segment)
sickbeard.searchQueueScheduler.action.add_item(dailysearch_queue_item) #@UndefinedVariable sickbeard.searchQueueScheduler.action.add_item(dailysearch_queue_item) #@UndefinedVariable
else: else:

View File

@ -59,20 +59,14 @@ def retrieveShowFromCache(name):
if indexerid: if indexerid:
return sickbeard.helpers.findCertainShow(sickbeard.showList, int(indexerid)) return sickbeard.helpers.findCertainShow(sickbeard.showList, int(indexerid))
def syncNameCache(): def clearCache(show=None, season=-1, indexer_id=0):
cacheDB = db.DBConnection('cache.db')
for curShow in sickbeard.showList:
for show_name in set(sickbeard.show_name_helpers.allPossibleShowNames(curShow)):
sqlResult = cacheDB.action("DELETE FROM scene_names WHERE name = ? and indexer_id = ?", [show_name, 0])
if sqlResult.rowcount > 0:
logger.log(u"Removing invalid record for [" + show_name + "] from cache ...")
break
def clearCache():
""" """
Deletes all "unknown" entries from the cache (names with indexer_id of 0). Deletes all "unknown" entries from the cache (names with indexer_id of 0).
""" """
cacheDB = db.DBConnection('cache.db') cacheDB = db.DBConnection('cache.db')
cacheDB.action("DELETE FROM scene_names WHERE indexer_id = ?", [0]) if show:
showNames = sickbeard.show_name_helpers.allPossibleShowNames(show, season=season)
for showName in showNames:
cacheDB.action("DELETE FROM scene_names WHERE name = ? and indexer_id = ?", [showName, indexer_id])
else:
cacheDB.action("DELETE FROM scene_names WHERE indexer_id = ?", [indexer_id])

View File

@ -17,6 +17,7 @@
# along with SickRage. If not, see <http://www.gnu.org/licenses/>. # along with SickRage. If not, see <http://www.gnu.org/licenses/>.
import re import re
import threading
import sickbeard import sickbeard
from lib import adba from lib import adba
@ -38,13 +39,17 @@ def get_scene_exceptions(indexer_id, season=-1):
if indexer_id not in exceptionCache or season not in exceptionCache[indexer_id]: if indexer_id not in exceptionCache or season not in exceptionCache[indexer_id]:
myDB = db.DBConnection("cache.db") myDB = db.DBConnection("cache.db")
exceptions = myDB.select("SELECT show_name FROM scene_exceptions WHERE indexer_id = ? and season = ?", [indexer_id, season]) exceptions = myDB.select("SELECT show_name FROM scene_exceptions WHERE indexer_id = ? and season = ?",
exceptionsList = [cur_exception["show_name"] for cur_exception in exceptions] [indexer_id, season])
if not indexer_id in exceptionCache: exceptionsList = list(set([cur_exception["show_name"] for cur_exception in exceptions]))
exceptionCache[indexer_id] = {}
if len(exceptionsList):
try:
exceptionCache[indexer_id][season] = exceptionsList exceptionCache[indexer_id][season] = exceptionsList
except:
exceptionCache[indexer_id] = {season:exceptionsList}
else: else:
exceptionsList = exceptionCache[indexer_id][season] exceptionsList = list(set(exceptionCache[indexer_id][season]))
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)
@ -70,14 +75,17 @@ def get_scene_seasons(indexer_id):
global exceptionSeasonCache global exceptionSeasonCache
if indexer_id not in exceptionSeasonCache: if indexer_id not in exceptionSeasonCache:
myDB = db.DBConnection("cache.db") myDB = db.DBConnection("cache.db")
sqlResults = myDB.select("SELECT DISTINCT(season) as season FROM scene_exceptions WHERE indexer_id = ?", [indexer_id]) sqlResults = myDB.select("SELECT DISTINCT(season) as season FROM scene_exceptions WHERE indexer_id = ?",
[indexer_id])
exceptionSeasonCache[indexer_id] = [int(x["season"]) for x in sqlResults] exceptionSeasonCache[indexer_id] = [int(x["season"]) for x in sqlResults]
return exceptionSeasonCache[indexer_id] return exceptionSeasonCache[indexer_id]
def get_scene_exception_by_name(show_name): def get_scene_exception_by_name(show_name):
return get_scene_exception_by_name_multiple(show_name)[0] return get_scene_exception_by_name_multiple(show_name)[0]
def get_scene_exception_by_name_multiple(show_name): def get_scene_exception_by_name_multiple(show_name):
""" """
Given a show name, return the indexerid of the exception, None if no exception Given a show name, return the indexerid of the exception, None if no exception
@ -87,7 +95,9 @@ def get_scene_exception_by_name_multiple(show_name):
myDB = db.DBConnection("cache.db") myDB = db.DBConnection("cache.db")
# try the obvious case first # try the obvious case first
exception_result = myDB.select("SELECT indexer_id, season FROM scene_exceptions WHERE LOWER(show_name) = ? ORDER BY season ASC", [show_name.lower()]) exception_result = myDB.select(
"SELECT indexer_id, season FROM scene_exceptions WHERE LOWER(show_name) = ? ORDER BY season ASC",
[show_name.lower()])
if exception_result: if exception_result:
return [(int(x["indexer_id"]), int(x["season"])) for x in exception_result] return [(int(x["indexer_id"]), int(x["season"])) for x in exception_result]
@ -99,7 +109,8 @@ def get_scene_exception_by_name_multiple(show_name):
cur_indexer_id = int(cur_exception["indexer_id"]) cur_indexer_id = int(cur_exception["indexer_id"])
cur_season = int(cur_exception["season"]) cur_season = int(cur_exception["season"])
if show_name.lower() in (cur_exception_name.lower(), sickbeard.helpers.sanitizeSceneName(cur_exception_name).lower().replace('.', ' ')): if show_name.lower() in (
cur_exception_name.lower(), 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))
if out: if out:
@ -107,18 +118,21 @@ def get_scene_exception_by_name_multiple(show_name):
else: else:
return [(None, None)] return [(None, None)]
def retrieve_exceptions(): def retrieve_exceptions():
""" """
Looks up the exceptions on github, parses them into a dict, and inserts them into the Looks up the exceptions on github, parses them into a dict, and inserts them into the
scene_exceptions table in cache.db. Also clears the scene name cache. scene_exceptions table in cache.db. Also clears the scene name cache.
""" """
global exceptionCache, exceptionSeasonCache global exceptionCache, exceptionSeasonCache, exceptionIndexerCache
exception_dict = {} exception_dict = {}
exceptionCache = {}
exceptionSeasonCache = {}
exceptionIndexerCache = {}
# exceptions are stored on github pages # exceptions are stored on github pages
for indexer in sickbeard.indexerApi().indexers: for indexer in sickbeard.indexerApi().indexers:
logger.log(u"Checking for scene exception updates for " + sickbeard.indexerApi(indexer).name + "") logger.log(u"Checking for scene exception updates for " + sickbeard.indexerApi(indexer).name + "")
@ -177,6 +191,10 @@ def retrieve_exceptions():
for cur_exception_dict in exception_dict[cur_indexer_id]: for cur_exception_dict in exception_dict[cur_indexer_id]:
cur_exception, curSeason = cur_exception_dict.items()[0] cur_exception, curSeason = cur_exception_dict.items()[0]
# updating internal scene cache
exceptionIndexerCache[helpers.full_sanitizeSceneName(cur_exception)] = cur_indexer_id
# if this exception isn't already in the DB then add it # if this exception isn't already in the DB then add it
if cur_exception not in existing_exceptions: if cur_exception not in existing_exceptions:
myDB.action("INSERT INTO scene_exceptions (indexer_id, show_name, season) VALUES (?,?,?)", myDB.action("INSERT INTO scene_exceptions (indexer_id, show_name, season) VALUES (?,?,?)",
@ -187,49 +205,29 @@ def retrieve_exceptions():
if changed_exceptions: if changed_exceptions:
logger.log(u"Updated scene exceptions") logger.log(u"Updated scene exceptions")
name_cache.clearCache() name_cache.clearCache()
exceptionCache = {}
exceptionSeasonCache = {}
else: else:
logger.log(u"No scene exceptions update needed") logger.log(u"No scene exceptions update needed")
# update indexer cache
updateIndexerCache()
def update_scene_exceptions(indexer_id, scene_exceptions): def update_scene_exceptions(indexer_id, scene_exceptions):
""" """
Given a indexer_id, and a list of all show scene exceptions, update the db. Given a indexer_id, and a list of all show scene exceptions, update the db.
""" """
global exceptionIndexerCache
myDB = db.DBConnection("cache.db") myDB = db.DBConnection("cache.db")
myDB.action('DELETE FROM scene_exceptions WHERE indexer_id=?', [indexer_id]) myDB.action('DELETE FROM scene_exceptions WHERE indexer_id=?', [indexer_id])
for cur_exception in scene_exceptions: logger.log(u"Updating internal scene name cache", logger.MESSAGE)
myDB.action("INSERT INTO scene_exceptions (indexer_id, show_name) VALUES (?,?)", [indexer_id, cur_exception]) for cur_exception, cur_season in scene_exceptions:
exceptionIndexerCache[helpers.full_sanitizeSceneName(cur_exception)] = indexer_id
myDB.action("INSERT INTO scene_exceptions (indexer_id, show_name, season) VALUES (?,?,?)",
[indexer_id, cur_exception, cur_season])
name_cache.clearCache() name_cache.clearCache()
def updateIndexerCache():
logger.log(u"Updating internal scene name cache", logger.MESSAGE)
_excpetionDots = []
global exceptionIndexerCache
exceptionIndexerCache = {}
for show in sickbeard.showList:
for curSeason in [-1] + sickbeard.scene_exceptions.get_scene_seasons(show.indexerid):
exceptionIndexerCache[helpers.full_sanitizeSceneName(show.name)] = show.indexerid
_excpetionDots.append(".")
for name in get_scene_exceptions(show.indexerid, season=curSeason):
exceptionIndexerCache[name] = show.indexerid
exceptionIndexerCache[helpers.full_sanitizeSceneName(name)] = show.indexerid
_excpetionDots.append(".")
logger.log(u"Updated internal scene name cache " + "".join(_excpetionDots), logger.MESSAGE)
logger.log(u"Internal scene name cache set to: " + str(exceptionIndexerCache), logger.DEBUG)
def _retrieve_anidb_mainnames(): def _retrieve_anidb_mainnames():
anidb_mainNames = {} anidb_mainNames = {}
for show in sickbeard.showList: for show in sickbeard.showList:
if show.is_anime and show.indexer == 1: if show.is_anime and show.indexer == 1:
@ -241,9 +239,9 @@ def _retrieve_anidb_mainnames():
if anime.name and anime.name != show.name: if anime.name and anime.name != show.name:
anidb_mainNames[show.indexerid] = [{anime.name: -1}] anidb_mainNames[show.indexerid] = [{anime.name: -1}]
#logger.log("anidb anime names: " + str(anidb_mainNames), logger.DEBUG)
return anidb_mainNames return anidb_mainNames
def _xem_excpetions_fetcher(indexer): def _xem_excpetions_fetcher(indexer):
exception_dict = {} exception_dict = {}
@ -260,9 +258,9 @@ def _xem_excpetions_fetcher(indexer):
for indexerid, names in url_data['data'].items(): for indexerid, names in url_data['data'].items():
exception_dict[int(indexerid)] = names exception_dict[int(indexerid)] = names
#logger.log(u"xem exception dict: " + str(exception_dict), logger.DEBUG)
return exception_dict return exception_dict
def getSceneSeasons(indexer_id): def getSceneSeasons(indexer_id):
"""get a list of season numbers that have scene excpetions """get a list of season numbers that have scene excpetions
""" """