Ejemplo n.º 1
0
    def massEditSubmit(
        self,
        paused=None,
        default_ep_status=None,
        anime=None,
        sports=None,
        scene=None,
        season_folders=None,
        quality_preset=None,
        subtitles=None,
        air_by_date=None,
        anyQualities=None,
        bestQualities=None,
        toEdit=None,
        *args,
        **kwargs,
    ):
        dir_map = {}
        for cur_arg in [x for x in kwargs if x.startswith("orig_root_dir_")]:
            dir_map[kwargs[cur_arg]] = kwargs[cur_arg.replace(
                "orig_root_dir_", "new_root_dir_")]

        showIDs = toEdit.split("|")
        errors = []
        for curShow in showIDs:
            curErrors = []
            show_obj = Show.find(settings.showList, int(curShow or 0))
            if not show_obj:
                continue

            cur_root_dir = self.__gooey_path(show_obj._location, "dirname")
            cur_show_dir = self.__gooey_path(show_obj._location, "basename")
            if cur_root_dir and dir_map.get(
                    cur_root_dir
            ) and cur_root_dir != dir_map.get(cur_root_dir):
                new_show_dir = os.path.join(dir_map[cur_root_dir],
                                            cur_show_dir)
                logger.info("For show " + show_obj.name +
                            " changing dir from " + show_obj._location +
                            " to " + new_show_dir)
            else:
                new_show_dir = show_obj._location

            new_paused = ("off", "on")[(paused == "enable",
                                        show_obj.paused)[paused == "keep"]]
            new_default_ep_status = (
                default_ep_status,
                show_obj.default_ep_status)[default_ep_status == "keep"]
            new_anime = ("off", "on")[(anime == "enable",
                                       show_obj.anime)[anime == "keep"]]
            new_sports = ("off", "on")[(sports == "enable",
                                        show_obj.sports)[sports == "keep"]]
            new_scene = ("off", "on")[(scene == "enable",
                                       show_obj.scene)[scene == "keep"]]
            new_air_by_date = (
                "off", "on")[(air_by_date == "enable",
                              show_obj.air_by_date)[air_by_date == "keep"]]
            new_season_folders = ("off", "on")[(
                season_folders == "enable",
                show_obj.season_folders)[season_folders == "keep"]]
            new_subtitles = ("off",
                             "on")[(subtitles == "enable",
                                    show_obj.subtitles)[subtitles == "keep"]]

            if quality_preset == "keep":
                anyQualities, bestQualities = Quality.splitQuality(
                    show_obj.quality)
            elif try_int(quality_preset, None):
                bestQualities = []

            exceptions_list = []

            curErrors += self.editShow(
                curShow,
                new_show_dir,
                anyQualities,
                bestQualities,
                exceptions_list,
                defaultEpStatus=new_default_ep_status,
                season_folders=new_season_folders,
                paused=new_paused,
                sports=new_sports,
                subtitles=new_subtitles,
                anime=new_anime,
                scene=new_scene,
                air_by_date=new_air_by_date,
                directCall=True,
            )

            if curErrors:
                logger.exception("Errors: " + str(curErrors))
                errors.append(
                    "<b>{0}:</b>\n<ul>".format(show_obj.name) + " ".join(
                        ["<li>{0}</li>".format(error)
                         for error in curErrors]) + "</ul>")

        if errors:
            ui.notifications.error(
                _("{num_errors:d} error{plural} while saving changes:").format(
                    num_errors=len(errors),
                    plural="" if len(errors) == 1 else "s"), " ".join(errors))

        return self.redirect("/manage/")
Ejemplo n.º 2
0
 def showQualSnatched(show):
     return Quality.splitQuality(show.quality)[1]