[75] add playlist user exclude

pull/1245/head
meisnate12 2 years ago
parent 5114b4476f
commit cdee4dfc65

@ -1 +1 @@
1.18.0-develop74 1.18.0-develop75

@ -62,6 +62,7 @@ settings:
ignore_imdb_ids: ignore_imdb_ids:
item_refresh_delay: 0 item_refresh_delay: 0
playlist_sync_to_user: all playlist_sync_to_user: all
playlist_exclude_user:
playlist_report: false playlist_report: false
verify_ssl: true verify_ssl: true
custom_repo: custom_repo:

@ -45,6 +45,7 @@ templates:
visible_library_<<key>>: <<visible_library>> visible_library_<<key>>: <<visible_library>>
visible_home_<<key>>: <<visible_home>> visible_home_<<key>>: <<visible_home>>
visible_shared_<<key>>: <<visible_shared>> visible_shared_<<key>>: <<visible_shared>>
minimum_items_<<key>>: <<minimum_items>>
optional: optional:
- use_<<key>> - use_<<key>>
- allowed_libraries - allowed_libraries
@ -58,6 +59,7 @@ templates:
- image - image
- ignore_ids - ignore_ids
- ignore_imdb_ids - ignore_imdb_ids
- minimum_items
allowed_library_types: allowed_library_types:
- <<use_<<key>>>> - <<use_<<key>>>>
- <<allowed_libraries>> - <<allowed_libraries>>
@ -73,6 +75,7 @@ templates:
item_sonarr_tag: <<item_sonarr_tag_<<key>>>> item_sonarr_tag: <<item_sonarr_tag_<<key>>>>
sort_title: "!<<collection_section>><<pre>><<order_<<key>>>><<sort>>" sort_title: "!<<collection_section>><<pre>><<order_<<key>>>><<sort>>"
url_poster: <<url_poster_<<key>>>> url_poster: <<url_poster_<<key>>>>
minimum_items: <<minimum_items_<<key>>>>
trakt: trakt:
optional: optional:

@ -97,6 +97,7 @@ settings:
ignore_imdb_ids: ignore_imdb_ids:
item_refresh_delay: 0 item_refresh_delay: 0
playlist_sync_to_user: all playlist_sync_to_user: all
playlist_exclude_user:
playlist_report: false playlist_report: false
verify_ssl: true verify_ssl: true
custom_repo: custom_repo:

@ -52,6 +52,7 @@ The available setting attributes which can be set at each level are outlined bel
| [`ignore_imdb_ids`](#ignore-imdb-ids) | &#9989; | &#9989; | &#9989; | | [`ignore_imdb_ids`](#ignore-imdb-ids) | &#9989; | &#9989; | &#9989; |
| [`item_refresh_delay`](#item-refresh-delay) | &#9989; | &#9989; | &#9989; | | [`item_refresh_delay`](#item-refresh-delay) | &#9989; | &#9989; | &#9989; |
| [`playlist_sync_to_users`](#playlist-sync-to-users) | &#9989; | &#10060; | &#9989; | | [`playlist_sync_to_users`](#playlist-sync-to-users) | &#9989; | &#10060; | &#9989; |
| [`playlist_exclude_users`](#playlist-exclude-users) | &#9989; | &#10060; | &#9989; |
| [`playlist_report`](#playlist-report) | &#9989; | &#10060; | &#10060; | | [`playlist_report`](#playlist-report) | &#9989; | &#10060; | &#10060; |
| [`custom_repo`](#custom-repo) | &#9989; | &#10060; | &#10060; | | [`custom_repo`](#custom-repo) | &#9989; | &#10060; | &#10060; |
| [`verify_ssl`](#verify-ssl) | &#9989; | &#10060; | &#10060; | | [`verify_ssl`](#verify-ssl) | &#9989; | &#10060; | &#10060; |
@ -540,6 +541,19 @@ Set the default playlist `sync_to_users`. To Sync a playlist to only yourself le
</tr> </tr>
</table> </table>
## Playlist Exclude Users
Set the default playlist `exclude_users`.
<table class="dualTable colwidths-auto align-default table">
<tr>
<th>Default Value</th>
<td><code> </code></td>
</tr>
<tr>
<th>Allowed Values</th>
<td>list of users or comma-separated string of users</td>
</tr>
</table>
# Playlist Report # Playlist Report
Set `playlist_report` to true to print out a playlist report at the end of the log. Set `playlist_report` to true to print out a playlist report at the end of the log.

@ -17,6 +17,8 @@ Below are the available variables which can be used to customize the file.
| `collection_mode` | **Description:** Controls the collection mode of all collections in a Defaults file.<br>**Values:**<table class="clearTable"><tr><td>`default`</td><td>Library default</td></tr><tr><td>`hide`</td><td>Hide Collection</td></tr><tr><td>`hide_items`</td><td>Hide Items in this Collection</td></tr><tr><td>`show_items`</td><td>Show this Collection and its Items</td></tr></table> | | `collection_mode` | **Description:** Controls the collection mode of all collections in a Defaults file.<br>**Values:**<table class="clearTable"><tr><td>`default`</td><td>Library default</td></tr><tr><td>`hide`</td><td>Hide Collection</td></tr><tr><td>`hide_items`</td><td>Hide Items in this Collection</td></tr><tr><td>`show_items`</td><td>Show this Collection and its Items</td></tr></table> |
| `ignore_ids` | **Description:** Set a list or comma-separated string of TMDb/TVDb IDs to ignore in all collections.<br>**Values:** List or comma-separated string of TMDb/TVDb IDs | | `ignore_ids` | **Description:** Set a list or comma-separated string of TMDb/TVDb IDs to ignore in all collections.<br>**Values:** List or comma-separated string of TMDb/TVDb IDs |
| `ignore_imdb_ids` | **Description:** Set a list or comma-separated string of IMDb IDs to ignore in all collections.<br>**Values:** List or comma-separated string of IMDb IDs | | `ignore_imdb_ids` | **Description:** Set a list or comma-separated string of IMDb IDs to ignore in all collections.<br>**Values:** List or comma-separated string of IMDb IDs |
| `minimum_items` | **Description:** Set the number of minimum items for a collection to be created for all collections.<br>**Values:** Any Number greater then 0 |
| `minimum_items_<<key>>`<sup>1</sup> | **Description:** Set the number of minimum items for a collection to be created for the specified key's collection.<br>**Values:** Any Number greater then 0 |
| `url_poster_<<key>>`<sup>1</sup> | **Description:** Changes the poster url of the specified key's collection.<br>**Values:** URL directly to the Image | | `url_poster_<<key>>`<sup>1</sup> | **Description:** Changes the poster url of the specified key's collection.<br>**Values:** URL directly to the Image |
| `visible_library` | **Description:** Controls visible on Library for all collections in a Defaults file. (Only works with Plex Pass)<br>**Values:**<table class="clearTable"><tr><td>`true`</td><td>Visible</td></tr><tr><td>`false`</td><td>Not Visible</td></tr><tr><td>[Any `schedule` Option](../metadata/details/schedule)</td><td>Visible When Scheduled</td></tr></table> | | `visible_library` | **Description:** Controls visible on Library for all collections in a Defaults file. (Only works with Plex Pass)<br>**Values:**<table class="clearTable"><tr><td>`true`</td><td>Visible</td></tr><tr><td>`false`</td><td>Not Visible</td></tr><tr><td>[Any `schedule` Option](../metadata/details/schedule)</td><td>Visible When Scheduled</td></tr></table> |
| `visible_library_<<key>>`<sup>1</sup> | **Description:** Controls visible on Library of the specified key's collection. (Only works with Plex Pass)<br>**Default:** `visible_library`<br>**Values:**<table class="clearTable"><tr><td>`true`</td><td>Visible</td></tr><tr><td>`false`</td><td>Not Visible</td></tr><tr><td>[Any `schedule` Option](../metadata/details/schedule)</td><td>Visible When Scheduled</td></tr></table> | | `visible_library_<<key>>`<sup>1</sup> | **Description:** Controls visible on Library of the specified key's collection. (Only works with Plex Pass)<br>**Default:** `visible_library`<br>**Values:**<table class="clearTable"><tr><td>`true`</td><td>Visible</td></tr><tr><td>`false`</td><td>Not Visible</td></tr><tr><td>[Any `schedule` Option](../metadata/details/schedule)</td><td>Visible When Scheduled</td></tr></table> |

@ -296,7 +296,7 @@ docker run -it -v "X:\Media\Plex Meta Manager\config:/config:rw" meisnate12/plex
### Collections Only ### Collections Only
Only run collection metadata/YAML files, skip library operations, overlays, and collections/metadata. Only run collection metadata/YAML files, skip library operations, overlays, and playlists.
<table class="dualTable colwidths-auto align-default table"> <table class="dualTable colwidths-auto align-default table">
<tr> <tr>

@ -44,11 +44,12 @@ There are multiple types of attributes that can be utilized within a playlist:
### Special Playlist Attributes ### Special Playlist Attributes
| Attribute | Description | Required | | Attribute | Description | Required |
|:------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------:| |:------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------:|
| `libraries` | Determine which libraries the playlist will be built from.<br>**Options:** Comma-separated string or list of library mapping names defined in the `libraries` attribute in the base of your [Configuration File](../config/configuration). | &#9989; | | `libraries` | Determine which libraries the playlist will be built from.<br>**Options:** Comma-separated string or list of library mapping names defined in the `libraries` attribute in the base of your [Configuration File](../config/configuration). | &#9989; |
| `sync_to_users` | Determine which Users have the playlist synced.<br>This will override the global [`playlist_sync_to_users` Setting](../config/settings.md#playlist-sync-to-users).<br>**Options:** Comma-separated string or list of users, `all` for every user who has server access, or leave blank for just the server owner. | &#10060; | | `sync_to_users` | Determine which Users have the playlist synced.<br>This will override the global [`playlist_sync_to_users` Setting](../config/settings.md#playlist-sync-to-users).<br>**Options:** Comma-separated string or list of users, `all` for every user who has server access, or leave blank for just the server owner. | &#10060; |
| `delete_playlist` | Will delete this playlist for the users defined by sync_to_users.<br>**Options:** `true` or `false` | &#10060; | | `exclude_users` | Determine which Users will be excluded from having the playlist synced.<br>This will override the global [`playlist_excude_users` Setting](../config/settings.md#playlist-exclude-users).<br>**Options:** Comma-separated string or list of users, `all` for every user who has server access, or leave blank for just the server owner. | &#10060; |
| `delete_playlist` | Will delete this playlist for the users defined by sync_to_users.<br>**Options:** `true` or `false` | &#10060; |
* Any defined playlist will be always be visible by The Plex Media Server owner, so it doesn't need to be defined within `sync_to_users`. * Any defined playlist will be always be visible by The Plex Media Server owner, so it doesn't need to be defined within `sync_to_users`.

@ -335,6 +335,7 @@ class CollectionBuilder:
self.overlay = Overlay(config, library, metadata, str(self.mapping_name), overlay_data, suppress, self.builder_level) self.overlay = Overlay(config, library, metadata, str(self.mapping_name), overlay_data, suppress, self.builder_level)
self.sync_to_users = None self.sync_to_users = None
self.exclude_users = None
self.valid_users = [] self.valid_users = []
if self.playlist: if self.playlist:
if "sync_to_users" in methods or "sync_to_user" in methods: if "sync_to_users" in methods or "sync_to_user" in methods:
@ -344,18 +345,35 @@ class CollectionBuilder:
logger.debug(f"Value: {self.data[methods[s_attr]]}") logger.debug(f"Value: {self.data[methods[s_attr]]}")
self.sync_to_users = self.data[methods[s_attr]] self.sync_to_users = self.data[methods[s_attr]]
else: else:
logger.warning(f"Playlist Error: sync_to_users attribute not found defaulting to playlist_sync_to_users: {self.sync_to_users}")
self.sync_to_users = config.general["playlist_sync_to_users"] self.sync_to_users = config.general["playlist_sync_to_users"]
logger.warning(f"Playlist Warning: sync_to_users attribute not found defaulting to playlist_sync_to_users: {self.sync_to_users}")
if "exclude_users" in methods or "exclude_user" in methods:
s_attr = f"exclude_user{'s' if 'exclude_users' in methods else ''}"
logger.debug("")
logger.debug(f"Validating Method: {s_attr}")
logger.debug(f"Value: {self.data[methods[s_attr]]}")
self.exclude_users = self.data[methods[s_attr]]
elif config.general["playlist_exclude_users"]:
self.exclude_users = config.general["playlist_exclude_users"]
logger.warning(f"Playlist Warning: exclude_users attribute not found defaulting to playlist_exclude_users: {self.exclude_users}")
plex_users = self.library.users plex_users = self.library.users
self.exclude_users = util.get_list(self.exclude_users)
for user in self.exclude_users:
if user not in plex_users:
raise Failed(f"Playlist Error: User: {user} not found in plex\nOptions: {plex_users}")
if self.sync_to_users: if self.sync_to_users:
if str(self.sync_to_users) == "all": if str(self.sync_to_users) == "all":
self.valid_users = plex_users self.valid_users = [p for p in plex_users if p not in self.exclude_users]
else: else:
for user in util.get_list(self.sync_to_users): for user in util.get_list(self.sync_to_users):
if user not in plex_users: if user not in plex_users:
raise Failed(f"Playlist Error: User: {user} not found in plex\nOptions: {plex_users}") raise Failed(f"Playlist Error: User: {user} not found in plex\nOptions: {plex_users}")
self.valid_users.append(user) if user not in self.exclude_users:
self.valid_users.append(user)
if "delete_playlist" in methods: if "delete_playlist" in methods:
logger.debug("") logger.debug("")

@ -371,6 +371,7 @@ class ConfigFile:
"ignore_ids": check_for_attribute(self.data, "ignore_ids", parent="settings", var_type="int_list", default_is_none=True), "ignore_ids": check_for_attribute(self.data, "ignore_ids", parent="settings", var_type="int_list", default_is_none=True),
"ignore_imdb_ids": check_for_attribute(self.data, "ignore_imdb_ids", parent="settings", var_type="list", default_is_none=True), "ignore_imdb_ids": check_for_attribute(self.data, "ignore_imdb_ids", parent="settings", var_type="list", default_is_none=True),
"playlist_sync_to_users": check_for_attribute(self.data, "playlist_sync_to_users", parent="settings", default="all", default_is_none=True), "playlist_sync_to_users": check_for_attribute(self.data, "playlist_sync_to_users", parent="settings", default="all", default_is_none=True),
"playlist_exclude_users": check_for_attribute(self.data, "playlist_exclude_users", parent="settings", default_is_none=True),
"playlist_report": check_for_attribute(self.data, "playlist_report", parent="settings", var_type="bool", default=True), "playlist_report": check_for_attribute(self.data, "playlist_report", parent="settings", var_type="bool", default=True),
"verify_ssl": check_for_attribute(self.data, "verify_ssl", parent="settings", var_type="bool", default=True), "verify_ssl": check_for_attribute(self.data, "verify_ssl", parent="settings", var_type="bool", default=True),
"custom_repo": check_for_attribute(self.data, "custom_repo", parent="settings", default_is_none=True), "custom_repo": check_for_attribute(self.data, "custom_repo", parent="settings", default_is_none=True),

@ -715,7 +715,10 @@ class Plex(Library):
return self._users return self._users
def delete_user_playlist(self, title, user): def delete_user_playlist(self, title, user):
self.delete(self.PlexServer.switchUser(user).playlist(title)) try:
self.delete(self.PlexServer.switchUser(user).playlist(title))
except NotFound as e:
raise Failed(e)
@property @property
def account(self): def account(self):

Loading…
Cancel
Save