diff --git a/modules/builder.py b/modules/builder.py index 03d64e95..7a347f1e 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -951,7 +951,8 @@ class CollectionBuilder: "list_type": "popular" if method_name == "tautulli_popular" else "watched", "list_days": util.parse("list_days", dict_data, datatype="int", methods=dict_methods, default=30, parent=method_name), "list_size": util.parse("list_size", dict_data, datatype="int", methods=dict_methods, default=10, parent=method_name), - "list_buffer": util.parse("list_buffer", dict_data, datatype="int", methods=dict_methods, default=20, parent=method_name) + "list_buffer": util.parse("list_buffer", dict_data, datatype="int", methods=dict_methods, default=20, parent=method_name), + "list_minimum": util.parse("list_minimum", dict_data, datatype="int", methods=dict_methods, default=0, parent=method_name) })) def _tmdb(self, method_name, method_data): diff --git a/modules/tautulli.py b/modules/tautulli.py index 82669065..3238f161 100644 --- a/modules/tautulli.py +++ b/modules/tautulli.py @@ -28,6 +28,7 @@ class Tautulli: logger.info(f"Processing Tautulli Most {params['list_type'].capitalize()}: {params['list_size']} {'Movies' if library.is_movie else 'Shows'}") response = self._request(f"{self.url}/api/v2?apikey={self.apikey}&cmd=get_home_stats&time_range={params['list_days']}&stats_count={query_size}") stat_id = f"{'popular' if params['list_type'] == 'popular' else 'top'}_{'movies' if library.is_movie else 'tv'}" + stat_type = "total_plays" if params['list_type'] == 'popular' else "users_watched" items = None for entry in response["response"]["data"]: @@ -39,9 +40,10 @@ class Tautulli: section_id = self._section_id(library.name) rating_keys = [] - count = 0 for item in items: - if item["section_id"] == section_id and count < int(params['list_size']): + if item["section_id"] == section_id and len(rating_keys) < int(params['list_size']): + if item[stat_type] < params['list_minimum']: + continue try: plex_item = library.fetchItem(int(item["rating_key"])) if not isinstance(plex_item, (Movie, Show)): @@ -53,8 +55,6 @@ class Tautulli: rating_keys.append(new_item[0].ratingKey) else: logger.error(f"Plex Error: Item {item} not found") - continue - count += 1 logger.debug("") logger.debug(f"{len(rating_keys)} Keys Found: {rating_keys}") return rating_keys