From d87e76e7c4311f118f74dd4e96be5621498862e5 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Sat, 4 Mar 2023 22:22:07 -0500 Subject: [PATCH] [120] add `has_stinger` and `stinger_rating` filters --- VERSION | 2 +- docs/metadata/filters.md | 46 ++++++++++++++++++++++------------------ modules/builder.py | 6 +++--- modules/config.py | 8 +++++++ modules/plex.py | 8 +++++++ 5 files changed, 45 insertions(+), 25 deletions(-) diff --git a/VERSION b/VERSION index 750f4480..33622094 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.18.3-develop119 +1.18.3-develop120 diff --git a/docs/metadata/filters.md b/docs/metadata/filters.md index f6fd3f80..dbced14e 100644 --- a/docs/metadata/filters.md +++ b/docs/metadata/filters.md @@ -127,12 +127,13 @@ Boolean Filters have no modifiers. ### Attribute -| Boolean Filters | Description | Movies | Shows | Seasons | Episodes | Artists | Albums | Track | -|:-------------------|:------------------------------------------------------------|:-------:|:-------------------:|:-------------------:|:--------:|:--------:|:--------:|:--------:| -| `has_collection` | Matches every item that has or does not have a collection | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| `has_edition` | Matches every item that has or does not have an edition | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | -| `has_dolby_vision` | Matches every item that has or does not have a dolby vision | ✅ | ✅1 | ✅1 | ✅ | ❌ | ❌ | ❌ | -| `has_overlay` | Matches every item that has or does not have an overlay | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | +| Boolean Filters | Description | Movies | Shows | Seasons | Episodes | Artists | Albums | Track | +|:-------------------|:---------------------------------------------------------------------------------------------------------|:-------:|:-------------------:|:-------------------:|:--------:|:--------:|:--------:|:--------:| +| `has_collection` | Matches every item that has or does not have a collection | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| `has_edition` | Matches every item that has or does not have an edition | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | +| `has_stinger` | Matches every item that has a [media stinger](http://www.mediastinger.com/) (After/During Credits Scene) | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | +| `has_dolby_vision` | Matches every item that has or does not have a dolby vision | ✅ | ✅1 | ✅1 | ✅ | ❌ | ❌ | ❌ | +| `has_overlay` | Matches every item that has or does not have an overlay | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | 1 Filters using the special `episodes` [filter](#special-filters) with the [default percent](details/definition). @@ -184,21 +185,22 @@ Number filters can **NOT** take multiple values. ### Attribute -| Number Filters | Description | Movies | Shows | Seasons | Episodes | Artists | Albums | Track | -|:------------------------------------|:---------------------------------------------------------------------|:-------:|:-------------------:|:-------------------:|:--------:|:-------------------:|:-------------------:|:--------:| -| `year`3 | Uses the year attribute to match
minimum: `1` | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | -| `tmdb_year`23 | Uses the year on TMDb to match
minimum: `1` | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | -| `critic_rating` | Uses the critic rating attribute to match
`0.0` - `10.0` | ✅ | ✅ | ❌ | ✅ | ❌ | ✅ | ❌ | -| `audience_rating` | Uses the audience rating attribute to match
`0.0` - `10.0` | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | -| `user_rating` | Uses the user rating attribute to match
`0.0` - `10.0` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| `tmdb_vote_count`2 | Uses the tmdb vote count to match
minimum: `1` | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | -| `plays` | Uses the plays attribute to match
minimum: `1` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| `duration` | Uses the duration attribute to match using minutes
minimum: `0.0` | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ | ✅ | -| `channels` | Uses the audio channels attribute to match
minimum: `0` | ✅ | ✅1 | ✅1 | ✅ | ❌ | ❌ | ❌ | -| `height` | Uses the height attribute to match
minimum: `0` | ✅ | ✅1 | ✅1 | ✅ | ❌ | ❌ | ❌ | -| `width` | Uses the width attribute to match
minimum: `0` | ✅ | ✅1 | ✅1 | ✅ | ❌ | ❌ | ❌ | -| `aspect` | Uses the aspect attribute to match
minimum: `0.0` | ✅ | ✅1 | ✅1 | ✅ | ❌ | ❌ | ❌ | -| `versions` | Uses the number of versions found to match
minimum: `0` | ✅ | ✅1 | ✅1 | ✅ | ✅1 | ✅1 | ✅ | +| Number Filters | Description | Movies | Shows | Seasons | Episodes | Artists | Albums | Track | +|:------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-------:|:-------------------:|:-------------------:|:--------:|:-------------------:|:-------------------:|:--------:| +| `year`3 | Uses the year attribute to match
minimum: `1` | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | +| `tmdb_year`23 | Uses the year on TMDb to match
minimum: `1` | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | +| `critic_rating` | Uses the critic rating attribute to match
`0.0` - `10.0` | ✅ | ✅ | ❌ | ✅ | ❌ | ✅ | ❌ | +| `audience_rating` | Uses the audience rating attribute to match
`0.0` - `10.0` | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | +| `user_rating` | Uses the user rating attribute to match
`0.0` - `10.0` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| `tmdb_vote_count`2 | Uses the tmdb vote count to match
minimum: `1` | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | +| `plays` | Uses the plays attribute to match
minimum: `1` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| `duration` | Uses the duration attribute to match using minutes
minimum: `0.0` | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ | ✅ | +| `channels` | Uses the audio channels attribute to match
minimum: `0` | ✅ | ✅1 | ✅1 | ✅ | ❌ | ❌ | ❌ | +| `height` | Uses the height attribute to match
minimum: `0` | ✅ | ✅1 | ✅1 | ✅ | ❌ | ❌ | ❌ | +| `width` | Uses the width attribute to match
minimum: `0` | ✅ | ✅1 | ✅1 | ✅ | ❌ | ❌ | ❌ | +| `aspect` | Uses the aspect attribute to match
minimum: `0.0` | ✅ | ✅1 | ✅1 | ✅ | ❌ | ❌ | ❌ | +| `versions` | Uses the number of versions found to match
minimum: `0` | ✅ | ✅1 | ✅1 | ✅ | ✅1 | ✅1 | ✅ | +| `stinger_rating`4 | Uses the [media stinger](http://www.mediastinger.com/) rating to match. The media stinger rating is if the after/during credits scene is worth staying for.
minimum: `0` | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | 1 Filters using the special `episodes` [filter](#special-filters) with the [default percent](details/definition). @@ -206,6 +208,8 @@ Number filters can **NOT** take multiple values. 3 You can use `current_year` to have PMM use the current years value. This can be combined with a `-#` at the end to subtract that number of years. i.e. `current-2` +4 The actual numbers are pulled from the [PMM-Mediastingers](https://github.com/meisnate12/PMM-Mediastingers) Repo. + ## Special Filters Special Filters each have their own set of rules for how they're used. diff --git a/modules/builder.py b/modules/builder.py index 21998e66..b4052448 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -84,7 +84,7 @@ filters_by_type = { "show_artist": ["folder"], "show_season": ["episodes"], "artist_album": ["tracks"], - "movie": ["edition", "has_edition"], + "movie": ["edition", "has_edition", "stinger_rating", "has_stinger"], "show": ["seasons", "tmdb_status", "tmdb_type", "origin_country", "network", "first_episode_aired", "last_episode_aired", "last_episode_aired_or_never"], "artist": ["albums"], "album": ["record_label"] @@ -113,12 +113,12 @@ tag_filters = [ "origin_country", "writer", "resolution", "audio_language", "subtitle_language", "tmdb_keyword", "tmdb_genre", "imdb_keyword" ] tag_modifiers = ["", ".not", ".regex", ".count_gt", ".count_gte", ".count_lt", ".count_lte"] -boolean_filters = ["has_collection", "has_edition", "has_overlay", "has_dolby_vision"] +boolean_filters = ["has_collection", "has_edition", "has_overlay", "has_dolby_vision", "has_stinger"] date_filters = ["release", "added", "last_played", "first_episode_aired", "last_episode_aired", "last_episode_aired_or_never"] date_modifiers = ["", ".not", ".before", ".after", ".regex"] number_filters = [ "year", "tmdb_year", "critic_rating", "audience_rating", "user_rating", "tmdb_vote_count", "plays", "duration", - "channels", "height", "width", "aspect", "versions"] + "channels", "height", "width", "aspect", "versions", "stinger_rating"] number_modifiers = ["", ".not", ".gt", ".gte", ".lt", ".lte"] special_filters = [ "history", "episodes", "seasons", "albums", "tracks", "original_language", "original_language.not", diff --git a/modules/config.py b/modules/config.py index a05fc637..d82010ce 100644 --- a/modules/config.py +++ b/modules/config.py @@ -32,6 +32,7 @@ from retrying import retry logger = util.logger +mediastingers_url = "https://raw.githubusercontent.com/meisnate12/PMM-Mediastingers/master/stingers.yml" sync_modes = {"append": "Only Add Items to the Collection or Playlist", "sync": "Add & Remove Items from the Collection or Playlist"} imdb_label_options = { "none": "Add IMDb Parental Labels for None, Mild, Moderate, or Severe", @@ -121,6 +122,7 @@ class ConfigFile: logger.info(f"Using {self.config_path} as config") logger.clear_errors() + self._mediastingers = None self.default_dir = default_dir self.read_only = attrs["read_only"] if "read_only" in attrs else False self.version = attrs["version"] if "version" in attrs else None @@ -1086,3 +1088,9 @@ class ConfigFile: @retry(stop_max_attempt_number=6, wait_fixed=10000) def post(self, url, data=None, json=None, headers=None): return self.session.post(url, data=data, json=json, headers=headers) + + @property + def mediastingers(self): + if self._mediastingers is None: + self._mediastingers = YAML(input_data=self.get(mediastingers_url).content).data + return self._mediastingers diff --git a/modules/plex.py b/modules/plex.py index 00fa85fe..fc166ec4 100644 --- a/modules/plex.py +++ b/modules/plex.py @@ -1574,6 +1574,10 @@ class Plex(Library): filter_check = len(item.collections) > 0 elif filter_attr == "has_edition": filter_check = True if item.edition else False + elif filter_attr == "has_stinger": + filter_check = False + if item.ratingKey in self.movie_rating_key_map and self.movie_rating_key_map[item.ratingKey] in self.config.mediastingers: + filter_check = True elif filter_attr == "has_overlay": for label in self.item_labels(item): if label.tag.lower().endswith(" overlay") or label.tag.lower() == "overlay": @@ -1637,6 +1641,10 @@ class Plex(Library): attr = getattr(media, filter_actual) if attr and attr > test_number: test_number = attr + elif filter_attr == "stinger_rating": + test_number = None + if item.ratingKey in self.movie_rating_key_map and self.movie_rating_key_map[item.ratingKey] in self.config.mediastingers: + test_number = self.config.mediastingers[self.movie_rating_key_map[item.ratingKey]] elif filter_attr == "versions": test_number = len(item.media) elif filter_attr == "audio_language":