From 7a0fbc88ef361443ad5e5a2b89b5f39801ff8ef7 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Fri, 23 Dec 2022 03:14:51 -0500 Subject: [PATCH] [2] add collection order option custom.desc --- CHANGELOG | 26 ++--------------------- VERSION | 2 +- docs/metadata/details/metadata.md | 34 +++++++++++++++---------------- modules/builder.py | 20 ++++++++++-------- 4 files changed, 31 insertions(+), 51 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c57ca878..7fa3ba5a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,29 +1,7 @@ # Requirements Update (requirements will need to be reinstalled) -Updated plexapi requirement to 4.13.2 -Updated retrying requirement to 1.3.4 -Updated lxml requirement to 4.92 # New Features -Now supports Python 3.11 -Wiki CSS update thanks to @YozoraXCII -Added `languages` template variable to the languages default -Added `mdb_average` as an option for `mass_update_*_ratings` -Added `custom_keys` dynamic collection attribute -Better Error handling for move errors -Added Sonarr v4 support -Added `album_genre`, `album_mood`, `album_style`, and `track_mood` as dynamic collection types -Added `only_run_on_create` to only run collections when the collection doesn't exist already -Added `exclude_user` as an option for playlist definitions +Added new collection_order `custom.desc`. ([FR](https://features.metamanager.wiki/features/p/reverse-sort-collectionorder-custom)) # Bug Fixes -Fixed positioning issues with the resolution/editions default and the ratings default -Fixed Metadata Asset Failures -Fixed `smart_label` collection counts -Fixed `delete_collections` operation -Fixed using `include` with the defaults -Fixed #1174 Content mapper error -Fixed mal builder errors -Fixed #1224 -Fixed audio_codec and video_format defaults regex patterns -Fixed tvdb xpaths for their builders and operations -Fixed overlays to allow only suppression of overlays which exist inside the same file \ No newline at end of file +Fixed Italian Translation \ No newline at end of file diff --git a/VERSION b/VERSION index f483a0c1..cace1a5f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.18.1-develop1 +1.18.1-develop2 diff --git a/docs/metadata/details/metadata.md b/docs/metadata/details/metadata.md index 510c83fc..d42e2b68 100644 --- a/docs/metadata/details/metadata.md +++ b/docs/metadata/details/metadata.md @@ -4,23 +4,23 @@ All the following attributes update various details of the definition's Metadata **Only `tmdb_person` works with Playlists.** -| Attribute | Description & Values | -|:-----------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `tmdb_person` | **Description:** Changes summary and poster to a TMDb Person's biography and profile as well as allow the people specified to be used in [Plex Searches](../builders/plex.md#plex-search).
**Values:** TMDb Person ID (List or Comma-separated string) | -| `sort_title` | **Description:** Changes the sort title.
You can "promote" certain collections to the top of a library by creating a sort title starting with a `+` or "demote" certain collections to the bottom of a library by creating a sort title starting with a `~`.
**Values:** Text to change Sort Title | -| `content_rating` | **Description:** Changes the content rating.
**Values:** Text to change Content Rating | -| `label` | **Description:** Appends new labels.
**Values:** Comma-separated string of labels to append | -| `label.remove` | **Description:** Removes existing labels from the collection.
**Values:** Comma-separated string of labels to remove | -| `label.sync` | **Description:** Matches the labels of the collection to the labels provided (Leave blank to remove all labels)
**Values:** Comma-separated string of labels to sync | -| `collection_mode` | **Description:** Changes the Collection Mode
**Values:**
`default`Library default
`hide`Hide Collection
`hide_items`Hide Items in this Collection
`show_items`Show this Collection and its Items
| -| `collection_order` | **Description:** Changes the Collection Order
**Normal Collections Only**
When using `custom` you can only have a single builder in the collection.
**Values:**
`release`Order Collection by Release Dates
`alpha`Order Collection Alphabetically
`custom`Order Collection Via the Builder Order
[Any `plex_search` Sort Option](../builders/plex.md#sort-options)Order Collection by any `plex_search` Sort Option
| -| `collection_filtering` | **Description:** Changes the Collection Filtering
**Smart Collections Only**
**Values:**
`admin`Always the server admin user
`user`User currently viewing the content
| -| `builder_level` | **Description:** Make season, episode, album or track collections/overlays from `plex_all`, `plex_search`, `trakt_list`, or `imdb_list` Builders and Filters
**Values:**
`season`Collection contains seasons
`episode`Collection contains episodes
`album`Collection contains albums
`track`Collection contains tracks
| -| `visible_library` | **Description:** Changes collection visible on Library (Only works with Plex Pass)
**Values:**
`true`Visible
`false`Not Visible
[Any `schedule` Option](schedule)Visible When Scheduled
| -| `visible_home` | **Description:** Changes collection visible on Home (Only works with Plex Pass)
**Values:**
`true`Visible
`false`Not Visible
[Any `schedule` Option](schedule)Visible When Scheduled
| -| `visible_shared` | **Description:** Changes collection visible on Shared Users' Home (Only works with Plex Pass)
**Values:**
`true`Visible
`false`Not Visible
[Any `schedule` Option](schedule)Visible When Scheduled
| -| `url_theme` | **Description:** Changes the Collection Theme to the URL provided.
**Values:** URL to mp3 file | -| `file_theme` | **Description:** Changes the Collection Theme to the file location provided.
**Values:** Path to mp3 file | +| Attribute | Description & Values | +|:-----------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `tmdb_person` | **Description:** Changes summary and poster to a TMDb Person's biography and profile as well as allow the people specified to be used in [Plex Searches](../builders/plex.md#plex-search).
**Values:** TMDb Person ID (List or Comma-separated string) | +| `sort_title` | **Description:** Changes the sort title.
You can "promote" certain collections to the top of a library by creating a sort title starting with a `+` or "demote" certain collections to the bottom of a library by creating a sort title starting with a `~`.
**Values:** Text to change Sort Title | +| `content_rating` | **Description:** Changes the content rating.
**Values:** Text to change Content Rating | +| `label` | **Description:** Appends new labels.
**Values:** Comma-separated string of labels to append | +| `label.remove` | **Description:** Removes existing labels from the collection.
**Values:** Comma-separated string of labels to remove | +| `label.sync` | **Description:** Matches the labels of the collection to the labels provided (Leave blank to remove all labels)
**Values:** Comma-separated string of labels to sync | +| `collection_mode` | **Description:** Changes the Collection Mode
**Values:**
`default`Library default
`hide`Hide Collection
`hide_items`Hide Items in this Collection
`show_items`Show this Collection and its Items
| +| `collection_order` | **Description:** Changes the Collection Order
**Normal Collections Only**
When using `custom.asc`/`custom.desc` you can only have a single builder in the collection.
**Values:**
`release`Order Collection by Release Dates
`alpha`Order Collection Alphabetically
`custom.asc`/`custom.desc`Order Collection Via the Builder Order ascending or descending
[Any `plex_search` Sort Option](../builders/plex.md#sort-options)Order Collection by any `plex_search` Sort Option
| +| `collection_filtering` | **Description:** Changes the Collection Filtering
**Smart Collections Only**
**Values:**
`admin`Always the server admin user
`user`User currently viewing the content
| +| `builder_level` | **Description:** Make season, episode, album or track collections/overlays from `plex_all`, `plex_search`, `trakt_list`, or `imdb_list` Builders and Filters
**Values:**
`season`Collection contains seasons
`episode`Collection contains episodes
`album`Collection contains albums
`track`Collection contains tracks
| +| `visible_library` | **Description:** Changes collection visible on Library (Only works with Plex Pass)
**Values:**
`true`Visible
`false`Not Visible
[Any `schedule` Option](schedule)Visible When Scheduled
| +| `visible_home` | **Description:** Changes collection visible on Home (Only works with Plex Pass)
**Values:**
`true`Visible
`false`Not Visible
[Any `schedule` Option](schedule)Visible When Scheduled
| +| `visible_shared` | **Description:** Changes collection visible on Shared Users' Home (Only works with Plex Pass)
**Values:**
`true`Visible
`false`Not Visible
[Any `schedule` Option](schedule)Visible When Scheduled
| +| `url_theme` | **Description:** Changes the Collection Theme to the URL provided.
**Values:** URL to mp3 file | +| `file_theme` | **Description:** Changes the Collection Theme to the file location provided.
**Values:** Path to mp3 file | * Here's an example of how the collections can look on the Home Page. diff --git a/modules/builder.py b/modules/builder.py index f1480acc..d28f1f6c 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -662,17 +662,17 @@ class CollectionBuilder: test_sort = self.library.default_collection_order logger.warning("") logger.warning(f"{self.Type} Warning: collection_order not found using library default_collection_order: {test_sort}") - self.custom_sort = self.playlist + self.custom_sort = "custom" if self.playlist else None if test_sort: if self.smart: raise Failed(f"{self.Type} Error: collection_order does not work with Smart Collections") logger.debug("") logger.debug("Validating Method: collection_order") logger.debug(f"Value: {test_sort}") - if test_sort in plex.collection_order_options: - self.details["collection_order"] = test_sort - if test_sort == "custom" and self.build_collection: - self.custom_sort = True + if test_sort in plex.collection_order_options + ["custom.asc", "custom.desc"]: + self.details["collection_order"] = test_sort.split(".")[0] + if test_sort.startswith("custom") and self.build_collection: + self.custom_sort = test_sort else: sort_type = self.builder_level if sort_type == "item": @@ -690,11 +690,11 @@ class CollectionBuilder: if ts not in sorts: raise Failed(f"{self.Type} Error: collection_order: {ts} is invalid. Options: {', '.join(sorts)}") self.custom_sort.append(ts) - if isinstance(self.custom_sort, list) and not self.custom_sort: + if not self.custom_sort: raise Failed(f"{self.Type} Error: {test_sort} collection_order invalid\n\trelease (Order Collection by release dates)\n\talpha (Order Collection Alphabetically)\n\tcustom (Custom Order Collection)\n\tOther sorting options can be found at https://github.com/meisnate12/Plex-Meta-Manager/wiki/Smart-Builders#sort-options") if self.smart: - self.custom_sort = False + self.custom_sort = None for method_key, method_data in self.data.items(): if method_key.lower() in ignored_details: @@ -810,7 +810,7 @@ class CollectionBuilder: if self.blank_collection and len(self.builders) > 0: raise Failed(f"{self.Type} Error: No builders allowed with blank_collection") - if self.custom_sort is True and (len(self.builders) > 1 or self.builders[0][0] not in custom_sort_builders): + if not isinstance(self.custom_sort, list) and self.custom_sort and (len(self.builders) > 1 or self.builders[0][0] not in custom_sort_builders): raise Failed(f"{self.Type} Error: " + ('Playlists' if self.playlist else 'collection_order: custom') + (f" can only be used with a single builder per {self.type}" if len(self.builders) > 1 else f" cannot be used with {self.builders[0][0]}")) @@ -2762,8 +2762,10 @@ class CollectionBuilder: logger.info("") logger.separator(f"Sorting {self.name} {self.Type}", space=False, border=False) logger.info("") - if self.custom_sort is True: + if not isinstance(self.custom_sort, list): items = self.found_items + if self.custom_sort == "custom.desc": + items = items[::-1] else: plex_search = {"sort_by": self.custom_sort} if self.builder_level in ["season", "episode"]: