[120] add has_stinger and stinger_rating filters

This commit is contained in:
meisnate12 2023-03-04 22:22:07 -05:00
parent b6c1548a06
commit d87e76e7c4
5 changed files with 45 additions and 25 deletions

View file

@ -1 +1 @@
1.18.3-develop119
1.18.3-develop120

View file

@ -128,9 +128,10 @@ 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_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 | &#9989; | &#9989;<sup>1</sup> | &#9989;<sup>1</sup> | &#9989; | &#10060; | &#10060; | &#10060; |
| `has_overlay` | Matches every item that has or does not have an overlay | &#9989; | &#9989; | &#9989; | &#9989; | &#9989; | &#9989; | &#10060; |
@ -185,7 +186,7 @@ Number filters can **NOT** take multiple values.
### Attribute
| Number Filters | Description | Movies | Shows | Seasons | Episodes | Artists | Albums | Track |
|:------------------------------------|:---------------------------------------------------------------------|:-------:|:-------------------:|:-------------------:|:--------:|:-------------------:|:-------------------:|:--------:|
|:------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-------:|:-------------------:|:-------------------:|:--------:|:-------------------:|:-------------------:|:--------:|
| `year`<sup>3</sup> | Uses the year attribute to match<br>minimum: `1` | &#9989; | &#9989; | &#9989; | &#9989; | &#10060; | &#9989; | &#9989; |
| `tmdb_year`<sup>2</sup><sup>3</sup> | Uses the year on TMDb to match<br>minimum: `1` | &#9989; | &#9989; | &#10060; | &#10060; | &#10060; | &#10060; | &#10060; |
| `critic_rating` | Uses the critic rating attribute to match<br>`0.0` - `10.0` | &#9989; | &#9989; | &#10060; | &#9989; | &#10060; | &#9989; | &#10060; |
@ -199,6 +200,7 @@ Number filters can **NOT** take multiple values.
| `width` | Uses the width attribute to match<br>minimum: `0` | &#9989; | &#9989;<sup>1</sup> | &#9989;<sup>1</sup> | &#9989; | &#10060; | &#10060; | &#10060; |
| `aspect` | Uses the aspect attribute to match<br>minimum: `0.0` | &#9989; | &#9989;<sup>1</sup> | &#9989;<sup>1</sup> | &#9989; | &#10060; | &#10060; | &#10060; |
| `versions` | Uses the number of versions found to match<br>minimum: `0` | &#9989; | &#9989;<sup>1</sup> | &#9989;<sup>1</sup> | &#9989; | &#9989;<sup>1</sup> | &#9989;<sup>1</sup> | &#9989; |
| `stinger_rating`<sup>4</sup> | 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.<br>minimum: `0` | &#9989; | &#10060; | &#10060; | &#10060; | &#10060; | &#10060; | &#10060; |
<sup>1</sup> 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.
<sup>3</sup> 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`
<sup>4</sup> 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.

View file

@ -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",

View file

@ -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

View file

@ -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":