Esempio n. 1
0
    def convert_info_dates(info_dict):
        if info_dict is None:
            return None

        if not isinstance(info_dict, dict):
            return info_dict

        dates_to_convert = [i for i in info_dict.keys() if i in info_dates]
        converted_dates = {key: tools.utc_to_local(info_dict.get(key))
                           for key in dates_to_convert if info_dict.get(key)}
        info_dict.update(converted_dates)
        return info_dict
Esempio n. 2
0
    def _post_process(self, item, prepend_date=False, mixed_list=False):
        if not item:
            return

        if self.show_original_title and item.get("info",
                                                 {}).get("originaltitle"):
            name = item.get("info", {}).get("originaltitle")
        else:
            name = item.get("info", {}).get("title")

        if not name:
            g.log("Item has no title: {}".format(item), "error")

        if (not item["info"]["mediatype"] == "list" and not self.hide_unaired
                and not self.is_aired(item["info"])):
            name = g.color_string(tools.italic_string(name), "red")

        if item["info"]["mediatype"] == "episode":
            if self.title_appends_mixed and mixed_list:
                name = self._handle_episode_title_appending(
                    name, item, self.title_appends_mixed)
            elif self.title_appends_general and not mixed_list:
                name = self._handle_episode_title_appending(
                    name, item, self.title_appends_general)

        if item["info"]["mediatype"] == "list" and self.list_title_appends == 1:
            name += " - {}".format(g.color_string(item["info"]["username"]))

        if not item["info"]["mediatype"] == "list" and prepend_date:
            release_date = tools.utc_to_local(item["info"].get("aired", None))
            if release_date:
                release_day = tools.parse_datetime(
                    release_date, g.DATE_TIME_FORMAT).strftime("%d %b")
                name = "[{}] {}".format(release_day, name)
        item.update({"name": name})
        item["info"]["title"] = name

        return item