Ignore ? in filenames since they are illegal
This commit is contained in:
@@ -47,6 +47,12 @@ class Settings:
|
||||
|
||||
return self.__config["HandbrakeCommand"]
|
||||
|
||||
def illegalcharacters(self):
|
||||
"""Get a list of illegal characters for filenames
|
||||
"""
|
||||
|
||||
return self.__config["IllegalCharacters"]
|
||||
|
||||
def mythtvaddress(self):
|
||||
"""
|
||||
Get the MythTV/address setting
|
||||
|
||||
@@ -88,8 +88,8 @@ class TVData:
|
||||
seasonfolder = "Season {0}".format(show.season)
|
||||
season = "S{0}".format(show.season)
|
||||
episode = "E{0}".format(show.episode)
|
||||
renamedfile = "{0}{1} - {2} - SD TV_.mpg".format(season, episode,
|
||||
show.subtitle)
|
||||
renamedfile = self.getoutputfilename(season, episode,
|
||||
show.subtitle)
|
||||
|
||||
directory = self.getdirectory(show.title, seasonfolder,
|
||||
season, episode)
|
||||
@@ -102,20 +102,17 @@ class TVData:
|
||||
else:
|
||||
return None
|
||||
|
||||
#==============================================================================
|
||||
# def __determinetargetfilename(directory, filename, inputfilename):
|
||||
# """
|
||||
# Determine the filename for the input file. If the path does not
|
||||
# exist, it is created.
|
||||
# """
|
||||
#
|
||||
# inputdir = os.path.join(directory, inputfilename[:-4])
|
||||
#
|
||||
# if not os.path.exists(inputdir):
|
||||
# os.makedirs(inputdir)
|
||||
#
|
||||
# return os.path.join(inputdir, filename)
|
||||
#==============================================================================
|
||||
def getoutputfilename(self, season, episode, name):
|
||||
"""
|
||||
Get the output filename, and remove any illegal characters
|
||||
"""
|
||||
|
||||
filename = "{0}{1} - {2} - SD TV_.mpg".format(season, episode, name)
|
||||
|
||||
for illegalcharacter in self.__settings.illegalcharacters():
|
||||
filename = filename.replace(illegalcharacter, "")
|
||||
|
||||
return filename
|
||||
|
||||
@staticmethod
|
||||
def processepisode(inputfile, outputfile):
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
TVRecordings = "/Volumes/TV Recordings/"
|
||||
HandbrakeCommand = "HandBrakeCLI", "--verbose", "-i", "SUBSTITUTE WITH INPUT FILE", "-o", "SUBSTITUDE WITH OUTPUT FILE", "-f", "mkv", "-e", "x264", "-x264-preset", "slower", "-x264-tune", "animation", "-q", "20", "--loose-anamorphic", "--decomb", "--detelecine", '--denoise="2:1:2:3"', "--deblock"
|
||||
IllegalCharacters = "?"
|
||||
|
||||
[ "MythTV" ]
|
||||
address = 192.168.0.2
|
||||
@@ -30,7 +31,7 @@ HandbrakeCommand = "HandBrakeCLI", "--verbose", "-i", "SUBSTITUTE WITH INPUT FIL
|
||||
SickbeardPrefix = ""
|
||||
[[ "Mike the Knight" ]]
|
||||
InputDirectory = "/srv/storage2/files/VideoProcessing/MikeTheKnight/Input/"
|
||||
UnknownDirectory = "/srv/storage2/files/VideoProcessing/Unknown/MikeTheKnight/"
|
||||
UnknownDirectory = "/srv/storage2/files/VideoProcessing/Unknown/MikeTheKnight/"
|
||||
OutputDirectory = "/srv/storage2/videos/Kids/TV/Mike the Knight/"
|
||||
alias = ,
|
||||
MythTvEpisodePrefix = "Mike the Knight and the ", Mike the Knight and "
|
||||
|
||||
45
tests/TVEncodertest.py
Normal file
45
tests/TVEncodertest.py
Normal file
@@ -0,0 +1,45 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Created on Sat Jul 13 20:37:47 2013
|
||||
|
||||
@author: shanef
|
||||
"""
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
sys.path.insert(0, parentdir)
|
||||
import TVEncoder
|
||||
|
||||
|
||||
class TVEncoderTest(unittest.TestCase):
|
||||
def test_processarguments_encodereadonly(self):
|
||||
args = []
|
||||
args.append(('-e', ''))
|
||||
args.append(('-l', ''))
|
||||
result = TVEncoder.processarguments(args)
|
||||
|
||||
self.assertTrue(result.doencode)
|
||||
self.assertTrue(result.readonly)
|
||||
|
||||
def test_processarguments_encodereadonlyreverse(self):
|
||||
args = []
|
||||
args.append(('-l', ''))
|
||||
args.append(('-e', ''))
|
||||
result = TVEncoder.processarguments(args)
|
||||
|
||||
self.assertTrue(result.doencode)
|
||||
self.assertTrue(result.readonly)
|
||||
|
||||
def test_processarguments_encode(self):
|
||||
args = []
|
||||
args.append(('-e', ''))
|
||||
result = TVEncoder.processarguments(args)
|
||||
|
||||
self.assertTrue(result.doencode)
|
||||
self.assertFalse(result.readonly)
|
||||
|
||||
if __name__ == '__main__':
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(TVEncoderTest)
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
38
tests/libtvdatasourcetest.py
Normal file
38
tests/libtvdatasourcetest.py
Normal file
@@ -0,0 +1,38 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Created on Thu Jul 18 23:13:15 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 libtvdatasource
|
||||
|
||||
|
||||
class tvdatasourceTest(unittest.TestCase):
|
||||
def test_GetOutputFilenameNoIllegals(self):
|
||||
result = self._dooutputfilenametest("S01", "E02", "test name", "")
|
||||
self.assertEqual(result, "S01E02 - test name - SD TV_.mpg")
|
||||
|
||||
def test_GetOutputFilenameOneIllegals(self):
|
||||
result = self._dooutputfilenametest("S01", "E02", "test name?", "?")
|
||||
self.assertEqual(result, "S01E02 - test name - SD TV_.mpg")
|
||||
|
||||
def test_GetOutputFilenameTwoIllegals(self):
|
||||
result = self._dooutputfilenametest("S01", "E02", "tes>t name?", ["?", ">"])
|
||||
self.assertEqual(result, "S01E02 - test name - SD TV_.mpg")
|
||||
|
||||
def _dooutputfilenametest(self, season, episode, name, illegals):
|
||||
settings = Mock('libsettings.Settings')
|
||||
settings.illegalcharacters.mock_returns = illegals
|
||||
tvdatasource = libtvdatasource.TVData(settings)
|
||||
return tvdatasource.getoutputfilename(season, episode, name)
|
||||
|
||||
if __name__ == '__main__':
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(tvdatasourceTest)
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
Reference in New Issue
Block a user