mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2024-11-22 04:23:08 +00:00
[28] add anilist score
This commit is contained in:
parent
8f964de9f2
commit
67bec92f9c
7 changed files with 41 additions and 32 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
1.19.1-develop27
|
||||
1.19.1-develop28
|
||||
|
|
|
@ -107,11 +107,17 @@ Both `username` and `list_name` are required.
|
|||
|
||||
The `sync_mode: sync` and `collection_order: custom` Details are recommended since the lists are continuously updated and in a specific order.
|
||||
|
||||
| Attribute | Description |
|
||||
|:------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `username` | **Description:** A user's AniList Username |
|
||||
| `list_name` | **Description:** A user's AniList List Name |
|
||||
| `sort_by` | **Description:** Sort Order to return<br>**Default:** `score`<br>**Values:**<table class="clearTable"><tr><td>`score`</td><td>Sort by User Score</td></tr><tr><td>`popularity`</td><td>Sort by Popularity</td></tr><tr><td>`status`</td><td>Sort by Status</td></tr><tr><td>`progress`</td><td>Sort by Progress</td></tr><tr><td>`last_updated`</td><td>Sort by Last Updated</td></tr><tr><td>`last_added`</td><td>Sort by Last Added</td></tr><tr><td>`start_date`</td><td>Sort by Start Date</td></tr><tr><td>`completed_date`</td><td>Sort by Completed Date</td></tr></table> |
|
||||
| Attribute | Description |
|
||||
|:------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `username` | **Description:** A user's AniList Username |
|
||||
| `list_name` | **Description:** A user's AniList List Name |
|
||||
| `score.gt`<sup>1</sup> | **Description:** Only return items that have a score greater then the given number.<br>**Values:** `0.0`-`10.0` |
|
||||
| `score.gte`<sup>1</sup> | **Description:** Only return items that have a score greater then or equal to the given number.<br>**Values:** `0.0`-`10.0` |
|
||||
| `score.lt`<sup>1</sup> | **Description:** Only return items that have a score less then the given number.<br>**Values:** `0.0`-`10.0` |
|
||||
| `score.lte`<sup>1</sup> | **Description:** Only return items that have a score less then or equal to the given number.<br>**Values:** `0.0`-`10.0` |
|
||||
| `sort_by` | **Description:** Sort Order to return<br>**Default:** `score`<br>**Values:**<table class="clearTable"><tr><td>`score`</td><td>Sort by User Score</td></tr><tr><td>`popularity`</td><td>Sort by Popularity</td></tr><tr><td>`status`</td><td>Sort by Status</td></tr><tr><td>`progress`</td><td>Sort by Progress</td></tr><tr><td>`last_updated`</td><td>Sort by Last Updated</td></tr><tr><td>`last_added`</td><td>Sort by Last Added</td></tr><tr><td>`start_date`</td><td>Sort by Start Date</td></tr><tr><td>`completed_date`</td><td>Sort by Completed Date</td></tr></table> |
|
||||
|
||||
<sup>1</sup> You can use multiple score filters but the number will have to match every filter. All unrated items are considered to have a 0 rating.
|
||||
|
||||
```yaml
|
||||
collections:
|
||||
|
|
|
@ -4,13 +4,13 @@ This builder finds its items by using the features of Plex.
|
|||
|
||||
No configuration is required for these builders.
|
||||
|
||||
| Attribute | Description | Works with Movies | Works with Shows | Works with Playlists and Custom Sort |
|
||||
|:----------------------------------------------|:-----------------------------------------------------------------------------|:-----------------:|:----------------:|:------------------------------------:|
|
||||
| [`plex_all`](#plex-all) | Gets every movie/show in your library. Useful with [Filters](filters.md) | ✅ | ✅ | ❌ |
|
||||
| [`plex_watchlist`](#plex-watchlist) | Gets every movie/show in your Watchlist. | ✅ | ✅ | ✅ |
|
||||
| [`plex_pilots`](#plex-pilots) | Gets the first episode of every show in your library | ❌ | ✅ | ✅ |
|
||||
| [`plex_collectionless`](#plex-collectionless.md) | Gets every movie/show that is not in a collection | ✅ | ✅ | ❌ |
|
||||
| [`plex_search`](#plex-search) | Gets every movie/show based on the search parameters provided | ✅ | ✅ | ✅ |
|
||||
| Attribute | Description | Works with Movies | Works with Shows | Works with Playlists and Custom Sort |
|
||||
|:----------------------------------------------|:----------------------------------------------------------------------------|:-----------------:|:----------------:|:------------------------------------:|
|
||||
| [`plex_all`](#plex-all) | Gets every movie/show in your library. Useful with [Filters](filters.md) | ✅ | ✅ | ❌ |
|
||||
| [`plex_watchlist`](#plex-watchlist) | Gets every movie/show in your Watchlist. | ✅ | ✅ | ✅ |
|
||||
| [`plex_pilots`](#plex-pilots) | Gets the first episode of every show in your library | ❌ | ✅ | ✅ |
|
||||
| [`plex_collectionless`](#plex-collectionless) | Gets every movie/show that is not in a collection | ✅ | ✅ | ❌ |
|
||||
| [`plex_search`](#plex-search) | Gets every movie/show based on the search parameters provided | ✅ | ✅ | ✅ |
|
||||
|
||||
## Plex All
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ function checkURLForBranch() {
|
|||
|
||||
if (currentURL.indexOf("nightly") !== -1) {
|
||||
// If "config" is found in the URL, change the CSS of .md-header to red
|
||||
document.querySelector(".md-header").style.backgroundColor = "#ef5552";
|
||||
document.querySelector(".md-tabs").style.backgroundColor = "#ef5552";
|
||||
document.querySelector(".md-header").style.backgroundColor = "#262dbd";
|
||||
document.querySelector(".md-tabs").style.backgroundColor = "#262dbd";
|
||||
|
||||
// Change the text of <span class="md-ellipsis">
|
||||
const ellipsisSpan = document.querySelector(".md-ellipsis");
|
||||
|
|
|
@ -221,13 +221,14 @@ class AniList:
|
|||
|
||||
return anilist_ids, ignore_ids, name
|
||||
|
||||
def _userlist(self, username, list_name, sort_by):
|
||||
def _userlist(self, username, list_name, sort_by, score):
|
||||
query = """
|
||||
query ($user: String, $sort: [MediaListSort]) {
|
||||
MediaListCollection (userName: $user, sort: $sort, type: ANIME) {
|
||||
lists {
|
||||
name
|
||||
entries {
|
||||
score(format: POINT_10)
|
||||
media{id}
|
||||
}
|
||||
}
|
||||
|
@ -237,7 +238,7 @@ class AniList:
|
|||
variables = {"user": username, "sort": userlist_sort_options[sort_by]}
|
||||
for alist in self._request(query, variables)["data"]["MediaListCollection"]["lists"]:
|
||||
if alist["name"] == list_name:
|
||||
return [m["media"]["id"] for m in alist["entries"]]
|
||||
return [m["media"]["id"] for m in alist["entries"] if not score or not any([util.is_number_filter(value, mod, m["score"]) for mod, value in score.items()])]
|
||||
return []
|
||||
|
||||
def validate_userlist(self, data):
|
||||
|
@ -293,7 +294,7 @@ class AniList:
|
|||
anilist_ids, _, name = self._relations(data)
|
||||
logger.info(f"Processing AniList Relations: ({data}) {name} ({len(anilist_ids)} Anime)")
|
||||
elif method == "anilist_userlist":
|
||||
anilist_ids = self._userlist(data["username"], data["list_name"], data["sort_by"])
|
||||
anilist_ids = self._userlist(data["username"], data["list_name"], data["sort_by"], data["score"])
|
||||
logger.info(f"Processing AniList Userlist: {data['list_name']} from {data['username']} sorted by {pretty_user[data['sort_by']]}")
|
||||
else:
|
||||
if method == "anilist_popular":
|
||||
|
|
|
@ -1393,11 +1393,22 @@ class CollectionBuilder:
|
|||
elif method_name == "anilist_userlist":
|
||||
for dict_data in util.parse(self.Type, method_name, method_data, datatype="listdict"):
|
||||
dict_methods = {dm.lower(): dm for dm in dict_data}
|
||||
self.builders.append((method_name, self.config.AniList.validate_userlist({
|
||||
new_dictionary = {
|
||||
"username": util.parse(self.Type, "username", dict_data, methods=dict_methods, parent=method_name),
|
||||
"list_name": util.parse(self.Type, "list_name", dict_data, methods=dict_methods, parent=method_name),
|
||||
"sort_by": util.parse(self.Type, "sort_by", dict_data, methods=dict_methods, parent=method_name, default="score", options=anilist.userlist_sort_options),
|
||||
})))
|
||||
}
|
||||
score_dict = {}
|
||||
for search_method, search_data in dict_data.items():
|
||||
search_attr, modifier = os.path.splitext(str(search_method).lower())
|
||||
if search_attr == "score" and modifier in ["gt", "gte", "lt", "lte"]:
|
||||
score = util.parse(self.Type, search_method, dict_data, datatype="int", default=-1, minimum=0, maximum=10, parent=method_name)
|
||||
if score > -1:
|
||||
score_dict[modifier] = score
|
||||
elif search_attr not in ["username", "list_name", "sort_by"]:
|
||||
raise Failed(f"{self.Type} Error: {method_name} {search_method} attribute not supported")
|
||||
new_dictionary["score"] = score_dict
|
||||
self.builders.append((method_name, self.config.AniList.validate_userlist(new_dictionary)))
|
||||
elif method_name == "anilist_search":
|
||||
if self.current_time.month in [12, 1, 2]: current_season = "winter"
|
||||
elif self.current_time.month in [3, 4, 5]: current_season = "spring"
|
||||
|
@ -2525,7 +2536,7 @@ class CollectionBuilder:
|
|||
elif self.playlist and items_added:
|
||||
self.obj.addItems(items_added)
|
||||
elif items_added:
|
||||
self.library.alter_collection(items_added, name, smart_label_collection=self.smart_label_collection)
|
||||
self.library.alter_collection(items_added, name, smart_label_collection=self.smart_label_collection)
|
||||
if self.do_report and items_added:
|
||||
self.library.add_additions(self.name, [(i.title, self.library.get_id_from_maps(i.ratingKey)) for i in items_added], self.library.is_movie)
|
||||
logger.exorcise()
|
||||
|
@ -2555,7 +2566,7 @@ class CollectionBuilder:
|
|||
self.library._reload(self.obj)
|
||||
self.obj.removeItems(items_removed)
|
||||
elif items_removed:
|
||||
self.library.alter_collection(items_removed, self.name, smart_label_collection=self.smart_label_collection, add=False)
|
||||
self.library.alter_collection(items_removed, self.name, smart_label_collection=self.smart_label_collection, add=False)
|
||||
if self.do_report and items_removed:
|
||||
self.library.add_removed(self.name, [(i.title, self.library.get_id_from_maps(i.ratingKey)) for i in items_removed], self.library.is_movie)
|
||||
logger.info("")
|
||||
|
|
|
@ -882,16 +882,7 @@ class Plex(Library):
|
|||
|
||||
def alter_collection(self, items, collection, smart_label_collection=False, add=True):
|
||||
self.Plex.batchMultiEdits(items)
|
||||
if smart_label_collection:
|
||||
if add:
|
||||
self.Plex.addLabel(collection)
|
||||
else:
|
||||
self.Plex.removeLabel(collection)
|
||||
else:
|
||||
if add:
|
||||
self.Plex.addCollection(collection)
|
||||
else:
|
||||
self.Plex.removeCollection(collection)
|
||||
self.query_data(getattr(self.Plex, f"{'add' if add else 'remove'}{'Label' if smart_label_collection else 'Collection'}"), collection)
|
||||
self.Plex.saveMultiEdits()
|
||||
|
||||
def move_item(self, collection, item, after=None):
|
||||
|
|
Loading…
Reference in a new issue