making looking for duplicates case insensitive
This commit is contained in:
@@ -35,12 +35,12 @@ class EncodeData:
|
||||
|
||||
errors = []
|
||||
|
||||
if os.path.exists(self.outputfile):
|
||||
if checkfileexists(self.outputfile, False):
|
||||
errors.append("FILE_EXISTS")
|
||||
|
||||
if self.outputfile[-5:-4] == "_":
|
||||
tempoutfile = self.outputfile[:-5] + self.outputfile[-4:]
|
||||
if os.path.exists(tempoutfile):
|
||||
if checkfileexists(tempoutfile, False):
|
||||
errors.append("FILE_EXISTS")
|
||||
|
||||
return errors
|
||||
@@ -155,12 +155,19 @@ class FileManager:
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def checkfileexists(filename):
|
||||
def checkfileexists(filename, casesensitive=True):
|
||||
"""
|
||||
Check to see if a file currently exists
|
||||
"""
|
||||
|
||||
if casesensitive:
|
||||
return os.path.exists(filename)
|
||||
else:
|
||||
filename = os.path.basename(filename)
|
||||
for dirfile in os.listdir(os.path.dirname(filename)):
|
||||
if (filename.lower() == dirfile.lower()):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def __getinputfilestoencode(self):
|
||||
"""
|
||||
@@ -215,3 +222,17 @@ def findseason(path, filename, readonly):
|
||||
os.makedirs(seasonpath)
|
||||
|
||||
return seasonpath
|
||||
|
||||
def checkfileexists(filename, casesensitive=True):
|
||||
"""
|
||||
Check to see if a file currently exists
|
||||
"""
|
||||
if casesensitive:
|
||||
return os.path.exists(filename)
|
||||
else:
|
||||
filename = os.path.basename(filename)
|
||||
for dirfile in os.listdir(os.path.dirname(filename)):
|
||||
if (filename.lower() == dirfile.lower()):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
14
settings.cfg
14
settings.cfg
@@ -22,49 +22,49 @@ IllegalCharacters = "?", ":"
|
||||
KidsTVDir = "/srv/storage2/videos/Kids/TV/"
|
||||
UnknownInput = "%(VideoProcessingDir)sUnknown/"
|
||||
[[ "Thomas the Tank Engine & Friends" ]]
|
||||
InputDirectory = "%(VideoProcessingDir)sThomas/Input/"
|
||||
InputDirectory = "%(VideoProcessingDir)sThomas/"
|
||||
UnknownDirectory = "%(UnknownInput)sThomas/"
|
||||
OutputDirectory = "%(KidsTVDir)sThomas The Tank Engine & Friends/"
|
||||
alias = "Thomas and Friends",
|
||||
MythTvEpisodePrefix = ,
|
||||
SickbeardPrefix = ""
|
||||
[[ "Chuggington" ]]
|
||||
InputDirectory = "%(VideoProcessingDir)sChuggington/Input/"
|
||||
InputDirectory = "%(VideoProcessingDir)sChuggington/"
|
||||
UnknownDirectory = "%(UnknownInput)sChuggington/"
|
||||
OutputDirectory = "%(KidsTVDir)sChuggington/"
|
||||
alias = ,
|
||||
MythTvEpisodePrefix = ,
|
||||
SickbeardPrefix = ""
|
||||
[[ "Mike the Knight" ]]
|
||||
InputDirectory = "%(VideoProcessingDir)sMikeTheKnight/Input/"
|
||||
InputDirectory = "%(VideoProcessingDir)sMikeTheKnight/"
|
||||
UnknownDirectory = "%(UnknownInput)sMikeTheKnight/"
|
||||
OutputDirectory = "%(KidsTVDir)sMike the Knight/"
|
||||
alias = ,
|
||||
MythTvEpisodePrefix = "Mike the Knight and the ", Mike the Knight and "
|
||||
SickbeardPrefix = ""
|
||||
[[ "Octonauts" ]]
|
||||
InputDirectory = "%(VideoProcessingDir)sOctonauts/Input/"
|
||||
InputDirectory = "%(VideoProcessingDir)sOctonauts/"
|
||||
UnknownDirectory = "%(UnknownInput)sOctonauts/"
|
||||
OutputDirectory = "%(KidsTVDir)sOctonauts/"
|
||||
alias = "The Octonauts",
|
||||
MythTvEpisodePrefix = "The Octonauts and ",
|
||||
SickbeardPrefix = "The"
|
||||
[[ "In the Night Garden" ]]
|
||||
InputDirectory = "%(VideoProcessingDir)sInTheNightGarden/Input/"
|
||||
InputDirectory = "%(VideoProcessingDir)sInTheNightGarden/"
|
||||
UnknownDirectory = "%(UnknownInput)sInTheNightGarden/"
|
||||
OutputDirectory = "%(KidsTVDir)sIn The Night Garden/"
|
||||
alias = ,
|
||||
MythTvEpisodePrefix = ,
|
||||
SickbeardPrefix = ""
|
||||
[[ "Raa Raa! The Noisy Lion" ]]
|
||||
InputDirectory = "%(VideoProcessingDir)sRaaRaa/Input/"
|
||||
InputDirectory = "%(VideoProcessingDir)sRaaRaa/"
|
||||
UnknownDirectory = "%(UnknownInput)sRaaRaa/"
|
||||
OutputDirectory = "%(KidsTVDir)sRaa Raa the Noisy Lion/"
|
||||
alias = ,
|
||||
MythTvEpisodePrefix = ,
|
||||
SickbeardPrefix = ""
|
||||
[[ "Fireman Sam" ]]
|
||||
InputDirectory = "%(VideoProcessingDir)sFiremanSam/Input/"
|
||||
InputDirectory = "%(VideoProcessingDir)sFiremanSam/"
|
||||
UnknownDirectory = "%(UnknownInput)sFiremanSam/"
|
||||
OutputDirectory = "%(KidsTVDir)sFireman Sam/"
|
||||
alias = ,
|
||||
|
||||
@@ -36,6 +36,7 @@ class libfilemanagertest(unittest.TestCase):
|
||||
result = data.checkproblems()
|
||||
|
||||
self.assertIn("FILE_EXISTS", result)
|
||||
minimock.restore()
|
||||
|
||||
def test_EncodeDataCheckProblemsFile_Exists(self):
|
||||
showname = "test show"
|
||||
@@ -45,6 +46,18 @@ class libfilemanagertest(unittest.TestCase):
|
||||
mock("os.path.exists", returns_iter=[False, True])
|
||||
result = data.checkproblems()
|
||||
self.assertIn("FILE_EXISTS", result)
|
||||
minimock.restore()
|
||||
|
||||
def test_checkfileexistscaseinsensitive(self):
|
||||
settings = Mock('libsettings.Settings')
|
||||
filemanager = FileManager(settings)
|
||||
|
||||
mock("os.listdir", returns=["filename.test"])
|
||||
|
||||
result = filemanager.checkfileexists("/path/to/fiLename.test", False)
|
||||
|
||||
self.assertTrue(result)
|
||||
minimock.restore()
|
||||
|
||||
def test_checkduplicateavi(self):
|
||||
settings = Mock('libsettings.Settings')
|
||||
@@ -55,6 +68,7 @@ class libfilemanagertest(unittest.TestCase):
|
||||
result = filemanager.checkduplicates("/path/to/S03E14 - Test - SD TV.mkv")
|
||||
|
||||
self.assertTrue(result)
|
||||
minimock.restore()
|
||||
|
||||
def test_checkduplicatenomatch(self):
|
||||
settings = Mock('libsettings.Settings')
|
||||
@@ -65,6 +79,7 @@ class libfilemanagertest(unittest.TestCase):
|
||||
result = filemanager.checkduplicates("/path/to/S03E13 - Test - SD TV.mkv")
|
||||
|
||||
self.assertFalse(result)
|
||||
minimock.restore()
|
||||
|
||||
def test_checkduplicatesameextension(self):
|
||||
settings = Mock('libsettings.Settings')
|
||||
@@ -75,6 +90,8 @@ class libfilemanagertest(unittest.TestCase):
|
||||
result = filemanager.checkduplicates("/path/to/S03E14 - Test - SD TV.avi")
|
||||
|
||||
self.assertFalse(result)
|
||||
minimock.restore()
|
||||
|
||||
|
||||
|
||||
def dummywalk(arg):
|
||||
|
||||
Reference in New Issue
Block a user