Ignore ? in filenames since they are illegal
This commit is contained in:
@@ -47,6 +47,12 @@ class Settings:
|
|||||||
|
|
||||||
return self.__config["HandbrakeCommand"]
|
return self.__config["HandbrakeCommand"]
|
||||||
|
|
||||||
|
def illegalcharacters(self):
|
||||||
|
"""Get a list of illegal characters for filenames
|
||||||
|
"""
|
||||||
|
|
||||||
|
return self.__config["IllegalCharacters"]
|
||||||
|
|
||||||
def mythtvaddress(self):
|
def mythtvaddress(self):
|
||||||
"""
|
"""
|
||||||
Get the MythTV/address setting
|
Get the MythTV/address setting
|
||||||
|
|||||||
@@ -88,8 +88,8 @@ class TVData:
|
|||||||
seasonfolder = "Season {0}".format(show.season)
|
seasonfolder = "Season {0}".format(show.season)
|
||||||
season = "S{0}".format(show.season)
|
season = "S{0}".format(show.season)
|
||||||
episode = "E{0}".format(show.episode)
|
episode = "E{0}".format(show.episode)
|
||||||
renamedfile = "{0}{1} - {2} - SD TV_.mpg".format(season, episode,
|
renamedfile = self.getoutputfilename(season, episode,
|
||||||
show.subtitle)
|
show.subtitle)
|
||||||
|
|
||||||
directory = self.getdirectory(show.title, seasonfolder,
|
directory = self.getdirectory(show.title, seasonfolder,
|
||||||
season, episode)
|
season, episode)
|
||||||
@@ -102,20 +102,17 @@ class TVData:
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
#==============================================================================
|
def getoutputfilename(self, season, episode, name):
|
||||||
# def __determinetargetfilename(directory, filename, inputfilename):
|
"""
|
||||||
# """
|
Get the output filename, and remove any illegal characters
|
||||||
# Determine the filename for the input file. If the path does not
|
"""
|
||||||
# exist, it is created.
|
|
||||||
# """
|
filename = "{0}{1} - {2} - SD TV_.mpg".format(season, episode, name)
|
||||||
#
|
|
||||||
# inputdir = os.path.join(directory, inputfilename[:-4])
|
for illegalcharacter in self.__settings.illegalcharacters():
|
||||||
#
|
filename = filename.replace(illegalcharacter, "")
|
||||||
# if not os.path.exists(inputdir):
|
|
||||||
# os.makedirs(inputdir)
|
return filename
|
||||||
#
|
|
||||||
# return os.path.join(inputdir, filename)
|
|
||||||
#==============================================================================
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def processepisode(inputfile, outputfile):
|
def processepisode(inputfile, outputfile):
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
TVRecordings = "/Volumes/TV Recordings/"
|
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"
|
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" ]
|
[ "MythTV" ]
|
||||||
address = 192.168.0.2
|
address = 192.168.0.2
|
||||||
|
|||||||
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