Ejemplo n.º 1
0
    def _test_allPossibleShowNames(self, name, indexerid=0, expected=None):
        if expected is None:
            expected = []

        s = TVShow(1, indexerid)
        s.name = name
        s.save_to_db()

        result = show_names.allPossibleShowNames(s)
        self.assertTrue(len(set(expected).intersection(set(result))) == len(expected))
Ejemplo n.º 2
0
    def test_process(self):
        show = TVShow(1, 3)
        show.name = self.SHOWNAME
        show.location = self.SHOWDIR
        show.save_to_db()
        sickrage.app.showlist = [show]

        sickrage.app.name_cache.put('show name', 3)
        self.post_processor = PostProcessor(self.FILEPATH, process_method='move')
        self.post_processor._log = _log
        self.assertTrue(self.post_processor.process)
Ejemplo n.º 3
0
    def _test_allPossibleShowNames(self, name, indexerid=0, expected=None):
        if expected is None:
            expected = []

        s = TVShow(1, indexerid)
        s.name = name
        s.save_to_db()

        result = show_names.allPossibleShowNames(s)
        self.assertTrue(
            len(set(expected).intersection(set(result))) == len(expected))
Ejemplo n.º 4
0
class AnimeTests(tests.SiCKRAGETestDBCase):
    def setUp(self):
        super(AnimeTests, self).setUp()
        self.show = TVShow(1, 1, 'en')
        self.show.anime = True
        self.show.save_to_db()

    def _test_names(self, np, section, transform=None, verbose=False):
        """
        Performs a test

        :param name_parser: to use for test
        :param section:
        :param transform:
        :param verbose:
        :return:
        """
        if VERBOSE or verbose:
            print()
            print('Running', section, 'tests')
        for cur_test_base in anime_test_cases[section]:
            if transform:
                cur_test = transform(cur_test_base)
                np.file_name = cur_test
            else:
                cur_test = cur_test_base
            if VERBOSE or verbose:
                print('Testing', cur_test)

            result = anime_test_cases[section][cur_test_base]
            np.showObj.name = result.series_name if result else None
            if not result:
                self.assertRaises(InvalidNameException, np.parse, cur_test)
                return
            else:
                result.which_regex = {section}
                test_result = np.parse(cur_test)

            if DEBUG or verbose:
                print('air_by_date:', test_result.is_air_by_date, 'air_date:', test_result.air_date)
                print('anime:', test_result.is_anime, 'ab_episode_numbers:', test_result.ab_episode_numbers)
                print(test_result)
                print(result)

            self.assertEqual(test_result.which_regex, {section},
                             '{} : {} != {}'.format(cur_test, test_result.which_regex, {section}))
            self.assertEqual(test_result, result, '{} : {} != {}'.format(cur_test, test_result, result))

    def test_anime_sxxexx_file_names(self):
        """
        Test anime SxxExx file names
        """
        np = NameParser(showObj=self.show, validate_show=False)
        self._test_names(np, 'anime_SxxExx', lambda x: x + '.avi')
Ejemplo n.º 5
0
    def test_isGoodName(self):
        list_of_cases = [('Show.Name.S01E02.Test-Test', 'Show/Name'),
                         ('Show.Name.S01E02.Test-Test', 'Show. Name'),
                         ('Show.Name.S01E02.Test-Test', 'Show- Name'),
                         ('Show.Name.Part.IV.Test-Test', 'Show Name'),
                         ('Show.Name.S01.Test-Test', 'Show Name'),
                         ('Show.Name.E02.Test-Test', 'Show: Name'),
                         ('Show Name Season 2 Test', 'Show: Name')]

        for testCase in list_of_cases:
            scene_name, show_name = testCase
            s = TVShow(1, 0)
            s.name = show_name
            s.save_to_db()
            self._test_isGoodName(scene_name, s)
Ejemplo n.º 6
0
    def test_isGoodName(self):
        list_of_cases = [('Show.Name.S01E02.Test-Test', 'Show/Name'),
                         ('Show.Name.S01E02.Test-Test', 'Show. Name'),
                         ('Show.Name.S01E02.Test-Test', 'Show- Name'),
                         ('Show.Name.Part.IV.Test-Test', 'Show Name'),
                         ('Show.Name.S01.Test-Test', 'Show Name'),
                         ('Show.Name.E02.Test-Test', 'Show: Name'),
                         ('Show Name Season 2 Test', 'Show: Name')]

        for testCase in list_of_cases:
            scene_name, show_name = testCase
            s = TVShow(1, 0)
            s.name = show_name
            s.save_to_db()
            self._test_isGoodName(scene_name, s)
Ejemplo n.º 7
0
class UnicodeTests(tests.SiCKRAGETestDBCase):
    def setUp(self):
        super(UnicodeTests, self).setUp()
        self.show = TVShow(1, 1, 'en')
        self.show.name = "The Big Bang Theory"
        self.show.save_to_db()

    def _test_unicode(self, name, result):
        np = NameParser(True, showObj=self.show, validate_show=False)
        parse_result = np.parse(name)

        # this shouldn't raise an exception
        repr(str(parse_result))
        self.assertEqual(parse_result.extra_info, result.extra_info)

    def test_unicode(self):
        for (name, result) in unicode_test_cases:
            self._test_unicode(name, result)
Ejemplo n.º 8
0
class QueueItemAdd(ShowQueueItem):
    def __init__(self, indexer, indexer_id, showDir, default_status, quality,
                 flatten_folders, lang, subtitles, subtitles_sr_metadata,
                 anime, scene, paused, blacklist, whitelist,
                 default_status_after, skip_downloaded):
        super(QueueItemAdd, self).__init__(None, ShowQueueActions.ADD)

        self.indexer = indexer
        self.indexer_id = indexer_id
        self.showDir = showDir
        self.default_status = default_status
        self.quality = quality
        self.flatten_folders = flatten_folders
        self.lang = lang
        self.subtitles = subtitles
        self.subtitles_sr_metadata = subtitles_sr_metadata
        self.anime = anime
        self.scene = scene
        self.paused = paused
        self.blacklist = blacklist
        self.whitelist = whitelist
        self.default_status_after = default_status_after
        self.skip_downloaded = skip_downloaded
        self.priority = srQueuePriorities.HIGH

    @property
    def show_name(self):
        """
        Returns the show name if there is a show object created, if not returns
        the dir that the show is being added to.
        """
        return self.show.name if self.show else os.path.basename(self.showDir)

    @property
    def is_loading(self):
        """
        Returns True if we've gotten far enough to have a show object, or False
        if we still only know the folder name.
        """
        if self.show is None:
            return True

    def run(self):
        start_time = time.time()

        sickrage.app.log.info(
            "Started adding show {} from show dir: {}".format(
                self.show_name, self.showDir))

        index_name = IndexerApi(self.indexer).name

        # make sure the Indexer IDs are valid
        try:

            lINDEXER_API_PARMS = IndexerApi(self.indexer).api_params.copy()
            lINDEXER_API_PARMS['cache'] = False
            lINDEXER_API_PARMS[
                'language'] = self.lang or sickrage.app.config.indexer_default_language

            sickrage.app.log.info("{}: {}".format(index_name,
                                                  repr(lINDEXER_API_PARMS)))

            t = IndexerApi(self.indexer).indexer(**lINDEXER_API_PARMS)

            try:
                s = t[self.indexer_id]
            except indexer_error:
                s = None

            if not s:
                return self._finish_early()

            # this usually only happens if they have an NFO in their show dir which gave us a Indexer ID that has no proper english version of the show
            if not getattr(s, 'seriesname'):
                sickrage.app.log.warning(
                    "Show in {} has no name on {}, probably the wrong language used to search with"
                    .format(self.showDir, index_name))
                sickrage.app.alerts.error(
                    _("Unable to add show"),
                    _("Show in {} has no name on {}, probably the wrong language. Delete .nfo "
                      "and add manually in the correct language").format(
                          self.showDir, index_name))
                return self._finish_early()

            # if the show has no episodes/seasons
            if not len(s):
                sickrage.app.log.warning(
                    "Show " + str(s['seriesname']) + " is on " +
                    str(IndexerApi(self.indexer).name) +
                    " but contains no season/episode data.")
                sickrage.app.alerts.error(
                    _("Unable to add show"),
                    _("Show ") + str(s['seriesname']) + _(" is on ") +
                    str(IndexerApi(self.indexer).name) +
                    _(" but contains no season/episode data."))
                return self._finish_early()
        except Exception as e:
            sickrage.app.log.error(
                "{}: Error while loading information from indexer {}. Error: {}"
                .format(self.indexer_id, index_name, e))

            sickrage.app.alerts.error(
                _("Unable to add show"),
                _("Unable to look up the show in {} on {} using ID {}, not using the NFO. Delete .nfo and try adding "
                  "manually again.").format(self.showDir, index_name,
                                            self.indexer_id))

            if sickrage.app.config.use_trakt:
                title = self.showDir.split("/")[-1]

                data = {
                    'shows': [{
                        'title': title,
                        'ids': {
                            IndexerApi(self.indexer).trakt_id: self.indexer_id
                        }
                    }]
                }

                srTraktAPI()["sync/watchlist"].remove(data)

            return self._finish_early()

        try:
            self.show = TVShow(self.indexer, self.indexer_id, self.lang)

            self.show.load_from_indexer()

            # set up initial values
            self.show.location = self.showDir
            self.show.subtitles = self.subtitles or sickrage.app.config.subtitles_default
            self.show.subtitles_sr_metadata = self.subtitles_sr_metadata
            self.show.quality = self.quality or sickrage.app.config.quality_default
            self.show.flatten_folders = self.flatten_folders or sickrage.app.config.flatten_folders_default
            self.show.anime = self.anime or sickrage.app.config.anime_default
            self.show.scene = self.scene or sickrage.app.config.scene_default
            self.show.skip_downloaded = self.skip_downloaded or sickrage.app.config.skip_downloaded_default
            self.show.paused = self.paused or False

            # set up default new/missing episode status
            sickrage.app.log.info(
                "Setting all current episodes to the specified default status: "
                + str(self.default_status))

            self.show.default_ep_status = self.default_status

            if self.show.anime:
                self.show.release_groups = BlackAndWhiteList(
                    self.show.indexerid)
                if self.blacklist:
                    self.show.release_groups.set_black_keywords(self.blacklist)
                if self.whitelist:
                    self.show.release_groups.set_white_keywords(self.whitelist)

                    # # be smartish about this
                    # if self.show.genre and "talk show" in self.show.genre.lower():
                    #     self.show.air_by_date = 1
                    # if self.show.genre and "documentary" in self.show.genre.lower():
                    #     self.show.air_by_date = 0
                    # if self.show.classification and "sports" in self.show.classification.lower():
                    #     self.show.sports = 1

        except indexer_exception as e:
            sickrage.app.log.warning(
                "Unable to add show due to an error with " +
                IndexerApi(self.indexer).name + ": {}".format(e))
            if self.show:
                sickrage.app.alerts.error(
                    _("Unable to add ") + str(self.show.name) +
                    _(" due to an error with ") +
                    IndexerApi(self.indexer).name + "")
            else:
                sickrage.app.alerts.error(
                    _("Unable to add show due to an error with ") +
                    IndexerApi(self.indexer).name + "")
            return self._finish_early()

        except MultipleShowObjectsException:
            sickrage.app.log.warning("The show in " + self.showDir +
                                     " is already in your show list, skipping")
            sickrage.app.alerts.error(
                _('Show skipped'),
                _("The show in ") + self.showDir +
                _(" is already in your show list"))
            return self._finish_early()

        except Exception as e:
            sickrage.app.log.error("Error trying to add show: {}".format(e))
            sickrage.app.log.debug(traceback.format_exc())
            raise self._finish_early()

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

        try:
            self.show.save_to_db()
        except Exception as e:
            sickrage.app.log.error(
                "Error saving the show to the database: {}".format(e))
            sickrage.app.log.debug(traceback.format_exc())
            raise self._finish_early()

        # add it to the show list
        if not findCertainShow(self.indexer_id):
            sickrage.app.showlist.append(self.show)

        try:
            self.show.load_episodes_from_indexer()
        except Exception as e:
            sickrage.app.log.error("Error with " +
                                   IndexerApi(self.show.indexer).name +
                                   ", not creating episode list: {}".format(e))
            sickrage.app.log.debug(traceback.format_exc())

        try:
            self.show.load_episodes_from_dir()
        except Exception as e:
            sickrage.app.log.debug(
                "Error searching dir for episodes: {}".format(e))
            sickrage.app.log.debug(traceback.format_exc())

        # if they set default ep status to WANTED then run the backlog to search for episodes
        if self.show.default_ep_status == WANTED:
            sickrage.app.log.info(
                "Launching backlog for this show since its episodes are WANTED"
            )
            sickrage.app.backlog_searcher.search_backlog([self.show])

        self.show.write_metadata(force=True)
        self.show.populate_cache()

        if sickrage.app.config.use_trakt:
            # if there are specific episodes that need to be added by trakt
            sickrage.app.trakt_searcher.manageNewShow(self.show)

            # add show to trakt.tv library
            if sickrage.app.config.trakt_sync:
                sickrage.app.trakt_searcher.addShowToTraktLibrary(self.show)

            if sickrage.app.config.trakt_sync_watchlist:
                sickrage.app.log.info("update watchlist")
                sickrage.app.notifier_providers['trakt'].update_watchlist(
                    show_obj=self.show)

        # Load XEM data to DB for show
        xem_refresh(self.show.indexerid, self.show.indexer, force=True)

        # check if show has XEM mapping so we can determin if searches should go by scene numbering or indexer numbering.
        if not self.scene and get_xem_numbering_for_show(
                self.show.indexerid, self.show.indexer):
            self.show.scene = 1

        self.show.default_ep_status = self.default_status_after

        self.show.save_to_db()

        sickrage.app.name_cache.build(self.show)

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

        self.finish()

        sickrage.app.log.info(
            "Finished adding show {} in {}s from show dir: {}".format(
                self.show_name, round(time.time() - start_time, 2),
                self.showDir))

    def _finish_early(self):
        if self.show: sickrage.app.show_queue.removeShow(self.show)
Ejemplo n.º 9
0
class BasicTests(tests.SiCKRAGETestDBCase):
    def setUp(self):
        super(BasicTests, self).setUp()
        self.show = TVShow(1, 1, 'en')
        self.show.save_to_db()

    def _test_names(self, np, section, transform=None, verbose=False):
        if VERBOSE or verbose:
            print('Running', section, 'tests')
        for cur_test_base in simple_test_cases[section]:
            if transform:
                cur_test = transform(cur_test_base)
                np.file_name = cur_test
            else:
                cur_test = cur_test_base
            if VERBOSE or verbose:
                print('Testing', cur_test)

            result = simple_test_cases[section][cur_test_base]
            np.showObj.name = result.series_name if result else None
            if not result:
                self.assertRaises(InvalidNameException, np.parse, cur_test)
                return
            else:
                result.which_regex = {section}
                test_result = np.parse(cur_test)

            if DEBUG or verbose:
                print('air_by_date:', test_result.is_air_by_date, 'air_date:', test_result.air_date)
                print('anime:', test_result.is_anime, 'ab_episode_numbers:', test_result.ab_episode_numbers)
                print(test_result)
                print(result)
            self.assertEqual(test_result.which_regex, {section})
            self.assertEqual(str(test_result), str(result))

    def test_standard_names(self):
        np = NameParser(True, showObj=self.show, validate_show=False)
        self._test_names(np, 'standard')

    def test_standard_repeat_names(self):
        np = NameParser(False, showObj=self.show, validate_show=False)
        self._test_names(np, 'standard_repeat')

    def test_fov_names(self):
        np = NameParser(False, showObj=self.show, validate_show=False)
        self._test_names(np, 'fov')

    def test_fov_repeat_names(self):
        np = NameParser(False, showObj=self.show, validate_show=False)
        self._test_names(np, 'fov_repeat')

    def test_stupid_names(self):
        np = NameParser(False, showObj=self.show, validate_show=False)
        self._test_names(np, 'stupid')

    def test_no_season_names(self):
        np = NameParser(False, showObj=self.show, validate_show=False)
        self._test_names(np, 'no_season')

    def test_no_season_general_names(self):
        np = NameParser(False, showObj=self.show, validate_show=False)
        self._test_names(np, 'no_season_general')

    def test_no_season_multi_ep_names(self):
        np = NameParser(False, showObj=self.show, validate_show=False)
        self._test_names(np, 'no_season_multi_ep')

    def test_season_only_names(self):
        np = NameParser(False, showObj=self.show, validate_show=False)
        self._test_names(np, 'season_only')

    def test_standard_file_names(self):
        np = NameParser(showObj=self.show, validate_show=False)
        self._test_names(np, 'standard', lambda x: x + '.avi')

    def test_standard_repeat_file_names(self):
        np = NameParser(showObj=self.show, validate_show=False)
        self._test_names(np, 'standard_repeat', lambda x: x + '.avi')

    def test_fov_file_names(self):
        np = NameParser(showObj=self.show, validate_show=False)
        self._test_names(np, 'fov', lambda x: x + '.avi')

    def test_fov_repeat_file_names(self):
        np = NameParser(showObj=self.show, validate_show=False)
        self._test_names(np, 'fov_repeat', lambda x: x + '.avi')

    def test_stupid_file_names(self):
        np = NameParser(showObj=self.show, validate_show=False)
        self._test_names(np, 'stupid', lambda x: x + '.avi')

    def test_no_season_file_names(self):
        np = NameParser(showObj=self.show, validate_show=False)
        self._test_names(np, 'no_season', lambda x: x + '.avi')

    def test_no_season_general_file_names(self):
        np = NameParser(showObj=self.show, validate_show=False)
        self._test_names(np, 'no_season_general', lambda x: x + '.avi')

    def test_no_season_multi_ep_file_names(self):
        np = NameParser(showObj=self.show, validate_show=False)
        self._test_names(np, 'no_season_multi_ep', lambda x: x + '.avi')

    def test_season_only_file_names(self):
        np = NameParser(showObj=self.show, validate_show=False)
        self._test_names(np, 'season_only', lambda x: x + '.avi')

    def test_combination_names(self):
        pass
Ejemplo n.º 10
0
class QueueItemAdd(ShowQueueItem):
    def __init__(self, indexer, indexer_id, showDir, default_status, quality, flatten_folders, lang, subtitles,
                 subtitles_sr_metadata, anime, scene, paused, blacklist, whitelist, default_status_after,
                 skip_downloaded):
        super(QueueItemAdd, self).__init__(None, ShowQueueActions.ADD)

        self.indexer = indexer
        self.indexer_id = indexer_id
        self.showDir = showDir
        self.default_status = default_status
        self.quality = quality
        self.flatten_folders = flatten_folders
        self.lang = lang
        self.subtitles = subtitles
        self.subtitles_sr_metadata = subtitles_sr_metadata
        self.anime = anime
        self.scene = scene
        self.paused = paused
        self.blacklist = blacklist
        self.whitelist = whitelist
        self.default_status_after = default_status_after
        self.skip_downloaded = skip_downloaded
        self.priority = srQueuePriorities.HIGH

    @property
    def show_name(self):
        """
        Returns the show name if there is a show object created, if not returns
        the dir that the show is being added to.
        """
        return self.show.name if self.show else os.path.basename(self.showDir)

    @property
    def is_loading(self):
        """
        Returns True if we've gotten far enough to have a show object, or False
        if we still only know the folder name.
        """
        if self.show is None:
            return True

    def run(self):
        start_time = time.time()

        sickrage.app.log.info("Started adding show {} from show dir: {}".format(self.show_name, self.showDir))

        index_name = IndexerApi(self.indexer).name

        # make sure the Indexer IDs are valid
        try:

            lINDEXER_API_PARMS = IndexerApi(self.indexer).api_params.copy()
            lINDEXER_API_PARMS['cache'] = False
            lINDEXER_API_PARMS['language'] = self.lang or sickrage.app.config.indexer_default_language

            sickrage.app.log.info("{}: {}".format(index_name, repr(lINDEXER_API_PARMS)))

            t = IndexerApi(self.indexer).indexer(**lINDEXER_API_PARMS)

            try:
                s = t[self.indexer_id]
            except indexer_error:
                s = None

            if not s:
                return self._finish_early()

            # this usually only happens if they have an NFO in their show dir which gave us a Indexer ID that has no proper english version of the show
            if not getattr(s, 'seriesname'):
                sickrage.app.log.warning(
                    "Show in {} has no name on {}, probably the wrong language used to search with".format(self.showDir,
                                                                                                           index_name))
                sickrage.app.alerts.error(_("Unable to add show"),
                                          _("Show in {} has no name on {}, probably the wrong language. Delete .nfo "
                                            "and add manually in the correct language").format(self.showDir,
                                                                                               index_name))
                return self._finish_early()

            # if the show has no episodes/seasons
            if not len(s):
                sickrage.app.log.warning("Show " + str(s['seriesname']) + " is on " + str(
                    IndexerApi(self.indexer).name) + " but contains no season/episode data.")
                sickrage.app.alerts.error(_("Unable to add show"),
                                          _("Show ") + str(s['seriesname']) + _(" is on ") + str(
                                              IndexerApi(
                                                  self.indexer).name) + _(
                                              " but contains no season/episode data."))
                return self._finish_early()
        except Exception as e:
            sickrage.app.log.error(
                "{}: Error while loading information from indexer {}. Error: {}".format(self.indexer_id, index_name, e))

            sickrage.app.alerts.error(
                _("Unable to add show"),
                _("Unable to look up the show in {} on {} using ID {}, not using the NFO. Delete .nfo and try adding "
                  "manually again.").format(self.showDir, index_name, self.indexer_id)
            )

            if sickrage.app.config.use_trakt:
                title = self.showDir.split("/")[-1]

                data = {
                    'shows': [
                        {
                            'title': title,
                            'ids': {IndexerApi(self.indexer).trakt_id: self.indexer_id}
                        }
                    ]
                }

                srTraktAPI()["sync/watchlist"].remove(data)

            return self._finish_early()

        try:
            self.show = TVShow(self.indexer, self.indexer_id, self.lang)

            self.show.load_from_indexer()

            # set up initial values
            self.show.location = self.showDir
            self.show.subtitles = self.subtitles or sickrage.app.config.subtitles_default
            self.show.subtitles_sr_metadata = self.subtitles_sr_metadata
            self.show.quality = self.quality or sickrage.app.config.quality_default
            self.show.flatten_folders = self.flatten_folders or sickrage.app.config.flatten_folders_default
            self.show.anime = self.anime or sickrage.app.config.anime_default
            self.show.scene = self.scene or sickrage.app.config.scene_default
            self.show.skip_downloaded = self.skip_downloaded or sickrage.app.config.skip_downloaded_default
            self.show.paused = self.paused or False

            # set up default new/missing episode status
            sickrage.app.log.info(
                "Setting all current episodes to the specified default status: " + str(self.default_status))

            self.show.default_ep_status = self.default_status

            if self.show.anime:
                self.show.release_groups = BlackAndWhiteList(self.show.indexerid)
                if self.blacklist:
                    self.show.release_groups.set_black_keywords(self.blacklist)
                if self.whitelist:
                    self.show.release_groups.set_white_keywords(self.whitelist)

                    # # be smartish about this
                    # if self.show.genre and "talk show" in self.show.genre.lower():
                    #     self.show.air_by_date = 1
                    # if self.show.genre and "documentary" in self.show.genre.lower():
                    #     self.show.air_by_date = 0
                    # if self.show.classification and "sports" in self.show.classification.lower():
                    #     self.show.sports = 1

        except indexer_exception as e:
            sickrage.app.log.warning(
                "Unable to add show due to an error with " + IndexerApi(
                    self.indexer).name + ": {}".format(e))
            if self.show:
                sickrage.app.alerts.error(
                    _("Unable to add ") + str(self.show.name) + _(" due to an error with ") + IndexerApi(
                        self.indexer).name + "")
            else:
                sickrage.app.alerts.error(
                    _("Unable to add show due to an error with ") + IndexerApi(self.indexer).name + "")
            return self._finish_early()

        except MultipleShowObjectsException:
            sickrage.app.log.warning("The show in " + self.showDir + " is already in your show list, skipping")
            sickrage.app.alerts.error(_('Show skipped'),
                                      _("The show in ") + self.showDir + _(" is already in your show list"))
            return self._finish_early()

        except Exception as e:
            sickrage.app.log.error("Error trying to add show: {}".format(e))
            sickrage.app.log.debug(traceback.format_exc())
            raise self._finish_early()

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

        try:
            self.show.save_to_db()
        except Exception as e:
            sickrage.app.log.error("Error saving the show to the database: {}".format(e))
            sickrage.app.log.debug(traceback.format_exc())
            raise self._finish_early()

        # add it to the show list
        if not findCertainShow(self.indexer_id):
            sickrage.app.showlist.append(self.show)

        try:
            self.show.load_episodes_from_indexer()
        except Exception as e:
            sickrage.app.log.error(
                "Error with " + IndexerApi(
                    self.show.indexer).name + ", not creating episode list: {}".format(e))
            sickrage.app.log.debug(traceback.format_exc())

        try:
            self.show.load_episodes_from_dir()
        except Exception as e:
            sickrage.app.log.debug("Error searching dir for episodes: {}".format(e))
            sickrage.app.log.debug(traceback.format_exc())

        # if they set default ep status to WANTED then run the backlog to search for episodes
        if self.show.default_ep_status == WANTED:
            sickrage.app.log.info("Launching backlog for this show since its episodes are WANTED")
            sickrage.app.backlog_searcher.search_backlog([self.show])

        self.show.write_metadata(force=True)
        self.show.populate_cache()

        if sickrage.app.config.use_trakt:
            # if there are specific episodes that need to be added by trakt
            sickrage.app.trakt_searcher.manageNewShow(self.show)

            # add show to trakt.tv library
            if sickrage.app.config.trakt_sync:
                sickrage.app.trakt_searcher.addShowToTraktLibrary(self.show)

            if sickrage.app.config.trakt_sync_watchlist:
                sickrage.app.log.info("update watchlist")
                sickrage.app.notifier_providers['trakt'].update_watchlist(show_obj=self.show)

        # Load XEM data to DB for show
        xem_refresh(self.show.indexerid, self.show.indexer, force=True)

        # check if show has XEM mapping so we can determin if searches should go by scene numbering or indexer numbering.
        if not self.scene and get_xem_numbering_for_show(self.show.indexerid, self.show.indexer):
            self.show.scene = 1

        self.show.default_ep_status = self.default_status_after

        self.show.save_to_db()

        sickrage.app.name_cache.build(self.show)

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

        self.finish()

        sickrage.app.log.info(
            "Finished adding show {} in {}s from show dir: {}".format(self.show_name,
                                                                      round(time.time() - start_time, 2),
                                                                      self.showDir))

    def _finish_early(self):
        if self.show: sickrage.app.show_queue.removeShow(self.show)