def searchEpisode(self, show=None, season=None, episode=None): outStr = "" epObj = _getEpisode(show, season, episode) if isinstance(epObj, str): return _genericMessage("Error", epObj) tempStr = "Searching for download for " + epObj.prettyName(True) logger.log(tempStr) outStr += tempStr + "<br />\n" foundEpisodes = search.findEpisode(epObj) if len(foundEpisodes) == 0: message = 'No downloads were found' flash.error(message, "Couldn't find a download for <i>%s</i>" % epObj.prettyName(True)) logger.log(message) else: # just use the first result for now logger.log("Downloading episode from " + foundEpisodes[0].url + "<br />\n") result = search.snatchEpisode(foundEpisodes[0]) providerModule = providers.getProviderModule(foundEpisodes[0].provider) if providerModule == None: flash.error('Provider is configured incorrectly, unable to download') else: flash.message('Episode snatched from <b>%s</b>' % providerModule.providerName) #TODO: check if the download was successful # update our lists to reflect the result if this search sickbeard.updateMissingList() sickbeard.updateAiringList() sickbeard.updateComingList() redirect("/home/displayShow?show=" + str(epObj.show.tvdbid))
def snatchEpisode(result, endStatus=SNATCHED): if result.resultType == "nzb": if sickbeard.NZB_METHOD == "blackhole": dlResult = _downloadResult(result) elif sickbeard.NZB_METHOD == "sabnzbd": dlResult = sab.sendNZB(result) else: logger.log("Unknown NZB action specified in config: " + sickbeard.NZB_METHOD, logger.ERROR) dlResult = False elif result.resultType == "torrent": dlResult = _downloadResult(result) else: logger.log("Unknown result type, unable to download it", logger.ERROR) dlResult = False if dlResult == False: return history.logSnatch(result) # don't notify when we snatch a backlog episode, that's just annoying if endStatus != SNATCHED_BACKLOG: notifiers.notify(NOTIFY_SNATCH, result.episode.prettyName(True)) with result.episode.lock: if result.predownloaded == True: logger.log("changing status from " + str(result.episode.status) + " to " + str(PREDOWNLOADED), logger.DEBUG) result.episode.status = PREDOWNLOADED else: logger.log("changing status from " + str(result.episode.status) + " to " + str(endStatus), logger.DEBUG) result.episode.status = endStatus result.episode.saveToDB() sickbeard.updateMissingList() sickbeard.updateAiringList() sickbeard.updateComingList()
def main(): # do some preliminary stuff sickbeard.MY_FULLNAME = os.path.normpath(os.path.abspath(sys.argv[0])) sickbeard.MY_NAME = os.path.basename(sickbeard.MY_FULLNAME) sickbeard.PROG_DIR = os.path.dirname(sickbeard.MY_FULLNAME) config_file = os.path.join(sickbeard.PROG_DIR, "config.ini") # need console logging for SickBeard.py and SickBeard-console.exe consoleLogging = (not hasattr(sys, "frozen")) or (sickbeard.MY_NAME.lower().find('-console') > 0) # rename the main thread threading.currentThread().name = "MAIN" try: opts, args = getopt.getopt(sys.argv[1:], "q", ['quiet']) except getopt.GetoptError: print "Available options: --quiet" sys.exit() for o, a in opts: # for now we'll just silence the logging if (o in ('-q', '--quiet')): consoleLogging = False if consoleLogging: print "Starting up Sick Beard "+SICKBEARD_VERSION+" from " + config_file # load the config and publish it to the sickbeard package if not os.path.isfile(config_file): logger.log("Unable to find config.ini, all settings will be default", logger.ERROR) sickbeard.CFG = ConfigObj(config_file) # initialize the config and our threads sickbeard.initialize(consoleLogging=consoleLogging) sickbeard.showList = [] try: initWebServer({ 'port': sickbeard.WEB_PORT, 'data_root': os.path.join(sickbeard.PROG_DIR, 'data'), 'web_root': sickbeard.WEB_ROOT, 'log_dir': sickbeard.LOG_DIR if sickbeard.WEB_LOG else None, 'username': sickbeard.WEB_USERNAME, 'password': sickbeard.WEB_PASSWORD, }) except IOError: logger.log("Unable to start web server, is something else running on port %d?" % sickbeard.WEB_PORT, logger.ERROR) if sickbeard.LAUNCH_BROWSER: logger.log("Launching browser and exiting", logger.ERROR) sickbeard.launchBrowser() sys.exit() # build from the DB to start with logger.log("Loading initial show list") loadShowsFromDB() # set up the lists sickbeard.updateAiringList() sickbeard.updateComingList() sickbeard.updateMissingList() # fire up all our threads sickbeard.start() # launch browser if we're supposed to if sickbeard.LAUNCH_BROWSER: sickbeard.launchBrowser() # stay alive while my threads do the work while (True): time.sleep(1) return
def main(): # do some preliminary stuff sickbeard.MY_FULLNAME = os.path.normpath(os.path.abspath(sys.argv[0])) sickbeard.MY_NAME = os.path.basename(sickbeard.MY_FULLNAME) sickbeard.PROG_DIR = os.path.dirname(sickbeard.MY_FULLNAME) config_file = os.path.join(sickbeard.PROG_DIR, "config.ini") # need console logging for SickBeard.py and SickBeard-console.exe consoleLogging = (not hasattr(sys, "frozen")) or (sickbeard.MY_NAME.lower().find("-console") > 0) # rename the main thread threading.currentThread().name = "MAIN" try: opts, args = getopt.getopt(sys.argv[1:], "qfp:", ["quiet", "force-update", "port=", "tvbinz"]) except getopt.GetoptError: print "Available options: --quiet, --forceupdate, --port" sys.exit() forceUpdate = False forcedPort = None for o, a in opts: # for now we'll just silence the logging if o in ("-q", "--quiet"): consoleLogging = False # for now we'll just silence the logging if o in ("--tvbinz"): sickbeard.SHOW_TVBINZ = True # should we update right away? if o in ("-f", "--forceupdate"): forceUpdate = True # should we update right away? if o in ("-p", "--port"): forcedPort = int(a) if consoleLogging: print "Starting up Sick Beard " + SICKBEARD_VERSION + " from " + config_file # load the config and publish it to the sickbeard package if not os.path.isfile(config_file): logger.log("Unable to find config.ini, all settings will be default", logger.ERROR) sickbeard.CFG = ConfigObj(config_file) # initialize the config and our threads sickbeard.initialize(consoleLogging=consoleLogging) sickbeard.showList = [] if forcedPort: logger.log("Forcing web server to port " + str(forcedPort)) startPort = forcedPort else: startPort = sickbeard.WEB_PORT logger.log("Starting Sick Beard on http://localhost:" + str(startPort)) try: initWebServer( { "port": startPort, "data_root": os.path.join(sickbeard.PROG_DIR, "data"), "web_root": sickbeard.WEB_ROOT, "log_dir": sickbeard.LOG_DIR if sickbeard.WEB_LOG else None, "username": sickbeard.WEB_USERNAME, "password": sickbeard.WEB_PASSWORD, } ) except IOError: logger.log( "Unable to start web server, is something else running on port %d?" % sickbeard.WEB_PORT, logger.ERROR ) if sickbeard.LAUNCH_BROWSER: logger.log("Launching browser and exiting", logger.ERROR) sickbeard.launchBrowser() sys.exit() # build from the DB to start with logger.log("Loading initial show list") loadShowsFromDB() # set up the lists sickbeard.updateAiringList() sickbeard.updateComingList() sickbeard.updateMissingList() # fire up all our threads sickbeard.start() # launch browser if we're supposed to if sickbeard.LAUNCH_BROWSER: sickbeard.launchBrowser() # start an update if we're supposed to if forceUpdate: sickbeard.showUpdateScheduler.action.run(force=True) # stay alive while my threads do the work while True: time.sleep(1) return
def main(): # do some preliminary stuff sickbeard.PROG_DIR = os.path.dirname(os.path.normpath(os.path.abspath(sys.argv[0]))) sickbeard.CONFIG_FILE = "config.ini" # rename the main thread threading.currentThread().name = "MAIN" print "Starting up Sick Beard "+SICKBEARD_VERSION+" from " + os.path.join(sickbeard.PROG_DIR, sickbeard.CONFIG_FILE) # load the config and publish it to the sickbeard package if not os.path.isfile(os.path.join(sickbeard.PROG_DIR, sickbeard.CONFIG_FILE)): logger.log("Unable to find config.ini, all settings will be default", logger.ERROR) sickbeard.CFG = ConfigObj(os.path.join(sickbeard.PROG_DIR, sickbeard.CONFIG_FILE)) # initialize the config and our threads sickbeard.initialize() sickbeard.showList = [] # setup cherrypy logging if os.path.isdir(sickbeard.LOG_DIR) and sickbeard.WEB_LOG: cherry_log = os.path.join(sickbeard.LOG_DIR, "cherrypy.log") logger.log("Using " + cherry_log + " for cherrypy log") else: cherry_log = None # cherrypy setup cherrypy.config.update({ 'server.socket_port': sickbeard.WEB_PORT, 'server.socket_host': '0.0.0.0', 'log.screen': False, 'log.access_file': cherry_log }) userpassdict = {sickbeard.WEB_USERNAME: sickbeard.WEB_PASSWORD} checkpassword = cherrypy.lib.auth_basic.checkpassword_dict(userpassdict) if sickbeard.WEB_USERNAME == "" or sickbeard.WEB_PASSWORD == "": useAuth = False else: useAuth = True conf = { '/': { 'tools.staticdir.root': os.path.join(sickbeard.PROG_DIR, 'data'), 'tools.auth_basic.on': useAuth, 'tools.auth_basic.realm': 'SickBeard', 'tools.auth_basic.checkpassword': checkpassword }, '/images': { 'tools.staticdir.on': True, 'tools.staticdir.dir': 'images' }, '/js': { 'tools.staticdir.on': True, 'tools.staticdir.dir': 'js' }, '/css': { 'tools.staticdir.on': True, 'tools.staticdir.dir': 'css' }, } cherrypy.tree.mount(WebInterface(), sickbeard.WEB_ROOT, conf) try: cherrypy.server.start() cherrypy.server.wait() except IOError: logger.log("Unable to start web server, is something else running on port %d?" % sickbeard.WEB_PORT, logger.ERROR) if sickbeard.LAUNCH_BROWSER: logger.log("Launching browser and exiting", logger.ERROR) sickbeard.launchBrowser() sys.exit() # build from the DB to start with logger.log("Loading initial show list") loadShowsFromDB() # set up the lists sickbeard.updateAiringList() sickbeard.updateComingList() sickbeard.updateMissingList() # fire up all our threads sickbeard.start() # launch browser if we're supposed to if sickbeard.LAUNCH_BROWSER: sickbeard.launchBrowser() # stay alive while my threads do the work while (True): time.sleep(1) return