move error fixing
This commit is contained in:
@@ -12,8 +12,8 @@ from libsettings import Settings
|
|||||||
from libhandbrake import Encoder
|
from libhandbrake import Encoder
|
||||||
import libtvdatasource
|
import libtvdatasource
|
||||||
|
|
||||||
#TVRECORDINGSDIR = "/Volumes/TV Recordings/"
|
TVRECORDINGSDIR = "/Volumes/TV Recordings/"
|
||||||
TVRECORDINGSDIR = "/srv/storage2/videos/TVRecordings/" # TODO move this to settings
|
#TVRECORDINGSDIR = "/srv/storage2/videos/TVRecordings/" # TODO move this to settings
|
||||||
|
|
||||||
def ShowHelp():
|
def ShowHelp():
|
||||||
print 'TVEncoder.py -p -n <number of files to prepare for processing> - prepare n recordings'
|
print 'TVEncoder.py -p -n <number of files to prepare for processing> - prepare n recordings'
|
||||||
|
|||||||
@@ -24,6 +24,12 @@ class Sickbeard:
|
|||||||
jsonurl = urlopen(self.__GetApiURL()+"?cmd=shows")
|
jsonurl = urlopen(self.__GetApiURL()+"?cmd=shows")
|
||||||
result = json.loads(jsonurl.read())
|
result = json.loads(jsonurl.read())
|
||||||
|
|
||||||
|
# TODO find a better way to do this
|
||||||
|
if showName == "Thomas and Friends":
|
||||||
|
showName = "Thomas The Tank Engine & Friends"
|
||||||
|
elif showName == "The Octonauts":
|
||||||
|
showName = "Octonauts"
|
||||||
|
|
||||||
shows = []
|
shows = []
|
||||||
for show in result['data']:
|
for show in result['data']:
|
||||||
shows.append((show, fuzz.partial_ratio(showName.lower(), result['data'][show]['show_name'].lower())))
|
shows.append((show, fuzz.partial_ratio(showName.lower(), result['data'][show]['show_name'].lower())))
|
||||||
@@ -38,7 +44,7 @@ class Sickbeard:
|
|||||||
episodeResult = json.loads(jsonEpisodeUrl.read())
|
episodeResult = json.loads(jsonEpisodeUrl.read())
|
||||||
|
|
||||||
if fuzz.ratio(episodeResult['data']['description'].lower(), description.lower()) > 85:
|
if fuzz.ratio(episodeResult['data']['description'].lower(), description.lower()) > 85:
|
||||||
return (season, episode)
|
return (season, episode, episodeResult['data']['name'])
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -49,13 +55,13 @@ class Sickbeard:
|
|||||||
for season in result['data']:
|
for season in result['data']:
|
||||||
for episode in result['data'][season]:
|
for episode in result['data'][season]:
|
||||||
if name is not None and name.lower() == result['data'][season][episode]['name'].lower():
|
if name is not None and name.lower() == result['data'][season][episode]['name'].lower():
|
||||||
return (season, episode)
|
return (season, episode, name)
|
||||||
elif description is not None:
|
elif description is not None:
|
||||||
result = self.FindEpisodeByDescription(showId, season, episode, description)
|
descriptionQueryResult = self.FindEpisodeByDescription(showId, season, episode, description)
|
||||||
if result is not None:
|
if descriptionQueryResult is not None:
|
||||||
return result
|
return descriptionQueryResult
|
||||||
|
|
||||||
return (0, 0)
|
return (0, 0, '')
|
||||||
|
|
||||||
def GetEpisodeName(subtitle, showName):
|
def GetEpisodeName(subtitle, showName):
|
||||||
if subtitle[:len(showName)].lower() == showName.lower():
|
if subtitle[:len(showName)].lower() == showName.lower():
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ RAARAA="RaaRaa"
|
|||||||
INPUTDIR="Input"
|
INPUTDIR="Input"
|
||||||
|
|
||||||
def FixEpisodeSeasonNumber(number):
|
def FixEpisodeSeasonNumber(number):
|
||||||
if number < 10:
|
if len(number) == 1:
|
||||||
return "0{0}".format(number)
|
return "0{0}".format(number)
|
||||||
else:
|
else:
|
||||||
return str(number)
|
return number
|
||||||
|
|
||||||
def GetDirectory(title, season):
|
def GetDirectory(title, season):
|
||||||
directory = ""
|
directory = ""
|
||||||
@@ -47,35 +47,34 @@ def GetDirectory(title, season):
|
|||||||
|
|
||||||
def RetrieveEpisodeData(serverAddress, user, password, database, inputFile, showsToProcess, sickbeardAddress, sickbeardPort, sickbeardAPIKey):
|
def RetrieveEpisodeData(serverAddress, user, password, database, inputFile, showsToProcess, sickbeardAddress, sickbeardPort, sickbeardAPIKey):
|
||||||
file = os.path.basename(inputFile)
|
file = os.path.basename(inputFile)
|
||||||
#print file
|
|
||||||
show = MythTV.RetrieveEpisodeData(serverAddress, user, password, database, file)
|
show = MythTV.RetrieveEpisodeData(serverAddress, user, password, database, file)
|
||||||
#print "file: {0} mythtv returned show name {1}".format(file, show.title)
|
|
||||||
|
|
||||||
if show.title and show.title in showsToProcess:
|
if show.title and show.title in showsToProcess:
|
||||||
if show.subtitle:
|
if show.subtitle:
|
||||||
show.subtitle = GetEpisodeName(show.subtitle, show.title)
|
show.subtitle = GetEpisodeName(show.subtitle, show.title)
|
||||||
|
|
||||||
if (show.season == '0' or show.episode == '0'):
|
if (show.season == "0" or show.episode == "0"):
|
||||||
sickbeard = Sickbeard(sickbeardAddress, sickbeardPort, sickbeardAPIKey)
|
sickbeard = Sickbeard(sickbeardAddress, sickbeardPort, sickbeardAPIKey)
|
||||||
showId = sickbeard.FindShowId(show.title)
|
showId = sickbeard.FindShowId(show.title)
|
||||||
|
|
||||||
result = sickbeard.FindEpisode(showId, show.subtitle, show.description)
|
result = sickbeard.FindEpisode(showId, show.subtitle, show.description)
|
||||||
show.season = result[0]
|
show.season = str(result[0])
|
||||||
show.episode = result[1]
|
show.episode = str(result[1])
|
||||||
|
show.subtitle = result[2]
|
||||||
|
|
||||||
if show.season != "0" and show.episode != "0":
|
if show.season != "0" and show.episode != "0":
|
||||||
show.season = FixEpisodeSeasonNumber(show.season)
|
show.season = FixEpisodeSeasonNumber(show.season)
|
||||||
show.episode = FixEpisodeSeasonNumber(show.episode)
|
show.episode = FixEpisodeSeasonNumber(show.episode)
|
||||||
|
|
||||||
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, show.subtitle)
|
renamedFile = "{0}{1} - {2} - SD TV_.mpg".format(season, episode, show.subtitle)
|
||||||
|
|
||||||
directory = GetDirectory(show.title, seasonFolder)
|
directory = GetDirectory(show.title, seasonFolder)
|
||||||
|
|
||||||
show.outputFile = os.path.join(directory, inputFile[:-4], renamedFile)
|
show.outputFile = os.path.join(directory, file[:-4], renamedFile)
|
||||||
show.inputFile = inputFile
|
show.inputFile = inputFile
|
||||||
|
|
||||||
return show
|
return show
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -5,15 +5,15 @@ Created on Sat Jul 6 20:26:22 2013
|
|||||||
@author: shanef
|
@author: shanef
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class TVShow:
|
class TVShow(object):
|
||||||
def __init__(self, episode, season, title, subtitle, description, inputFile='', outputFile=''):
|
def __init__(self, episode, season, title, subtitle, description, inputFile='', outputFile=''):
|
||||||
self.episode = episode
|
self.episode = str(episode)
|
||||||
self.season = season
|
self.season = str(season)
|
||||||
self.title = title
|
self.title = title
|
||||||
self.subtitle = subtitle
|
self.subtitle = subtitle
|
||||||
self.description = description
|
self.description = description
|
||||||
self.inputFile = inputFile
|
self.inputFile = inputFile
|
||||||
self.outputFile = outputFile
|
self.outputFile = outputFile
|
||||||
|
|
||||||
def Print(self):
|
def Print(self):
|
||||||
print "Input: {0} -> Output: {1}".format(self.inputFile, self.outputFile)
|
print "Input: {0} -> Output: {1}".format(self.inputFile, self.outputFile)
|
||||||
Reference in New Issue
Block a user