Beispiel #1
0
    def run(self):
        super(QueueItemUpdate, self).run()

        sickrage.srCore.srLogger.info("Performing updates for show: {}".format(self.show.name))

        try:
            sickrage.srCore.srLogger.debug("Retrieving show info from " + srIndexerApi(self.show.indexer).name + "")
            self.show.loadFromIndexer(cache=not self.force)
        except indexer_error as e:
            sickrage.srCore.srLogger.warning(
                "Unable to contact " + srIndexerApi(self.show.indexer).name + ", aborting: {}".format(e))
            return
        except indexer_attributenotfound as e:
            sickrage.srCore.srLogger.error(
                "Data retrieved from " + srIndexerApi(self.show.indexer).name + " was incomplete, aborting: {}".format(
                    e.message))
            return

        try:
            sickrage.srCore.srLogger.debug("Retrieving show info from TMDb")
            self.show.loadTMDbInfo()
        except Exception as e:
            sickrage.srCore.srLogger.error("Error loading TMDb info: {}".format(e.message))
            sickrage.srCore.srLogger.debug(traceback.format_exc())
            try:
                sickrage.srCore.srLogger.debug("Attempting to retrieve show info from IMDb")
                self.show.loadIMDbInfo()
            except Exception as e:
                sickrage.srCore.srLogger.error("Error loading IMDb info: {}".format(e.message))
                sickrage.srCore.srLogger.debug(traceback.format_exc())

        # have to save show before reading episodes from db
        try:
            self.show.saveToDB()
        except Exception as e:
            sickrage.srCore.srLogger.error("Error saving show info to the database: {}".format(e.message))
            return

        # get episode list from DB
        DBEpList = self.show.loadEpisodesFromDB() if not self.force else {}

        # get episode list from TVDB
        try:
            IndexerEpList = self.show.loadEpisodesFromIndexer(cache=not self.force)
        except indexer_exception as e:
            sickrage.srCore.srLogger.error("Unable to get info from " + srIndexerApi(
                self.show.indexer).name + ", the show info will not be refreshed: {}".format(e.message))
            IndexerEpList = None

        if IndexerEpList is None:
            sickrage.srCore.srLogger.error("No data returned from " + srIndexerApi(
                self.show.indexer).name + ", unable to update this show")
        else:
            # for each ep we found on the Indexer not in the DB list add to DB
            sql_l = []
            for curSeason in IndexerEpList:
                for curEpisode in set(IndexerEpList[curSeason]).difference(DBEpList.get(curSeason, {})):
                    sql_q = self.show.getEpisode(curSeason, curEpisode, forceIndexer=True).saveToDB(False)
                    if sql_q:
                        sql_l.append(sql_q)

            if len(sql_l) > 0:
                main_db.MainDB().mass_upsert(sql_l)
                del sql_l  # cleanup

            # remaining episodes in the DB list are not on the indexer, just delete them from the DB
            for curSeason in DBEpList:
                for curEpisode in set(DBEpList[curSeason]).difference(IndexerEpList.get(curSeason, {})):
                    sickrage.srCore.srLogger.info("Permanently deleting episode " + str(curSeason) + "x" + str(
                        curEpisode) + " from the database")

                    try:
                        self.show.getEpisode(curSeason, curEpisode).deleteEpisode()
                    except EpisodeDeletedException:
                        pass

        # cleanup
        scrub(DBEpList)
        scrub(IndexerEpList)

        sickrage.srCore.srLogger.info("Finished updates for show: {}".format(self.show.name))

        # refresh show
        sickrage.srCore.SHOWQUEUE.refreshShow(self.show, self.force)
Beispiel #2
0
    def run(self):
        start_time = time.time()

        sickrage.app.log.info("Performing updates for show: {}".format(
            self.show.name))

        try:
            sickrage.app.log.debug("Retrieving show info from " +
                                   IndexerApi(self.show.indexer).name + "")
            self.show.load_from_indexer(cache=False)
        except indexer_error as e:
            sickrage.app.log.warning("Unable to contact " +
                                     IndexerApi(self.show.indexer).name +
                                     ", aborting: {}".format(e))
            return
        except indexer_attributenotfound as e:
            sickrage.app.log.warning("Data retrieved from " +
                                     IndexerApi(self.show.indexer).name +
                                     " was incomplete, aborting: {}".format(e))
            return

        try:
            sickrage.app.log.debug(
                "Attempting to retrieve show info from IMDb")
            self.show.load_imdb_info()
        except Exception as e:
            sickrage.app.log.warning(
                "Error loading IMDb info for {}: {}".format(
                    IndexerApi(self.show.indexer).name, e))

        # get episode list from DB
        DBEpList = self.show.load_episodes_from_db()
        IndexerEpList = None

        # get episode list from TVDB
        try:
            IndexerEpList = self.show.load_episodes_from_indexer()
        except indexer_exception as e:
            sickrage.app.log.error(
                "Unable to get info from " +
                IndexerApi(self.show.indexer).name +
                ", the show info will not be refreshed: {}".format(e))

        if not IndexerEpList:
            sickrage.app.log.error("No data returned from " +
                                   IndexerApi(self.show.indexer).name +
                                   ", unable to update this show")
        else:
            # for each ep we found on indexer delete it from the DB list
            for curSeason in IndexerEpList:
                for curEpisode in IndexerEpList[curSeason]:
                    if curSeason in DBEpList and curEpisode in DBEpList[
                            curSeason]:
                        del DBEpList[curSeason][curEpisode]

            # remaining episodes in the DB list are not on the indexer, just delete them from the DB
            for curSeason in DBEpList:
                for curEpisode in DBEpList[curSeason]:
                    sickrage.app.log.info("Permanently deleting episode " +
                                          str(curSeason) + "x" +
                                          str(curEpisode) +
                                          " from the database")
                    try:
                        self.show.get_episode(curSeason,
                                              curEpisode).deleteEpisode()
                    except EpisodeDeletedException:
                        pass

        # cleanup
        scrub(DBEpList)
        scrub(IndexerEpList)

        sickrage.app.quicksearch_cache.update_show(self.show.indexerid)

        sickrage.app.log.info("Finished updates in {}s for show: {}".format(
            round(time.time() - start_time, 2), self.show.name))

        # refresh show
        sickrage.app.show_queue.refreshShow(self.show, self.force)
Beispiel #3
0
    def run(self):
        super(QueueItemUpdate, self).run()

        sickrage.srCore.srLogger.info("Performing updates for show: {}".format(self.show.name))

        try:
            sickrage.srCore.srLogger.debug("Retrieving show info from " + srIndexerApi(self.show.indexer).name + "")
            self.show.loadFromIndexer(cache=not self.force)
        except indexer_error as e:
            sickrage.srCore.srLogger.warning(
                "Unable to contact " + srIndexerApi(self.show.indexer).name + ", aborting: {}".format(e.message))
            return
        except indexer_attributenotfound as e:
            sickrage.srCore.srLogger.error(
                "Data retrieved from " + srIndexerApi(self.show.indexer).name + " was incomplete, aborting: {}".format(
                    e.message))
            return

        try:
            sickrage.srCore.srLogger.debug("Attempting to retrieve show info from IMDb")
            self.show.loadIMDbInfo()
        except Exception as e:
            sickrage.srCore.srLogger.error("Error loading IMDb info: {}".format(e.message))
            sickrage.srCore.srLogger.debug(traceback.format_exc())

        # have to save show before reading episodes from db
        try:
            self.show.saveToDB()
        except Exception as e:
            sickrage.srCore.srLogger.error("Error saving show info to the database: {}".format(e.message))
            return

        # get episode list from DB
        DBEpList = self.show.loadEpisodesFromDB() if not self.force else {}

        # get episode list from TVDB
        try:
            IndexerEpList = self.show.loadEpisodesFromIndexer(cache=not self.force)
        except indexer_exception as e:
            sickrage.srCore.srLogger.error("Unable to get info from " + srIndexerApi(
                self.show.indexer).name + ", the show info will not be refreshed: {}".format(e.message))
            IndexerEpList = None

        if IndexerEpList is None:
            sickrage.srCore.srLogger.error("No data returned from " + srIndexerApi(
                self.show.indexer).name + ", unable to update this show")
        else:
            # for each ep we found on the Indexer not in the DB list add to DB
            sql_l = []
            for curSeason in IndexerEpList:
                for curEpisode in set(IndexerEpList[curSeason]).difference(DBEpList.get(curSeason, {})):
                    sql_q = self.show.getEpisode(curSeason, curEpisode, forceIndexer=True).saveToDB(False)
                    if sql_q:
                        sql_l.append(sql_q)

            if len(sql_l) > 0:
                main_db.MainDB().mass_upsert(sql_l)
                del sql_l  # cleanup

            # remaining episodes in the DB list are not on the indexer, just delete them from the DB
            for curSeason in DBEpList:
                for curEpisode in set(DBEpList[curSeason]).difference(IndexerEpList.get(curSeason, {})):
                    sickrage.srCore.srLogger.info("Permanently deleting episode " + str(curSeason) + "x" + str(
                        curEpisode) + " from the database")

                    try:
                        self.show.getEpisode(curSeason, curEpisode).deleteEpisode()
                    except EpisodeDeletedException:
                        pass

        # cleanup
        scrub(DBEpList)
        scrub(IndexerEpList)

        sickrage.srCore.srLogger.info("Finished updates for show: {}".format(self.show.name))

        # refresh show
        sickrage.srCore.SHOWQUEUE.refreshShow(self.show, self.force)
Beispiel #4
0
    def run(self):
        sickrage.srCore.srLogger.info("Performing updates for show: {}".format(
            self.show.name))

        try:
            sickrage.srCore.srLogger.debug(
                "Retrieving show info from " +
                srIndexerApi(self.show.indexer).name + "")
            self.show.loadFromIndexer(cache=not self.force)
        except indexer_error as e:
            sickrage.srCore.srLogger.warning(
                "Unable to contact " + srIndexerApi(self.show.indexer).name +
                ", aborting: {}".format(e.message))
            return
        except indexer_attributenotfound as e:
            sickrage.srCore.srLogger.error(
                "Data retrieved from " + srIndexerApi(self.show.indexer).name +
                " was incomplete, aborting: {}".format(e.message))
            return

        try:
            sickrage.srCore.srLogger.debug(
                "Attempting to retrieve show info from IMDb")
            self.show.loadIMDbInfo()
        except Exception as e:
            sickrage.srCore.srLogger.error(
                "Error loading IMDb info: {}".format(e.message))
            sickrage.srCore.srLogger.debug(traceback.format_exc())

        # have to save show before reading episodes from db
        try:
            self.show.saveToDB()
        except Exception as e:
            sickrage.srCore.srLogger.error(
                "Error saving show info to the database: {}".format(e.message))
            return

        # get episode list from DB
        DBEpList = self.show.loadEpisodesFromDB()
        IndexerEpList = None

        # get episode list from TVDB
        try:
            IndexerEpList = self.show.loadEpisodesFromIndexer(
                cache=not self.force)
        except indexer_exception as e:
            sickrage.srCore.srLogger.error(
                "Unable to get info from " +
                srIndexerApi(self.show.indexer).name +
                ", the show info will not be refreshed: {}".format(e.message))

        if IndexerEpList is None:
            sickrage.srCore.srLogger.error(
                "No data returned from " +
                srIndexerApi(self.show.indexer).name +
                ", unable to update this show")
        else:
            # for each ep we found on indexer delete it from the DB list
            for curSeason in IndexerEpList:
                for curEpisode in IndexerEpList[curSeason]:
                    if curSeason in DBEpList and curEpisode in DBEpList[
                            curSeason]:
                        del DBEpList[curSeason][curEpisode]

            # remaining episodes in the DB list are not on the indexer, just delete them from the DB
            for curSeason in DBEpList:
                for curEpisode in DBEpList[curSeason]:
                    sickrage.srCore.srLogger.info(
                        "Permanently deleting episode " + str(curSeason) +
                        "x" + str(curEpisode) + " from the database")

                    curEp = self.show.getEpisode(curSeason, curEpisode)
                    try:
                        curEp.deleteEpisode()
                    except EpisodeDeletedException:
                        pass

        # cleanup
        scrub(DBEpList)
        scrub(IndexerEpList)

        sickrage.srCore.srLogger.info("Finished updates for show: {}".format(
            self.show.name))

        # refresh show
        sickrage.srCore.SHOWQUEUE.refreshShow(self.show, self.force)
Beispiel #5
0
    def run(self):
        sickrage.app.log.info("Performing updates for show: {}".format(self.show.name))

        try:
            sickrage.app.log.debug("Retrieving show info from " + IndexerApi(self.show.indexer).name + "")
            self.show.loadFromIndexer(cache=False)
        except indexer_error as e:
            sickrage.app.log.warning(
                "Unable to contact " + IndexerApi(self.show.indexer).name + ", aborting: {}".format(e.message))
            return
        except indexer_attributenotfound as e:
            sickrage.app.log.error(
                "Data retrieved from " + IndexerApi(self.show.indexer).name + " was incomplete, aborting: {}".format(
                    e.message))
            return

        try:
            sickrage.app.log.debug("Attempting to retrieve show info from IMDb")
            self.show.loadIMDbInfo()
        except Exception as e:
            sickrage.app.log.error("Error loading IMDb info: {}".format(e.message))
            sickrage.app.log.debug(traceback.format_exc())

        # get episode list from DB
        DBEpList = self.show.loadEpisodesFromDB()
        IndexerEpList = None

        # get episode list from TVDB
        try:
            IndexerEpList = self.show.loadEpisodesFromIndexer()
        except indexer_exception as e:
            sickrage.app.log.error("Unable to get info from " + IndexerApi(
                self.show.indexer).name + ", the show info will not be refreshed: {}".format(e.message))

        if IndexerEpList is None:
            sickrage.app.log.error("No data returned from " + IndexerApi(
                self.show.indexer).name + ", unable to update this show")
        else:
            # for each ep we found on indexer delete it from the DB list
            for curSeason in IndexerEpList:
                for curEpisode in IndexerEpList[curSeason]:
                    if curSeason in DBEpList and curEpisode in DBEpList[curSeason]:
                        del DBEpList[curSeason][curEpisode]

            # remaining episodes in the DB list are not on the indexer, just delete them from the DB
            for curSeason in DBEpList:
                for curEpisode in DBEpList[curSeason]:
                    sickrage.app.log.info(
                        "Permanently deleting episode " + str(curSeason) + "x" + str(curEpisode) + " from the database")

                    curEp = self.show.getEpisode(curSeason, curEpisode)
                    try:
                        curEp.deleteEpisode()
                    except EpisodeDeletedException:
                        pass

        # cleanup
        scrub(DBEpList)
        scrub(IndexerEpList)

        sickrage.app.log.info(
            "Finished updates in {}s for show: {}".format(round(time.time() - self.startTime, 2), self.show.name))

        # refresh show
        sickrage.app.show_queue.refreshShow(self.show, self.force)