Example #1
0
 def _update_season_tmdb(self, db_object):
     if (
         (self.metadata_location == 1 or self.tvshows_preferred_art_source == 1)
         and (self._tmdb_needs_update(db_object) or self._force_update(db_object))
         and self._tmdb_show_id_valid(db_object)
     ):
         if self.metadata_location == 1:
             tools.smart_merge_dictionary(
                 db_object,
                 self.tmdb_api.get_season(
                     db_object["tmdb_show_id"],
                     tools.safe_dict_get(
                         db_object, "trakt_object", "info", "season"
                     ),
                 ),
             )
         elif self.tvshows_preferred_art_source == 1:
             tools.smart_merge_dictionary(
                 db_object,
                 self.tmdb_api.get_season_art(
                     db_object["tmdb_show_id"],
                     tools.safe_dict_get(
                         db_object, "trakt_object", "info", "season"
                     ),
                 ),
             )
Example #2
0
    def _update_tvshow_trakt(self, db_object):
        if (
            self.metadata_location == 0
            and tools.safe_dict_get(db_object, "trakt_object", "info")
            and db_object.get("trakt_id")
        ):
            if (
                tools.safe_dict_get(db_object, "trakt_object", "info", "language")
                and self.trakt_api.language
                != tools.safe_dict_get(db_object, "trakt_object", "info", "language")
                and tools.safe_dict_get(
                    db_object, "trakt_object", "info", "available_translations"
                )
                and self.trakt_api.language
                in tools.safe_dict_get(
                    db_object, "trakt_object", "info", "available_translations"
                )
            ):
                db_object["trakt_object"]["info"].update(
                    self.trakt_api.get_show_translation(db_object["trakt_id"])
                )

            db_object["trakt_object"]["info"][
                "aliases"
            ] = self.trakt_api.get_show_aliases(db_object["trakt_id"])
    def _update_tvshow_fallback(self, db_object):
        if self._tvdb_id_valid(db_object):
            if (self.metadata_location == 1 and
                    not tools.safe_dict_get(db_object, "tmdb_object", "info")
                    and
                    not tools.safe_dict_get(db_object, "tvdb_object", "info")):
                tools.smart_merge_dictionary(
                    db_object, self.tvdb_api.get_show(db_object["tvdb_id"]))
            if (self.tvshows_preferred_art_source != 2
                    and not self._tmdb_meta_up_to_par("tvshow", db_object)
                    and not self._tvdb_meta_up_to_par("tvshow", db_object)):
                tools.smart_merge_dictionary(
                    db_object,
                    self.tvdb_api.get_show_art(db_object["tvdb_id"]))

        if self._tmdb_id_valid(db_object):
            if (self.metadata_location == 2 and
                    not tools.safe_dict_get(db_object, "tmdb_object", "info")
                    and
                    not tools.safe_dict_get(db_object, "tvdb_object", "info")):
                tools.smart_merge_dictionary(
                    db_object, self.tmdb_api.get_show(db_object["tmdb_id"]))
            if (self.tvshows_preferred_art_source != 1
                    and not self._tmdb_meta_up_to_par("tvshow", db_object)
                    and not self._tvdb_meta_up_to_par("tvshow", db_object)):
                tools.smart_merge_dictionary(
                    db_object,
                    self.tmdb_api.get_show_art(db_object["tmdb_id"]))
 def _update_tvshow_rating(self, db_object):
     if not tools.safe_dict_get(db_object, "tmdb_object",
                                "info") and self._tmdb_id_valid(db_object):
         tools.smart_merge_dictionary(
             db_object, self.tmdb_api.get_show_rating(db_object["tmdb_id"]))
     if not tools.safe_dict_get(db_object, "tvdb_object",
                                "info") and self._tvdb_id_valid(db_object):
         tools.smart_merge_dictionary(
             db_object, self.tvdb_api.get_show_rating(db_object["tvdb_id"]))
Example #5
0
 def sort_list_items(db_list, trakt_list):
     return [
         t
         for o in trakt_list
         for t in db_list
         if t
         and o
         and tools.safe_dict_get(t, "info", "trakt_id")
         == tools.safe_dict_get(o, "trakt_id")
     ]
 def _update_tvshow_cast(self, db_object):
     if (not tools.safe_dict_get(db_object, "tmdb_object", "cast")
             and self._tmdb_id_valid(db_object)
             and not tools.safe_dict_get(db_object, "tvdb_object", "cast")):
         tools.smart_merge_dictionary(
             db_object, self.tmdb_api.get_show_cast(db_object["tmdb_id"]))
     if (not tools.safe_dict_get(db_object, "tvdb_object", "cast")
             and self._tvdb_id_valid(db_object)
             and not tools.safe_dict_get(db_object, "tmdb_object", "cast")):
         tools.smart_merge_dictionary(
             db_object, self.tvdb_api.get_show_cast(db_object["tvdb_id"]))
Example #7
0
    def _update_episode_fallback(self, db_object):
        if self._tvdb_show_id_valid(db_object):
            if (
                self.metadata_location == 1
                and not tools.safe_dict_get(db_object, "tmdb_object", "info")
                and not tools.safe_dict_get(db_object, "tvdb_object", "info")
            ):
                tools.smart_merge_dictionary(
                    db_object,
                    self.tvdb_api.get_episode(
                        db_object["tvdb_show_id"],
                        tools.safe_dict_get(
                            db_object, "trakt_object", "info", "season"
                        ),
                        tools.safe_dict_get(
                            db_object, "trakt_object", "info", "episode"
                        ),
                    ),
                )

        if self._tmdb_show_id_valid(db_object):
            if (
                self.metadata_location == 2
                and not tools.safe_dict_get(db_object, "tmdb_object", "info")
                and not tools.safe_dict_get(db_object, "tvdb_object", "info")
            ):
                tools.smart_merge_dictionary(
                    db_object,
                    self.tmdb_api.get_episode(
                        db_object["tmdb_show_id"],
                        tools.safe_dict_get(
                            db_object, "trakt_object", "info", "season"
                        ),
                        tools.safe_dict_get(db_object, "trakt_object", "info", "e"),
                    ),
                )
            if (
                self.tvshows_preferred_art_source != 1
                and not self._tmdb_meta_up_to_par("episode", db_object)
                and not self._tvdb_meta_up_to_par("episode", db_object)
            ):
                tools.smart_merge_dictionary(
                    db_object,
                    self.tmdb_api.get_episode_art(
                        db_object["tmdb_show_id"],
                        tools.safe_dict_get(
                            db_object, "trakt_object", "info", "season"
                        ),
                        tools.safe_dict_get(
                            db_object, "trakt_object", "info", "episode"
                        ),
                    ),
                )
Example #8
0
 def art_meta_up_to_par(media_type, item):
     try:
         if not item:
             return False
         if media_type in ["tvshow", "season", "movie"] and not tools.safe_dict_get(item, "art", "poster"):
             return False
         if media_type in ["tvshow", "movie"] and not tools.safe_dict_get(item, "art", "fanart"):
             return False
         if (media_type == "episode") and not tools.safe_dict_get(item, "art", "thumb"):
             return False
         return True
     except KeyError:
         return False
Example #9
0
 def _update_episode_tvdb(self, db_object):
     if (
         (self.metadata_location == 2 or self.tvshows_preferred_art_source == 2)
         and (self._tvdb_needs_update(db_object) or self._force_update(db_object))
         and self._tvdb_show_id_valid(db_object)
     ):
         tools.smart_merge_dictionary(
             db_object,
             self.tvdb_api.get_episode(
                 db_object["tvdb_show_id"],
                 tools.safe_dict_get(db_object, "trakt_object", "info", "season"),
                 tools.safe_dict_get(db_object, "trakt_object", "info", "episode"),
             ),
         )
 def _update_movie_trakt(self, db_object):
     if (self.metadata_location == META_TRAKT
             and tools.safe_dict_get(db_object, "trakt_object", "info")
             and db_object.get("trakt_id") and tools.safe_dict_get(
                 db_object, "trakt_object", "info", "language")
             and self.trakt_api.language != tools.safe_dict_get(
                 db_object, "trakt_object", "info", "language")
             and tools.safe_dict_get(db_object, "trakt_object", "info",
                                     "available_translations")
             and self.trakt_api.language in tools.safe_dict_get(
                 db_object, "trakt_object", "info",
                 "available_translations")):
         db_object["trakt_object"]["info"].update(
             self.trakt_api.get_movie_translation(db_object["trakt_id"]))
Example #11
0
 def get_show_rating(self, tmdb_id):
     result = tools.filter_dictionary(
         tools.safe_dict_get(self.get_json_cached("tv/{}".format(tmdb_id)),
                             "info"),
         "rating.tmdb",
     )
     return {"info": result} if result else None
Example #12
0
 def get_movie_rating(self, tmdb_id):
     result = tools.filter_dictionary(
         tools.safe_dict_get(self.get_json("movie/{}".format(tmdb_id)),
                             "info"),
         "rating",
     )
     return {"info": result} if result else None
Example #13
0
 def _update_movie_cast(self, db_object):
     if not tools.safe_dict_get(
         db_object, "tmdb_object", "cast"
     ) and self._tmdb_id_valid(db_object):
         tools.smart_merge_dictionary(
             db_object, self.tmdb_api.get_movie_cast(db_object["tmdb_id"])
         )
Example #14
0
 def get_episode_rating(self, tmdb_id, season, episode):
     result = tools.filter_dictionary(
         tools.safe_dict_get(
             self.get_json_cached("tv/{}/season/{}/episode/{}".format(
                 tmdb_id, season, episode)),
             "info",
         ),
         "rating.tmdb",
     )
     return {"info": result} if result else None
 def _update_episode_rating(self, db_object):
     if not tools.safe_dict_get(
             db_object, "tmdb_object",
             "info") and self._tmdb_show_id_valid(db_object):
         tools.smart_merge_dictionary(
             db_object,
             self.tmdb_api.get_episode_rating(
                 db_object["tmdb_show_id"],
                 tools.safe_dict_get(db_object, "trakt_object", "info",
                                     "season"),
                 tools.safe_dict_get(db_object, "trakt_object", "info",
                                     "episode"),
             ),
         )
     if not tools.safe_dict_get(
             db_object, "tvdb_object",
             "info") and self._tvdb_show_id_valid(db_object):
         tools.smart_merge_dictionary(
             db_object,
             self.tvdb_api.get_episode_rating(
                 db_object["tvdb_show_id"],
                 tools.safe_dict_get(db_object, "trakt_object", "info",
                                     "season"),
                 tools.safe_dict_get(db_object, "trakt_object", "info",
                                     "episode"),
             ),
         )
    def _update_season_fallback(self, db_object):
        if self._tmdb_show_id_valid(db_object):
            if (self.metadata_location == META_TVDB and
                    not tools.safe_dict_get(db_object, "tmdb_object", "info")
                    and
                    not tools.safe_dict_get(db_object, "tvdb_object", "info")):
                tools.smart_merge_dictionary(
                    db_object,
                    self.tmdb_api.get_season(
                        db_object["tmdb_show_id"],
                        tools.safe_dict_get(db_object, "trakt_object", "info",
                                            "season"),
                    ),
                )
            if (self.tvshows_preferred_art_source != ART_TMDB
                    and self.metadata_location != META_TMDB
                    and not self._tmdb_meta_up_to_par("season", db_object)
                    and not self._tvdb_meta_up_to_par("season", db_object)):
                tools.smart_merge_dictionary(
                    db_object,
                    self.tvdb_api.get_season_art(
                        db_object["tmdb_show_id"],
                        tools.safe_dict_get(db_object, "trakt_object", "info",
                                            "season"),
                    ),
                )

        if self._tvdb_show_id_valid(db_object):
            if (self.tvshows_preferred_art_source != ART_TVDB
                    and self.metadata_location != META_TVDB
                    and not self._tmdb_meta_up_to_par("season", db_object)
                    and not self._tvdb_meta_up_to_par("season", db_object)):
                tools.smart_merge_dictionary(
                    db_object,
                    self.tvdb_api.get_season_art(
                        db_object["tvdb_show_id"],
                        tools.safe_dict_get(db_object, "trakt_object", "info",
                                            "season"),
                    ),
                )
 def _update_season_fanart(self, db_object):
     if (self.fanarttv_api.fanart_support
             and (self._fanart_needs_update(db_object)
                  or self._force_update(db_object))
             and self._tvdb_show_id_valid(db_object)):
         tools.smart_merge_dictionary(
             db_object,
             self.fanarttv_api.get_season(
                 db_object.get("tvdb_show_id"),
                 tools.safe_dict_get(db_object, "trakt_object", "info",
                                     "season"),
             ),
         )
 def _update_season_tvdb(self, db_object):
     if ((self.tvshows_preferred_art_source == 2
          or not self._tmdb_meta_up_to_par("season", db_object))
             and (self._tvdb_needs_update(db_object)
                  or self._force_update(db_object))
             and self._tvdb_show_id_valid(db_object)):
         tools.smart_merge_dictionary(
             db_object,
             self.tvdb_api.get_season_art(
                 db_object["tvdb_show_id"],
                 tools.safe_dict_get(db_object, "trakt_object", "info",
                                     "season"),
             ),
         )
Example #19
0
 def get_show_cast(self, tmdb_id):
     result = tools.safe_dict_get(
         self.get_json("tv/{}/credits".format(tmdb_id)), "cast"
     )
     return {"cast": result} if result else None
Example #20
0
 def get_movie_cast(self, tmdb_id):
     result = tools.safe_dict_get(
         self.get_json_cached("movie/{}/credits".format(tmdb_id)), "cast")
     return {"cast": result} if result else None
 def sort_list_items(db_list, trakt_list):
     db_list_dict = {
         tools.safe_dict_get(t, "info", "trakt_id"): t
         for t in db_list
     }
     return [db_list_dict.get(o.get('trakt_id')) for o in trakt_list]
 def full_meta_up_to_par(media_type, item):
     if tools.safe_dict_get(item, "info", "title"):
         return True
     elif MetadataHandler.art_meta_up_to_par(media_type, item):
         return True
     return False