mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-07 10:33:38 +00:00
Remove various unused code
This commit is contained in:
parent
f395a72d2c
commit
2dab61478e
7 changed files with 6 additions and 307 deletions
|
@ -355,7 +355,6 @@ NMJ_HOST = None
|
||||||
NMJ_DATABASE = None
|
NMJ_DATABASE = None
|
||||||
NMJ_MOUNT = None
|
NMJ_MOUNT = None
|
||||||
|
|
||||||
ANIMESUPPORT = False
|
|
||||||
USE_ANIDB = False
|
USE_ANIDB = False
|
||||||
ANIDB_USERNAME = None
|
ANIDB_USERNAME = None
|
||||||
ANIDB_PASSWORD = None
|
ANIDB_PASSWORD = None
|
||||||
|
@ -523,7 +522,7 @@ def initialize(consoleLogging=True):
|
||||||
ADD_SHOWS_WO_DIR, USE_SUBTITLES, SUBTITLES_LANGUAGES, SUBTITLES_DIR, SUBTITLES_SERVICES_LIST, SUBTITLES_SERVICES_ENABLED, SUBTITLES_HISTORY, SUBTITLES_FINDER_FREQUENCY, subtitlesFinderScheduler, \
|
ADD_SHOWS_WO_DIR, USE_SUBTITLES, SUBTITLES_LANGUAGES, SUBTITLES_DIR, SUBTITLES_SERVICES_LIST, SUBTITLES_SERVICES_ENABLED, SUBTITLES_HISTORY, SUBTITLES_FINDER_FREQUENCY, subtitlesFinderScheduler, \
|
||||||
USE_FAILED_DOWNLOADS, DELETE_FAILED, ANON_REDIRECT, LOCALHOST_IP, TMDB_API_KEY, DEBUG, PROXY_SETTING, PROXY_INDEXERS, \
|
USE_FAILED_DOWNLOADS, DELETE_FAILED, ANON_REDIRECT, LOCALHOST_IP, TMDB_API_KEY, DEBUG, PROXY_SETTING, PROXY_INDEXERS, \
|
||||||
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, USE_ANIDB, ANIDB_USERNAME, ANIDB_PASSWORD, ANIDB_USE_MYLIST, \
|
||||||
ANIME_SPLIT_HOME, SCENE_DEFAULT, BACKLOG_DAYS, ANIME_TREAT_AS_HDTV, \
|
ANIME_SPLIT_HOME, SCENE_DEFAULT, BACKLOG_DAYS, ANIME_TREAT_AS_HDTV, \
|
||||||
COOKIE_SECRET, USE_IMDB_INFO
|
COOKIE_SECRET, USE_IMDB_INFO
|
||||||
|
|
||||||
|
@ -964,7 +963,6 @@ def initialize(consoleLogging=True):
|
||||||
|
|
||||||
USE_LISTVIEW = bool(check_setting_int(CFG, 'General', 'use_listview', 0))
|
USE_LISTVIEW = bool(check_setting_int(CFG, 'General', 'use_listview', 0))
|
||||||
|
|
||||||
ANIMESUPPORT = False
|
|
||||||
USE_ANIDB = bool(check_setting_int(CFG, 'ANIDB', 'use_anidb', 0))
|
USE_ANIDB = bool(check_setting_int(CFG, 'ANIDB', 'use_anidb', 0))
|
||||||
ANIDB_USERNAME = check_setting_str(CFG, 'ANIDB', 'anidb_username', '')
|
ANIDB_USERNAME = check_setting_str(CFG, 'ANIDB', 'anidb_username', '')
|
||||||
ANIDB_PASSWORD = check_setting_str(CFG, 'ANIDB', 'anidb_password', '')
|
ANIDB_PASSWORD = check_setting_str(CFG, 'ANIDB', 'anidb_password', '')
|
||||||
|
|
|
@ -171,15 +171,6 @@ def isRarFile(filename):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def isBeingWritten(filepath):
|
|
||||||
# Return True if file was modified within 60 seconds. it might still be being written to.
|
|
||||||
ctime = max(ek.ek(os.path.getctime, filepath), ek.ek(os.path.getmtime, filepath))
|
|
||||||
if ctime > time.time() - 60:
|
|
||||||
return True
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def sanitizeFileName(name):
|
def sanitizeFileName(name):
|
||||||
'''
|
'''
|
||||||
>>> sanitizeFileName('a/b/c')
|
>>> sanitizeFileName('a/b/c')
|
||||||
|
@ -230,43 +221,6 @@ def makeDir(path):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def searchDBForShow(regShowName, log=False):
|
|
||||||
showNames = [re.sub('[. -]', ' ', regShowName)]
|
|
||||||
|
|
||||||
yearRegex = "([^()]+?)\s*(\()?(\d{4})(?(2)\))$"
|
|
||||||
|
|
||||||
myDB = db.DBConnection()
|
|
||||||
for showName in showNames:
|
|
||||||
|
|
||||||
sqlResults = myDB.select("SELECT * FROM tv_shows WHERE show_name LIKE ?",
|
|
||||||
[showName])
|
|
||||||
|
|
||||||
if len(sqlResults) == 1:
|
|
||||||
return int(sqlResults[0]["indexer_id"])
|
|
||||||
else:
|
|
||||||
# if we didn't get exactly one result then try again with the year stripped off if possible
|
|
||||||
match = re.match(yearRegex, showName)
|
|
||||||
if match and match.group(1):
|
|
||||||
if log:
|
|
||||||
logger.log(u"Unable to match original name but trying to manually strip and specify show year",
|
|
||||||
logger.DEBUG)
|
|
||||||
sqlResults = myDB.select(
|
|
||||||
"SELECT * FROM tv_shows WHERE (show_name LIKE ?) AND startyear = ?",
|
|
||||||
[match.group(1) + '%', match.group(3)])
|
|
||||||
|
|
||||||
if len(sqlResults) == 0:
|
|
||||||
if log:
|
|
||||||
logger.log(u"Unable to match a record in the DB for " + showName, logger.DEBUG)
|
|
||||||
continue
|
|
||||||
elif len(sqlResults) > 1:
|
|
||||||
if log:
|
|
||||||
logger.log(u"Multiple results for " + showName + " in the DB, unable to match show name",
|
|
||||||
logger.DEBUG)
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
return int(sqlResults[0]["indexer_id"])
|
|
||||||
|
|
||||||
|
|
||||||
def searchIndexerForShowID(regShowName, indexer=None, indexer_id=None, ui=None):
|
def searchIndexerForShowID(regShowName, indexer=None, indexer_id=None, ui=None):
|
||||||
showNames = [re.sub('[. -]', ' ', regShowName)]
|
showNames = [re.sub('[. -]', ' ', regShowName)]
|
||||||
|
|
||||||
|
@ -611,17 +565,6 @@ def fixSetGroupID(childPath):
|
||||||
childPath, parentGID), logger.ERROR)
|
childPath, parentGID), logger.ERROR)
|
||||||
|
|
||||||
|
|
||||||
def is_anime_in_show_list():
|
|
||||||
for show in sickbeard.showList:
|
|
||||||
if show.is_anime:
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def update_anime_support():
|
|
||||||
sickbeard.ANIMESUPPORT = is_anime_in_show_list()
|
|
||||||
|
|
||||||
|
|
||||||
def get_absolute_number_from_season_and_episode(show, season, episode):
|
def get_absolute_number_from_season_and_episode(show, season, episode):
|
||||||
absolute_number = None
|
absolute_number = None
|
||||||
|
|
||||||
|
@ -733,24 +676,6 @@ if __name__ == '__main__':
|
||||||
doctest.testmod()
|
doctest.testmod()
|
||||||
|
|
||||||
|
|
||||||
def parse_json(data):
|
|
||||||
"""
|
|
||||||
Parse json data into a python object
|
|
||||||
|
|
||||||
data: data string containing json
|
|
||||||
|
|
||||||
Returns: parsed data as json or None
|
|
||||||
"""
|
|
||||||
|
|
||||||
try:
|
|
||||||
parsedJSON = json.loads(data)
|
|
||||||
except ValueError, e:
|
|
||||||
logger.log(u"Error trying to decode json data. Error: " + ex(e), logger.DEBUG)
|
|
||||||
return None
|
|
||||||
|
|
||||||
return parsedJSON
|
|
||||||
|
|
||||||
|
|
||||||
def parse_xml(data, del_xmlns=False):
|
def parse_xml(data, del_xmlns=False):
|
||||||
"""
|
"""
|
||||||
Parse data into an xml elementtree.ElementTree
|
Parse data into an xml elementtree.ElementTree
|
||||||
|
@ -773,32 +698,6 @@ def parse_xml(data, del_xmlns=False):
|
||||||
return parsedXML
|
return parsedXML
|
||||||
|
|
||||||
|
|
||||||
def get_xml_text(element, mini_dom=False):
|
|
||||||
"""
|
|
||||||
Get all text inside a xml element
|
|
||||||
|
|
||||||
element: A xml element either created with elementtree.ElementTree or xml.dom.minidom
|
|
||||||
mini_dom: Default False use elementtree, True use minidom
|
|
||||||
|
|
||||||
Returns: text
|
|
||||||
"""
|
|
||||||
|
|
||||||
text = ""
|
|
||||||
|
|
||||||
if mini_dom:
|
|
||||||
node = element
|
|
||||||
for child in node.childNodes:
|
|
||||||
if child.nodeType in (Node.CDATA_SECTION_NODE, Node.TEXT_NODE):
|
|
||||||
text += child.data
|
|
||||||
else:
|
|
||||||
if element is not None:
|
|
||||||
for child in [element] + element.findall('.//*'):
|
|
||||||
if child.text:
|
|
||||||
text += child.text
|
|
||||||
|
|
||||||
return text.strip()
|
|
||||||
|
|
||||||
|
|
||||||
def backupVersionedFile(old_file, version):
|
def backupVersionedFile(old_file, version):
|
||||||
numTries = 0
|
numTries = 0
|
||||||
|
|
||||||
|
@ -987,6 +886,7 @@ To add a new encryption_version:
|
||||||
# Key Generators
|
# Key Generators
|
||||||
unique_key1 = hex(uuid.getnode() ** 2) # Used in encryption v1
|
unique_key1 = hex(uuid.getnode() ** 2) # Used in encryption v1
|
||||||
|
|
||||||
|
|
||||||
# Encryption Functions
|
# Encryption Functions
|
||||||
def encrypt(data, encryption_version=0, decrypt=False):
|
def encrypt(data, encryption_version=0, decrypt=False):
|
||||||
# Version 1: Simple XOR encryption (this is not very secure, but works)
|
# Version 1: Simple XOR encryption (this is not very secure, but works)
|
||||||
|
@ -1009,21 +909,6 @@ def full_sanitizeSceneName(name):
|
||||||
return re.sub('[. -]', ' ', sanitizeSceneName(name)).lower().lstrip()
|
return re.sub('[. -]', ' ', sanitizeSceneName(name)).lower().lstrip()
|
||||||
|
|
||||||
|
|
||||||
def _check_against_names(nameInQuestion, show, season=-1):
|
|
||||||
showNames = []
|
|
||||||
if season in [-1, 1]:
|
|
||||||
showNames = [show.name]
|
|
||||||
|
|
||||||
showNames.extend(sickbeard.scene_exceptions.get_scene_exceptions(show.indexerid, season=season))
|
|
||||||
|
|
||||||
for showName in showNames:
|
|
||||||
nameFromList = full_sanitizeSceneName(showName)
|
|
||||||
if nameFromList == nameInQuestion:
|
|
||||||
return True
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def get_show(name, tryIndexers=False):
|
def get_show(name, tryIndexers=False):
|
||||||
if not sickbeard.showList or None is name:
|
if not sickbeard.showList or None is name:
|
||||||
return
|
return
|
||||||
|
@ -1121,51 +1006,6 @@ def set_up_anidb_connection():
|
||||||
return sickbeard.ADBA_CONNECTION.authed()
|
return sickbeard.ADBA_CONNECTION.authed()
|
||||||
|
|
||||||
|
|
||||||
def makeZip(fileList, archive):
|
|
||||||
"""
|
|
||||||
'fileList' is a list of file names - full path each name
|
|
||||||
'archive' is the file name for the archive with a full path
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
a = zipfile.ZipFile(archive, 'w', zipfile.ZIP_DEFLATED)
|
|
||||||
for f in fileList:
|
|
||||||
a.write(f)
|
|
||||||
a.close()
|
|
||||||
return True
|
|
||||||
except Exception as e:
|
|
||||||
logger.log(u"Zip creation error: " + str(e), logger.ERROR)
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def extractZip(archive, targetDir):
|
|
||||||
"""
|
|
||||||
'fileList' is a list of file names - full path each name
|
|
||||||
'archive' is the file name for the archive with a full path
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
if not os.path.exists(targetDir):
|
|
||||||
os.mkdir(targetDir)
|
|
||||||
|
|
||||||
zip_file = zipfile.ZipFile(archive, 'r')
|
|
||||||
for member in zip_file.namelist():
|
|
||||||
filename = os.path.basename(member)
|
|
||||||
# skip directories
|
|
||||||
if not filename:
|
|
||||||
continue
|
|
||||||
|
|
||||||
# copy file (taken from zipfile's extract)
|
|
||||||
source = zip_file.open(member)
|
|
||||||
target = file(os.path.join(targetDir, filename), "wb")
|
|
||||||
shutil.copyfileobj(source, target)
|
|
||||||
source.close()
|
|
||||||
target.close()
|
|
||||||
zip_file.close()
|
|
||||||
return True
|
|
||||||
except Exception as e:
|
|
||||||
logger.log(u"Zip extraction error: " + str(e), logger.ERROR)
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def mapIndexersToShow(showObj):
|
def mapIndexersToShow(showObj):
|
||||||
mapped = {}
|
mapped = {}
|
||||||
|
|
||||||
|
@ -1481,6 +1321,7 @@ def clearCache(force=False):
|
||||||
logger.WARNING)
|
logger.WARNING)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
def human(size):
|
def human(size):
|
||||||
"""
|
"""
|
||||||
format a size in bytes into a 'human' file size, e.g. bytes, KB, MB, GB, TB, PB
|
format a size in bytes into a 'human' file size, e.g. bytes, KB, MB, GB, TB, PB
|
||||||
|
@ -1528,6 +1369,7 @@ def maybe_plural(number=1):
|
||||||
def build_dict(seq, key):
|
def build_dict(seq, key):
|
||||||
return dict((d[key], dict(d, index=index)) for (index, d) in enumerate(seq))
|
return dict((d[key], dict(d, index=index)) for (index, d) in enumerate(seq))
|
||||||
|
|
||||||
|
|
||||||
def client_host(server_host):
|
def client_host(server_host):
|
||||||
'''Extracted from cherrypy libs
|
'''Extracted from cherrypy libs
|
||||||
Return the host on which a client can connect to the given listener.'''
|
Return the host on which a client can connect to the given listener.'''
|
||||||
|
|
|
@ -321,12 +321,4 @@ def _xem_exceptions_fetcher():
|
||||||
|
|
||||||
setLastRefresh('xem')
|
setLastRefresh('xem')
|
||||||
|
|
||||||
return xem_exception_dict
|
return xem_exception_dict
|
||||||
|
|
||||||
|
|
||||||
def getSceneSeasons(indexer_id):
|
|
||||||
"""get a list of season numbers that have scene exceptions
|
|
||||||
"""
|
|
||||||
myDB = db.DBConnection('cache.db')
|
|
||||||
seasons = myDB.select("SELECT DISTINCT season FROM scene_exceptions WHERE indexer_id = ?", [indexer_id])
|
|
||||||
return [cur_exception["season"] for cur_exception in seasons]
|
|
|
@ -80,40 +80,6 @@ def filterBadReleases(name, parse=True):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def sceneToNormalShowNames(name):
|
|
||||||
"""
|
|
||||||
Takes a show name from a scene dirname and converts it to a more "human-readable" format.
|
|
||||||
|
|
||||||
name: The show name to convert
|
|
||||||
|
|
||||||
Returns: a list of all the possible "normal" names
|
|
||||||
"""
|
|
||||||
|
|
||||||
if not name:
|
|
||||||
return []
|
|
||||||
|
|
||||||
name_list = [name]
|
|
||||||
|
|
||||||
# use both and and &
|
|
||||||
new_name = re.sub('(?i)([\. ])and([\. ])', '\\1&\\2', name, re.I)
|
|
||||||
if new_name not in name_list:
|
|
||||||
name_list.append(new_name)
|
|
||||||
|
|
||||||
results = []
|
|
||||||
|
|
||||||
for cur_name in name_list:
|
|
||||||
# add brackets around the year
|
|
||||||
results.append(re.sub('(\D)(\d{4})$', '\\1(\\2)', cur_name))
|
|
||||||
|
|
||||||
# add brackets around the country
|
|
||||||
country_match_str = '|'.join(common.countryList.values())
|
|
||||||
results.append(re.sub('(?i)([. _-])(' + country_match_str + ')$', '\\1(\\2)', cur_name))
|
|
||||||
|
|
||||||
results += name_list
|
|
||||||
|
|
||||||
return list(set(results))
|
|
||||||
|
|
||||||
|
|
||||||
def makeSceneShowSearchStrings(show, season=-1):
|
def makeSceneShowSearchStrings(show, season=-1):
|
||||||
showNames = allPossibleShowNames(show, season=season)
|
showNames = allPossibleShowNames(show, season=season)
|
||||||
|
|
||||||
|
@ -225,40 +191,6 @@ def makeSceneSearchString(show, ep_obj):
|
||||||
return toReturn
|
return toReturn
|
||||||
|
|
||||||
|
|
||||||
def isGoodResult(name, show, log=True, season=-1):
|
|
||||||
"""
|
|
||||||
Use an automatically-created regex to make sure the result actually is the show it claims to be
|
|
||||||
"""
|
|
||||||
|
|
||||||
all_show_names = allPossibleShowNames(show, season=season)
|
|
||||||
showNames = map(sanitizeSceneName, all_show_names) + all_show_names
|
|
||||||
showNames += map(unidecode, all_show_names)
|
|
||||||
|
|
||||||
for curName in set(showNames):
|
|
||||||
if not show.is_anime:
|
|
||||||
escaped_name = re.sub('\\\\[\\s.-]', '\W+', re.escape(curName))
|
|
||||||
if show.startyear:
|
|
||||||
escaped_name += "(?:\W+" + str(show.startyear) + ")?"
|
|
||||||
curRegex = '^' + escaped_name + '\W+(?:(?:S\d[\dE._ -])|(?:\d\d?x)|(?:\d{4}\W\d\d\W\d\d)|(?:(?:part|pt)[\._ -]?(\d|[ivx]))|Season\W+\d+\W+|E\d+\W+|(?:\d{1,3}.+\d{1,}[a-zA-Z]{2}\W+[a-zA-Z]{3,}\W+\d{4}.+))'
|
|
||||||
else:
|
|
||||||
escaped_name = re.sub('\\\\[\\s.-]', '[\W_]+', re.escape(curName))
|
|
||||||
# FIXME: find a "automatically-created" regex for anime releases # test at http://regexr.com?2uon3
|
|
||||||
curRegex = '^((\[.*?\])|(\d+[\.-]))*[ _\.]*' + escaped_name + '(([ ._-]+\d+)|([ ._-]+s\d{2})).*'
|
|
||||||
|
|
||||||
if log:
|
|
||||||
logger.log(u"Checking if show " + name + " matches " + curRegex, logger.DEBUG)
|
|
||||||
|
|
||||||
match = re.search(curRegex, name, re.I)
|
|
||||||
if match:
|
|
||||||
logger.log(u"Matched " + curRegex + " to " + name, logger.DEBUG)
|
|
||||||
return True
|
|
||||||
|
|
||||||
if log:
|
|
||||||
logger.log(
|
|
||||||
u"Provider gave result " + name + " but that doesn't seem like a valid result for " + show.name + " so I'm ignoring it")
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def allPossibleShowNames(show, season=-1):
|
def allPossibleShowNames(show, season=-1):
|
||||||
"""
|
"""
|
||||||
Figures out every possible variation of the name for a particular show. Includes TVDB name, TVRage name,
|
Figures out every possible variation of the name for a particular show. Includes TVDB name, TVRage name,
|
||||||
|
|
|
@ -1187,8 +1187,6 @@ class TVShow(object):
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
myDB.upsert("tv_shows", newValueDict, controlValueDict)
|
myDB.upsert("tv_shows", newValueDict, controlValueDict)
|
||||||
|
|
||||||
helpers.update_anime_support()
|
|
||||||
|
|
||||||
if sickbeard.USE_IMDB_INFO and self.imdbid:
|
if sickbeard.USE_IMDB_INFO and self.imdbid:
|
||||||
controlValueDict = {'indexer_id': self.indexerid}
|
controlValueDict = {'indexer_id': self.indexerid}
|
||||||
newValueDict = self.imdb_info
|
newValueDict = self.imdb_info
|
||||||
|
|
|
@ -7,33 +7,11 @@ import webapi
|
||||||
|
|
||||||
from sickbeard import logger
|
from sickbeard import logger
|
||||||
from sickbeard.helpers import create_https_certificates
|
from sickbeard.helpers import create_https_certificates
|
||||||
from tornado.web import Application, StaticFileHandler, HTTPError
|
from tornado.web import Application, StaticFileHandler
|
||||||
from tornado.httpserver import HTTPServer
|
from tornado.httpserver import HTTPServer
|
||||||
from tornado.ioloop import IOLoop
|
from tornado.ioloop import IOLoop
|
||||||
|
|
||||||
|
|
||||||
class MultiStaticFileHandler(StaticFileHandler):
|
|
||||||
def initialize(self, paths, default_filename=None):
|
|
||||||
self.paths = paths
|
|
||||||
self.default_filename = default_filename
|
|
||||||
|
|
||||||
def get(self, path, include_body=True):
|
|
||||||
for p in self.paths:
|
|
||||||
try:
|
|
||||||
# Initialize the Static file with a path
|
|
||||||
super(MultiStaticFileHandler, self).initialize(p)
|
|
||||||
# Try to get the file
|
|
||||||
return super(MultiStaticFileHandler, self).get(path)
|
|
||||||
except HTTPError as exc:
|
|
||||||
# File not found, carry on
|
|
||||||
if exc.status_code == 404:
|
|
||||||
continue
|
|
||||||
raise
|
|
||||||
|
|
||||||
# Oops file not found anywhere!
|
|
||||||
raise HTTPError(404)
|
|
||||||
|
|
||||||
|
|
||||||
class WebServer(threading.Thread):
|
class WebServer(threading.Thread):
|
||||||
def __init__(self, options={}, io_loop=None):
|
def __init__(self, options={}, io_loop=None):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
|
|
|
@ -14,14 +14,6 @@ from sickbeard.tv import TVShow as Show
|
||||||
|
|
||||||
class SceneTests(test.SickbeardTestDBCase):
|
class SceneTests(test.SickbeardTestDBCase):
|
||||||
|
|
||||||
def _test_sceneToNormalShowNames(self, name, expected):
|
|
||||||
result = show_name_helpers.sceneToNormalShowNames(name)
|
|
||||||
self.assertTrue(len(set(expected).intersection(set(result))) == len(expected))
|
|
||||||
|
|
||||||
dot_result = show_name_helpers.sceneToNormalShowNames(name.replace(' ', '.'))
|
|
||||||
dot_expected = [x.replace(' ', '.') for x in expected]
|
|
||||||
self.assertTrue(len(set(dot_expected).intersection(set(dot_result))) == len(dot_expected))
|
|
||||||
|
|
||||||
def _test_allPossibleShowNames(self, name, indexerid=0, expected=[]):
|
def _test_allPossibleShowNames(self, name, indexerid=0, expected=[]):
|
||||||
s = Show(1, indexerid)
|
s = Show(1, indexerid)
|
||||||
s.name = name
|
s.name = name
|
||||||
|
@ -33,39 +25,6 @@ class SceneTests(test.SickbeardTestDBCase):
|
||||||
result = show_name_helpers.filterBadReleases(name)
|
result = show_name_helpers.filterBadReleases(name)
|
||||||
self.assertEqual(result, expected)
|
self.assertEqual(result, expected)
|
||||||
|
|
||||||
def _test_isGoodName(self, name, show):
|
|
||||||
self.assertTrue(show_name_helpers.isGoodResult(name, show))
|
|
||||||
|
|
||||||
def test_isGoodName(self):
|
|
||||||
listOfcases = [('Show.Name.S01E02.Test-Test', 'Show/Name'),
|
|
||||||
('Show.Name.S01E02.Test-Test', 'Show. Name'),
|
|
||||||
('Show.Name.S01E02.Test-Test', 'Show- Name'),
|
|
||||||
('Show.Name.Part.IV.Test-Test', 'Show Name'),
|
|
||||||
('Show.Name.S01.Test-Test', 'Show Name'),
|
|
||||||
('Show.Name.E02.Test-Test', 'Show: Name'),
|
|
||||||
('Show Name Season 2 Test', 'Show: Name'),
|
|
||||||
]
|
|
||||||
|
|
||||||
for testCase in listOfcases:
|
|
||||||
scene_name, show_name = testCase
|
|
||||||
s = Show(1, 0)
|
|
||||||
s.name = show_name
|
|
||||||
self._test_isGoodName(scene_name, s)
|
|
||||||
|
|
||||||
def test_sceneToNormalShowNames(self):
|
|
||||||
self._test_sceneToNormalShowNames('Show Name 2010', ['Show Name 2010', 'Show Name (2010)'])
|
|
||||||
self._test_sceneToNormalShowNames('Show Name US', ['Show Name US', 'Show Name (US)'])
|
|
||||||
self._test_sceneToNormalShowNames('Show Name AU', ['Show Name AU', 'Show Name (AU)'])
|
|
||||||
self._test_sceneToNormalShowNames('Show Name CA', ['Show Name CA', 'Show Name (CA)'])
|
|
||||||
self._test_sceneToNormalShowNames('Show and Name', ['Show and Name', 'Show & Name'])
|
|
||||||
self._test_sceneToNormalShowNames('Show and Name 2010', ['Show and Name 2010', 'Show & Name 2010', 'Show and Name (2010)', 'Show & Name (2010)'])
|
|
||||||
self._test_sceneToNormalShowNames('show name us', ['show name us', 'show name (us)'])
|
|
||||||
self._test_sceneToNormalShowNames('Show And Name', ['Show And Name', 'Show & Name'])
|
|
||||||
|
|
||||||
# failure cases
|
|
||||||
self._test_sceneToNormalShowNames('Show Name 90210', ['Show Name 90210'])
|
|
||||||
self._test_sceneToNormalShowNames('Show Name YA', ['Show Name YA'])
|
|
||||||
|
|
||||||
def test_allPossibleShowNames(self):
|
def test_allPossibleShowNames(self):
|
||||||
#common.sceneExceptions[-1] = ['Exception Test']
|
#common.sceneExceptions[-1] = ['Exception Test']
|
||||||
myDB = db.DBConnection("cache.db")
|
myDB = db.DBConnection("cache.db")
|
||||||
|
|
Loading…
Reference in a new issue