Fixed fuzzy episode name matching logic
This commit is contained in:
@@ -67,13 +67,15 @@ class Sickbeard:
|
||||
|
||||
jsonurl = urlopen("{0}?cmd=show.seasons&tvdbid={1}".format(
|
||||
self.__getapiurl(), showid))
|
||||
print jsonurl.__class__
|
||||
print jsonurl.__class__.__name__
|
||||
result = json.loads(jsonurl.read())
|
||||
|
||||
for season in result['data']:
|
||||
for episode in result['data'][season]:
|
||||
episodename = result['data'][season][episode]['name']
|
||||
if name is not None and fuzz.partial_ratio(name.lower(),
|
||||
episodename) > 90:
|
||||
if name is not None and fuzz.ratio(name.lower(),
|
||||
episodename.lower()) > 85:
|
||||
return (season, episode, episodename)
|
||||
elif description is not None:
|
||||
descriptionqueryresult = \
|
||||
@@ -84,14 +86,6 @@ class Sickbeard:
|
||||
|
||||
return (0, 0, '')
|
||||
|
||||
#==============================================================================
|
||||
# def GetEpisodeName(subtitle, showName):
|
||||
# if subtitle[:len(showName)].lower() == showName.lower():
|
||||
# return subtitle[len(showName + ' and the '):]
|
||||
# else:
|
||||
# return subtitle
|
||||
#==============================================================================
|
||||
|
||||
def fixepisodetitle(self, showname, episodetitle):
|
||||
"""
|
||||
Check to see if there is a prefix specified for the show. If there is,
|
||||
|
||||
@@ -40,6 +40,7 @@ class TVEncoderTest(unittest.TestCase):
|
||||
self.assertTrue(result.doencode)
|
||||
self.assertFalse(result.readonly)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(TVEncoderTest)
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
@@ -12,17 +12,12 @@ import sys
|
||||
parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
sys.path.insert(0, parentdir)
|
||||
import libemail
|
||||
#from libsettings import EmailSettings
|
||||
from libsettings import EmailSettings
|
||||
import smtplib
|
||||
|
||||
|
||||
class libemailtest(unittest.TestCase):
|
||||
def test_SendEmail(self):
|
||||
#EmailSettings = Mock('libsettings.EmailSettings')
|
||||
#libsettings.EmailSettings.mock_returns = Mock('emailsettings')
|
||||
|
||||
#EmailSettings.getfromaddress.mock_returns = "from@email.com"
|
||||
#libsettings.EmailSettings.gettoaddress.mock_returns = "to@gmail.com"
|
||||
mock("EmailSettings.getfromaddress", returns="from@email.com")
|
||||
mock("EmailSettings.gettoaddress", returns="to@email.com")
|
||||
mock("EmailSettings.getsmtpserver", returns="smtp.test")
|
||||
|
||||
@@ -4,3 +4,48 @@ Created on Fri Jul 5 14:12:38 2013
|
||||
|
||||
@author: shanef
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from minimock import Mock
|
||||
import os
|
||||
import sys
|
||||
parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
sys.path.insert(0, parentdir)
|
||||
import libsickbeard
|
||||
import urllib
|
||||
|
||||
|
||||
class SickbeardTest(unittest.TestCase):
|
||||
def test_findepisodeCloseSubtitle(self):
|
||||
settings = Mock('libsettings.Settings')
|
||||
settings.sickbeardaddress.mock_returns = "test"
|
||||
settings.sickbeardport.mock_returns = "test"
|
||||
settings.sickbeardapikey.mock_returns = "test"
|
||||
|
||||
urllib.urlopen = dummy_urlopen
|
||||
|
||||
sickbeard = libsickbeard.Sickbeard(settings)
|
||||
|
||||
result = sickbeard.findepisode("78949", "Splish, Splash, Splosh")
|
||||
|
||||
self.assertEqual("13", result[0])
|
||||
self.assertEqual("15", result[1])
|
||||
self.assertEqual("Splish, Splash, Splosh!", result[2])
|
||||
|
||||
|
||||
def dummy_urlopen(arg):
|
||||
class TmpClass:
|
||||
def read(arg):
|
||||
jsonresult = '{ "data": {"13": { "15": { "airdate": "2010-02-12", ' \
|
||||
'"name": "Splish, Splash, Splosh!", "quality": "N/A", ' \
|
||||
'"status": "Wanted" } } }, "message": "", ' \
|
||||
'"result": "success" }'
|
||||
|
||||
return jsonresult
|
||||
|
||||
return TmpClass()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(SickbeardTest)
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
|
||||
Reference in New Issue
Block a user