mirror of
https://github.com/mza921/Plex-Auto-Collections
synced 2024-11-14 16:27:22 +00:00
Merge pull request #70 from mza921/trakt_trending
Add Trakt Trending List support
This commit is contained in:
commit
a6d4d62047
5 changed files with 58 additions and 18 deletions
24
README.md
24
README.md
|
@ -1,5 +1,5 @@
|
|||
# Plex Auto Collections
|
||||
##### Version 2.1.1
|
||||
##### Version 2.2.0
|
||||
Plex Auto Collections is a Python 3 script that works off a configuration file to create/update Plex collections. Collection management with this tool can be automated in a varying degree of customizability. Supports IMDB, TMDb, and Trakt lists as well as built in Plex filters such as actors, genres, year, studio and more.
|
||||
|
||||
![https://i.imgur.com/iHAYFIZ.png](https://i.imgur.com/iHAYFIZ.png)
|
||||
|
@ -20,6 +20,7 @@ Plex Auto Collections is a Python 3 script that works off a configuration file t
|
|||
- [TVDb Show (List Type)](#tvdb-show-list-type)
|
||||
- [IMDb List or Search (List Type)](#imdb-list-or-search-list-type)
|
||||
- [Trakt List (List Type)](#trakt-list-list-type)
|
||||
- [Trakt Trending List (List Type)](#trakt-trending-list-list-type)
|
||||
- [Tautulli List (List Type)](#tautulli-list-list-type)
|
||||
- [Subfilters (Collection Attribute)](#subfilters-collection-attribute)
|
||||
- [Sync Mode (Collection Attribute)](#sync-mode-collection-attribute)
|
||||
|
@ -146,7 +147,7 @@ Each collection is defined by the mapping name which becomes the name of the Ple
|
|||
|
||||
### List Type (Collection Attribute)
|
||||
|
||||
The only required attribute for each collection is the list type. There are eight different list types to choose from:
|
||||
The only required attribute for each collection is the list type. There are eleven different list types to choose from:
|
||||
- [Plex Collection](#plex-collection-list-type)
|
||||
- [TMDb Collection](#tmdb-collection-list-type)
|
||||
- [TMDb Actor](#tmdb-actor-list-type)
|
||||
|
@ -156,8 +157,12 @@ The only required attribute for each collection is the list type. There are eigh
|
|||
- [TVDb Show](#tvdb-show-list-type)
|
||||
- [IMDb List or Search](#imdb-list-or-search-list-type)
|
||||
- [Trakt List](#trakt-list-list-type)
|
||||
- [Trakt Trending List](#trakt-trending-list-list-type)
|
||||
- [Tautulli List](#tautulli-list-list-type)
|
||||
|
||||
Note that each list type supports multiple lists.
|
||||
Note that most list types supports multiple lists, with the following exceptions:
|
||||
- Trakt Trending List
|
||||
- Tautulli List
|
||||
|
||||
#### Plex Collection (List Type)
|
||||
|
||||
|
@ -379,6 +384,19 @@ collections:
|
|||
trakt_list: https://trakt.tv/users/jay-greene/lists/reddit-top-250-2019-edition
|
||||
```
|
||||
|
||||
#### Trakt Trending List (List Type)
|
||||
|
||||
###### Works with Movie and TV Show Libraries
|
||||
|
||||
This script can pull a number of items from the Trakt Trending List for [Movies](https://trakt.tv/movies/trending) or [Shows](https://trakt.tv/shows/trending). The `trakt_trending` attribute only supports a single integer value. The `sync_mode: sync` option is recommended since the list is continuously updated.
|
||||
|
||||
```yaml
|
||||
collections:
|
||||
Trending:
|
||||
trakt_trending: 30
|
||||
sync_mode: sync
|
||||
```
|
||||
|
||||
#### Tautulli List (List Type)
|
||||
|
||||
###### Works with Movie and TV Show Libraries
|
||||
|
|
|
@ -123,6 +123,8 @@ def update_from_config(config_path, plex, headless=False, no_meta=False, no_imag
|
|||
print("| {} missing movie{} from {} List: {}".format(len(missing), "s" if len(missing) > 1 else "", method_name, v))
|
||||
elif m == "tmdb_collection":
|
||||
print("| {} missing movie{} from {} Collection: {}".format(len(missing), "s" if len(missing) > 1 else "", method_name, v))
|
||||
elif m == "trakt_trending":
|
||||
print("| {} missing movie{} from {} List: Trending (top {})".format(len(missing), "s" if len(missing) > 1 else "", method_name, v))
|
||||
else:
|
||||
print("| {} ID: {} missing".format(method_name, v))
|
||||
if Radarr.valid:
|
||||
|
@ -136,6 +138,8 @@ def update_from_config(config_path, plex, headless=False, no_meta=False, no_imag
|
|||
method_name = "Trakt" if "trakt" in m else "TVDb" if "tvdb" in m else "TMDb"
|
||||
if m == "trakt_list" or m == "tmdb_list":
|
||||
print("| {} missing show{} from {} List: {}".format(len(missing), "s" if len(missing) > 1 else "", method_name, v))
|
||||
elif m == "trakt_trending":
|
||||
print("| {} missing show{} from {} List: Trending (top {})".format(len(missing), "s" if len(missing) > 1 else "", method_name, v))
|
||||
else:
|
||||
print("| {} ID: {} missing".format(method_name, v))
|
||||
|
||||
|
@ -616,7 +620,7 @@ print("| | _/| |/ -_)\ \ / / _ \| || || _|/ _ \ | (__ / _ \| || |/ -_)/ _|
|
|||
print("| |_| |_|\___|/_\_\ /_/ \_\\\\_,_| \__|\___/ \___|\___/|_||_|\___|\__| \__||_|\___/|_||_|/__/ |")
|
||||
print("| |")
|
||||
print("|===================================================================================================|")
|
||||
print("| Version 2.1.1")
|
||||
print("| Version 2.2.0")
|
||||
print("| Locating config...")
|
||||
config_path = None
|
||||
app_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
|
|
|
@ -118,7 +118,7 @@ def add_to_collection(config_path, plex, method, value, c, map, subfilters=None)
|
|||
shows = []
|
||||
items = []
|
||||
missing = []
|
||||
if (method == "trakt_list" or ("tmdb" in method and plex.library_type == "show")) and not TraktClient.valid:
|
||||
if ("trakt" in method or ("tmdb" in method and plex.library_type == "show")) and not TraktClient.valid:
|
||||
raise KeyError("| trakt connection required for {}",format(method))
|
||||
if ("imdb" in method or "tmdb" in method) and not TMDB.valid:
|
||||
raise KeyError("| tmdb connection required for {}",format(method))
|
||||
|
@ -141,6 +141,8 @@ def add_to_collection(config_path, plex, method, value, c, map, subfilters=None)
|
|||
movies, missing = imdb_tools.tmdb_get_movies(config_path, plex, value)
|
||||
elif method == "trakt_list" and TraktClient.valid:
|
||||
movies, missing = trakt_tools.trakt_get_movies(config_path, plex, value)
|
||||
elif method == "trakt_trending" and TraktClient.valid:
|
||||
movies, missing = trakt_tools.trakt_get_movies(config_path, plex, value, is_userlist=False)
|
||||
elif method == "tautulli" and Tautulli.valid:
|
||||
movies, missing = imdb_tools.get_tautulli(config_path, plex, value)
|
||||
elif plex.library_type == "show":
|
||||
|
@ -161,6 +163,8 @@ def add_to_collection(config_path, plex, method, value, c, map, subfilters=None)
|
|||
shows, missing = imdb_tools.tvdb_get_shows(config_path, plex, value)
|
||||
elif method == "trakt_list" and TraktClient.valid:
|
||||
shows, missing = trakt_tools.trakt_get_shows(config_path, plex, value)
|
||||
elif method == "trakt_trending" and TraktClient.valid:
|
||||
shows, missing = trakt_tools.trakt_get_shows(config_path, plex, value, is_userlist=False)
|
||||
elif method == "tautulli" and Tautulli.valid:
|
||||
shows, missing = imdb_tools.get_tautulli(config_path, plex, value)
|
||||
|
||||
|
|
|
@ -3,16 +3,21 @@ from urllib.parse import urlparse
|
|||
import plex_tools
|
||||
import trakt
|
||||
|
||||
def trakt_get_movies(config_path, plex, data):
|
||||
def trakt_get_movies(config_path, plex, data, is_userlist=True):
|
||||
config_tools.TraktClient(config_path)
|
||||
if is_userlist:
|
||||
trakt_url = data
|
||||
if trakt_url[-1:] == " ":
|
||||
trakt_url = trakt_url[:-1]
|
||||
imdb_map = {}
|
||||
trakt_list_path = urlparse(trakt_url).path
|
||||
trakt_list_items = trakt.Trakt[trakt_list_path].items()
|
||||
else:
|
||||
# Trending list
|
||||
max_items = int(data)
|
||||
trakt_list_items = trakt.Trakt['movies'].trending(per_page=max_items)
|
||||
title_ids = [m.pk[1] for m in trakt_list_items if isinstance(m, trakt.objects.movie.Movie)]
|
||||
|
||||
imdb_map = {}
|
||||
if title_ids:
|
||||
for item in plex.Library.all():
|
||||
guid = urlparse(item.guid)
|
||||
|
@ -52,14 +57,20 @@ def trakt_get_movies(config_path, plex, data):
|
|||
# No movies
|
||||
return None, None
|
||||
|
||||
def trakt_get_shows(config_path, plex, data):
|
||||
def trakt_get_shows(config_path, plex, data, is_userlist=True):
|
||||
config_tools.TraktClient(config_path)
|
||||
if is_userlist:
|
||||
trakt_url = data
|
||||
if trakt_url[-1:] == " ":
|
||||
trakt_url = trakt_url[:-1]
|
||||
tvdb_map = {}
|
||||
trakt_list_path = urlparse(trakt_url).path
|
||||
trakt_list_items = trakt.Trakt[trakt_list_path].items()
|
||||
else:
|
||||
# Trending list
|
||||
max_items = int(data)
|
||||
trakt_list_items = trakt.Trakt['shows'].trending(per_page=max_items)
|
||||
|
||||
tvdb_map = {}
|
||||
title_ids = []
|
||||
for m in trakt_list_items:
|
||||
if isinstance(m, trakt.objects.show.Show):
|
||||
|
|
|
@ -24,6 +24,9 @@ collections:
|
|||
Marvel:
|
||||
trakt_list: https://trakt.tv/users/movistapp/lists/marvel
|
||||
collection_mode: show_items
|
||||
Trakt Trending:
|
||||
trakt_trending: 30
|
||||
sync_mode: sync
|
||||
Pixar:
|
||||
studio: Pixar
|
||||
summary: A collection of Pixar movies
|
||||
|
|
Loading…
Reference in a new issue