| @@ 125-138 (lines=14) @@ | ||
| 122 | except ValueError as e: logging.error(f"Config error for Plex: {e}"); return None |
|
| 123 | except Exception as e: logging.error(f"Failed to connect to Plex: {e}"); return None |
|
| 124 | ||
| 125 | def get_collections_from_all_libraries(plex, library_names): |
|
| 126 | """Fetches all collection objects from the specified library names.""" |
|
| 127 | all_collections = [] |
|
| 128 | if not plex or not library_names: return all_collections |
|
| 129 | for library_name in library_names: |
|
| 130 | if not isinstance(library_name, str): logging.warning(f"Invalid lib name: {library_name}"); continue |
|
| 131 | try: |
|
| 132 | library = plex.library.section(library_name) |
|
| 133 | collections_in_library = library.collections() |
|
| 134 | logging.info(f"Found {len(collections_in_library)} collections in '{library_name}'.") |
|
| 135 | all_collections.extend(collections_in_library) |
|
| 136 | except NotFound: logging.error(f"Library '{library_name}' not found.") |
|
| 137 | except Exception as e: logging.error(f"Error fetching from '{library_name}': {e}") |
|
| 138 | return all_collections |
|
| 139 | ||
| 140 | def pin_collections(collections, config): |
|
| 141 | """Pins the provided list of collections and sends individual Discord notifications.""" |
|
| @@ 125-138 (lines=14) @@ | ||
| 122 | except ValueError as e: logging.error(f"Config error for Plex: {e}"); return None |
|
| 123 | except Exception as e: logging.error(f"Failed to connect to Plex: {e}"); return None |
|
| 124 | ||
| 125 | def get_collections_from_all_libraries(plex, library_names): |
|
| 126 | """Fetches all collection objects from the specified library names.""" |
|
| 127 | all_collections = [] |
|
| 128 | if not plex or not library_names: return all_collections |
|
| 129 | for library_name in library_names: |
|
| 130 | if not isinstance(library_name, str): logging.warning(f"Invalid lib name: {library_name}"); continue |
|
| 131 | try: |
|
| 132 | library = plex.library.section(library_name) |
|
| 133 | collections_in_library = library.collections() |
|
| 134 | logging.info(f"Found {len(collections_in_library)} collections in '{library_name}'.") |
|
| 135 | all_collections.extend(collections_in_library) |
|
| 136 | except NotFound: logging.error(f"Library '{library_name}' not found.") |
|
| 137 | except Exception as e: logging.error(f"Error fetching from '{library_name}': {e}") |
|
| 138 | return all_collections |
|
| 139 | ||
| 140 | def pin_collections(collections, config): |
|
| 141 | """Pins the provided list of collections and sends individual Discord notifications.""" |
|