diff --git a/README.md b/README.md index ec44c0c..66ef1df 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,14 @@ # Emby MDBList Collection Creator 1.8 -This tool allows you to convert lists from MDBList.com into collections within your Emby media server. MDBList aggregates content lists from various platforms including Trakt and IMDB) +This tool allows you to convert lists from MDBList.com into collections within your Emby media server. MDBList aggregates content lists from various platforms including Trakt and IMDB. ## Features * List Conversion: Transform MDBList lists into Emby collections * Metadata Refresh: Keep ratings up-to-date for newly released content -* Collection Images: Upload both local and remote images for collections -* Seasonal collections: Specify when a collections should be visible +* Collection Images: Upload local or remote images for collections posters +* Seasonal Collections: Specify when a collections should be visible +* Collection Ordering: Show your collections in order of which one was update * Backup & Restore: Additional utilities to backup and restore watch history and favorites ## Prerequisites: diff --git a/app.py b/app.py index 9749fea..8d0297d 100644 --- a/app.py +++ b/app.py @@ -1,13 +1,14 @@ import random import time import configparser -from emby import Emby -from item_sorting import ItemSorting -from refresher import Refresher -from mdblist import Mdblist -from datetime import datetime -from date_parser import inside_period -from db import Db +from src.emby import Emby +from src.item_sorting import ItemSorting +from src.refresher import Refresher +from src.mdblist import Mdblist +from src.date_parser import inside_period +from src.db import Db +from src.utils import find_missing_entries_in_list +from src.utils import minutes_until_2100 config_parser = configparser.ConfigParser() config_parser.optionxform = str.lower @@ -29,11 +30,9 @@ update_collection_sort_name = config_parser.getboolean( "admin", "update_collection_sort_name", fallback=True ) - update_items_sort_names_default_value = config_parser.getboolean( "admin", "update_items_sort_names_default_value", fallback=False ) - refresh_items = config_parser.getboolean( "admin", "refresh_items_in_collections", fallback=False ) @@ -43,7 +42,6 @@ refresh_items_max_days_since_premiered = config_parser.getint( "admin", "refresh_items_in_collections_max_days_since_premiered", fallback=30 ) - hours_between_refresh = config_parser.getint("admin", "hours_between_refresh") newly_added = 0 @@ -58,33 +56,6 @@ db_manager = Db() -def find_missing_entries_in_list(list_to_check, list_to_find): - """ - Finds the missing entries in a list. - - Args: - list_to_check (list): The list to check against. - list_to_find (list): The list to find missing entries in. - - Returns: - list: A list of missing entries found in list_to_find. - """ - return [item for item in list_to_find if item not in list_to_check] - - -def minutes_until_2100(): - """ - Used for sorting collection so that the newest show up first in Emby. - Returns: - int: The number of minutes remaining until the year 2100. - """ - today = datetime.now() - year_2100 = datetime(2100, 1, 1) - delta = year_2100 - today - minutes = delta.days * 24 * 60 + delta.seconds // 60 - return minutes - - def process_list(mdblist_list: dict): global newly_added global newly_removed @@ -139,9 +110,7 @@ def process_list(mdblist_list: dict): elif mdblist_name is not None and user_name is not None: found_list_id = mdblist.find_list_id_by_name_and_user(mdblist_name, user_name) if found_list_id is None: - print( - f"ERROR! Could not find list {mdblist_name} by user {user_name}. Will not process this list." - ) + print(f"ERROR! List {mdblist_name} by {user_name} not found. Skipping.") print("=========================================") return mdblist_imdb_ids, mdblist_mediatypes = mdblist.get_list(found_list_id) @@ -155,16 +124,12 @@ def process_list(mdblist_list: dict): mdblist_imdb_ids.extend(imdb_ids) mdblist_mediatypes.extend(mediatypes) else: - print( - f"ERROR! Must provide either list_id or both list_name and user_name for mdblist {collection_name}. Will not process this list." - ) + print(f"ERROR! Must provide either id or source for {collection_name}.") print("=========================================") return if mdblist_imdb_ids is None: - print( - f"ERROR! No items in mdblist {collection_name}. Will not process this list." - ) + print(f"ERROR! No items in {collection_name}. Will not process this list.") print("=========================================") return @@ -207,20 +172,15 @@ def process_list(mdblist_list: dict): add_emby_ids = emby.get_items_with_imdb_id(missing_imdb_ids, mdblist_mediatypes) print() - print( - f"Added {len(add_emby_ids)} new items to Collection and removed {len(remove_emby_ids)}" - ) + print(f"Added {len(add_emby_ids)} new items and removed {len(remove_emby_ids)}") if collection_id is None: if len(add_emby_ids) == 0: - print( - f"ERROR! No items to put in mdblist {collection_name}. Will not process." - ) + print(f"ERROR! No items to put in mdblist {collection_name}.") print("=========================================") return - collection_id = emby.create_collection( - collection_name, [add_emby_ids[0]] - ) # Create the collection with the first item since you have to create with an item + # Create the collection with the first item since you have to create with an item + collection_id = emby.create_collection(collection_name, [add_emby_ids[0]]) add_emby_ids.pop(0) if collection_id not in all_collections_ids: @@ -256,7 +216,6 @@ def process_my_lists_on_mdblist(): def process_hardcoded_lists(): - # Get all section from config file that are not "admin" and add to mdblist_lists collections = [] for section in config_parser.sections(): if section == "admin": diff --git a/app_backup.py b/app_backup.py index 4560025..91918ec 100644 --- a/app_backup.py +++ b/app_backup.py @@ -5,7 +5,7 @@ import configparser import json -from emby import Emby +from src.emby import Emby import os directory = "backup" diff --git a/app_restore_backup.py b/app_restore_backup.py index db22c09..6a2c41d 100644 --- a/app_restore_backup.py +++ b/app_restore_backup.py @@ -34,7 +34,7 @@ etc """ -from emby import Emby +from src.emby import Emby import ast import sys from argparse import ArgumentParser diff --git a/config.cfg b/config.cfg index 98332e7..d9e4d70 100644 --- a/config.cfg +++ b/config.cfg @@ -93,7 +93,7 @@ frequency = 100 update_items_sort_names = False # Example using a collection poster. Either a local path or an image URL. -# https://plexcollectionposters.com/ has a lot of great posters. +# https://theposterdb.com/ and https://plexcollectionposters.com/ have a lot of great posters. [Oscars 2024] source = https://mdblist.com/lists/squint/the-96th-academy-awards poster = https://plexcollectionposters.com/images/2019/01/31/oscars9a7c2bc47188f883.png @@ -107,7 +107,7 @@ update_items_sort_names = False # Example: active_between = 09-30, 11-01. [Best of Halloween] source = https://mdblist.com/lists/hdlists/the-top-100-halloween-movies-of-all-time -poster = https://plexcollectionposters.com/images/2021/11/16/halloween-collectionb0b15dcb9ee4669b.jpg +poster = https://theposterdb.com/api/assets/190058/view active_between = 09-30, 11-01 frequency = 100 update_items_sort_names = False \ No newline at end of file diff --git a/date_parser.py b/src/date_parser.py similarity index 100% rename from date_parser.py rename to src/date_parser.py diff --git a/db.py b/src/db.py similarity index 100% rename from db.py rename to src/db.py diff --git a/emby.py b/src/emby.py similarity index 100% rename from emby.py rename to src/emby.py diff --git a/item_sorting.py b/src/item_sorting.py similarity index 100% rename from item_sorting.py rename to src/item_sorting.py diff --git a/mdblist.py b/src/mdblist.py similarity index 100% rename from mdblist.py rename to src/mdblist.py diff --git a/refresher.py b/src/refresher.py similarity index 100% rename from refresher.py rename to src/refresher.py diff --git a/src/utils.py b/src/utils.py new file mode 100644 index 0000000..ff86a72 --- /dev/null +++ b/src/utils.py @@ -0,0 +1,28 @@ +from datetime import datetime + + +def find_missing_entries_in_list(list_to_check, list_to_find): + """ + Finds the missing entries in a list. + + Args: + list_to_check (list): The list to check against. + list_to_find (list): The list to find missing entries in. + + Returns: + list: A list of missing entries found in list_to_find. + """ + return [item for item in list_to_find if item not in list_to_check] + + +def minutes_until_2100(): + """ + Used for sorting collection so that the newest show up first in Emby. + Returns: + int: The number of minutes remaining until the year 2100. + """ + today = datetime.now() + year_2100 = datetime(2100, 1, 1) + delta = year_2100 - today + minutes = delta.days * 24 * 60 + delta.seconds // 60 + return minutes