From d0d66fe9a891f16b807ff2d5a29456e0186bd94c Mon Sep 17 00:00:00 2001 From: Shane Frischkorn Date: Sat, 6 Jul 2013 21:10:16 +1000 Subject: [PATCH] move error fixing --- TVEncoder.py | 8 ++++---- libfilemanager.py | 2 +- libmythtv.py | 15 +++++++-------- libsettings.py | 11 ++++++++--- libtvdatasource.py | 10 +++++----- 5 files changed, 25 insertions(+), 21 deletions(-) diff --git a/TVEncoder.py b/TVEncoder.py index f3f5320..47eacae 100644 --- a/TVEncoder.py +++ b/TVEncoder.py @@ -12,7 +12,7 @@ from libsettings import Settings from libhandbrake import Encoder import libtvdatasource -TVRECORDINGSDIR = "/srv/storage2/videos/TVRecordings/" # TODO move this to settings +TVRECORDINGSDIR = "/Volumes/TV Recordings/"#"/srv/storage2/videos/TVRecordings/" # TODO move this to settings def ShowHelp(): print 'TVEncoder.py -p -n - prepare n recordings' @@ -53,16 +53,16 @@ def main(argv): readOnly = True doList = True - shows = Settings("") # TODO call actual settings file + showSettings = Settings("settings.xml") # TODO call actual settings file if readOnly and doList: if doEncode: #Generate the list of files that would be encoded - showData = libfilemanager.GetEncodingFiles(shows, readOnly) + showData = libfilemanager.GetEncodingFiles(showSettings, readOnly) PrintShowsToEncode(showData) else: # Generate the list of files to process - shows = libfilemanager.GetFilesToPrepare(TVRECORDINGSDIR, numFiles, shows) + shows = libfilemanager.GetFilesToPrepare(TVRECORDINGSDIR, numFiles, showSettings) PrintShowsToPrepare(shows) else: if doEncode: diff --git a/libfilemanager.py b/libfilemanager.py index 55878cf..b3c3c7e 100644 --- a/libfilemanager.py +++ b/libfilemanager.py @@ -88,7 +88,7 @@ def GetFilesToPrepare(path, numberofFiles, shows): for file in files: # TODO get these from settings #if TVData.CheckTitleIsInList('localhost', 'script', 'script', 'mythconverg', file): - showData = TVData.RetrieveEpisodeData('localhost', 'script', 'script', 'mythconverg', file, shows) + showData = TVData.RetrieveEpisodeData('192.168.0.2', 'script', 'script', 'mythconverg', file, shows, '192.168.0.2', '8081', '3678177136222bf5002be209220ccb20') # TODO all these settings need to move to settings if showData: showsToProcess.append(showData) i = i + 1 diff --git a/libmythtv.py b/libmythtv.py index 9872cb2..9061232 100644 --- a/libmythtv.py +++ b/libmythtv.py @@ -8,14 +8,13 @@ Created on Fri Jul 5 14:10:47 2013 import MySQLdb as mdb from libtvshow import TVShow -class MythTV: - def RetrieveEpisodeData(serverAddress, user, password, database, inputFile): - con = mdb.connect(serverAddress, user, password, database) +def RetrieveEpisodeData(serverAddress, user, password, database, inputFile): + con = mdb.connect(serverAddress, user, password, database) - with con: - cur = con.cursor(mdb.cursors.DictCursor) - cur.execute("select episode, season, title, subtitle, description from mythconverg.recorded where basename = '{0}'".format(inputFile)) - result = cur.fetchone() + with con: + cur = con.cursor(mdb.cursors.DictCursor) + cur.execute("select episode, season, title, subtitle, description from mythconverg.recorded where basename = '{0}'".format(inputFile)) + result = cur.fetchone() - return TVShow(result['episode'], result['season'], result['title'], result['subtitle'], result['description']) + return TVShow(result['episode'], result['season'], result['title'], result['subtitle'], result['description']) \ No newline at end of file diff --git a/libsettings.py b/libsettings.py index 9227e8c..c20a3b2 100644 --- a/libsettings.py +++ b/libsettings.py @@ -5,18 +5,23 @@ Created on Fri Jul 5 20:14:15 2013 @author: shanef """ -from libtvdatasource import TVShow from xml.etree import ElementTree +class ShowSettings: + def __init__(self, name, inputDirectory, outputDirectory): + self.name = name + self.inputDirectory = inputDirectory + self.outputDirectory = outputDirectory + class Settings: def __init__(self, settingsFile): self.shows = self.LoadSettings(settingsFile) - def LoadSettings(source): + def LoadSettings(self, source): shows = [] settingsXml = ElementTree.parse(source).getroot() for show in settingsXml.findall('show'): - newShow = TVShow(show[0].text, show[1].text, show[2].text) + newShow = ShowSettings(show[0].text, show[1].text, show[2].text) shows.append(newShow) return shows \ No newline at end of file diff --git a/libtvdatasource.py b/libtvdatasource.py index 469603e..d954d36 100644 --- a/libtvdatasource.py +++ b/libtvdatasource.py @@ -9,7 +9,6 @@ import libmythtv as MythTV from libsickbeard import Sickbeard import os import shutil -from libtvshow import TVShow # TODO Move these to settings PROCESSDIR="/srv/storage2/files/VideoProcessing/" @@ -46,18 +45,19 @@ def GetDirectory(title, season): return os.path.join(PROCESSDIR, directory, INPUTDIR, season) -def RetrieveEpisodeData(serverAddress, user, password, database, inputFile, showsToProcess): +def RetrieveEpisodeData(serverAddress, user, password, database, inputFile, showsToProcess, sickbeardAddress, sickbeardPort, sickbeardAPIKey): file = os.path.basename(inputFile) - show = MythTV.RetrieveEpisodeData('localhost', 'script', 'script', 'mythconverg', file) + show = MythTV.RetrieveEpisodeData(serverAddress, user, password, database, file) if show.title and show.title in showsToProcess: if show.subtitle: show.subtitle = GetEpisodeName(show.subtitle, show.title) if (show.season == '0' or show.episode == '0'): - showId = Sickbeard.FindShowId(show.title) + sickbeard = Sickbeard(sickbeardAddress, sickbeardPort, sickbeardAPIKey) + 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.episode = result[1]