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(
|
jsonurl = urlopen("{0}?cmd=show.seasons&tvdbid={1}".format(
|
||||||
self.__getapiurl(), showid))
|
self.__getapiurl(), showid))
|
||||||
|
print jsonurl.__class__
|
||||||
|
print jsonurl.__class__.__name__
|
||||||
result = json.loads(jsonurl.read())
|
result = json.loads(jsonurl.read())
|
||||||
|
|
||||||
for season in result['data']:
|
for season in result['data']:
|
||||||
for episode in result['data'][season]:
|
for episode in result['data'][season]:
|
||||||
episodename = result['data'][season][episode]['name']
|
episodename = result['data'][season][episode]['name']
|
||||||
if name is not None and fuzz.partial_ratio(name.lower(),
|
if name is not None and fuzz.ratio(name.lower(),
|
||||||
episodename) > 90:
|
episodename.lower()) > 85:
|
||||||
return (season, episode, episodename)
|
return (season, episode, episodename)
|
||||||
elif description is not None:
|
elif description is not None:
|
||||||
descriptionqueryresult = \
|
descriptionqueryresult = \
|
||||||
@@ -84,14 +86,6 @@ class Sickbeard:
|
|||||||
|
|
||||||
return (0, 0, '')
|
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):
|
def fixepisodetitle(self, showname, episodetitle):
|
||||||
"""
|
"""
|
||||||
Check to see if there is a prefix specified for the show. If there is,
|
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.assertTrue(result.doencode)
|
||||||
self.assertFalse(result.readonly)
|
self.assertFalse(result.readonly)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
suite = unittest.TestLoader().loadTestsFromTestCase(TVEncoderTest)
|
suite = unittest.TestLoader().loadTestsFromTestCase(TVEncoderTest)
|
||||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||||
@@ -12,17 +12,12 @@ import sys
|
|||||||
parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
sys.path.insert(0, parentdir)
|
sys.path.insert(0, parentdir)
|
||||||
import libemail
|
import libemail
|
||||||
#from libsettings import EmailSettings
|
from libsettings import EmailSettings
|
||||||
import smtplib
|
import smtplib
|
||||||
|
|
||||||
|
|
||||||
class libemailtest(unittest.TestCase):
|
class libemailtest(unittest.TestCase):
|
||||||
def test_SendEmail(self):
|
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.getfromaddress", returns="from@email.com")
|
||||||
mock("EmailSettings.gettoaddress", returns="to@email.com")
|
mock("EmailSettings.gettoaddress", returns="to@email.com")
|
||||||
mock("EmailSettings.getsmtpserver", returns="smtp.test")
|
mock("EmailSettings.getsmtpserver", returns="smtp.test")
|
||||||
|
|||||||
@@ -4,3 +4,48 @@ Created on Fri Jul 5 14:12:38 2013
|
|||||||
|
|
||||||
@author: shanef
|
@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