| @@ 140-154 (lines=15) @@ | ||
| 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.""" |
|
| 142 | if not collections: logging.info("Pin list is empty."); return |
|
| 143 | webhook_url = config.get('discord_webhook_url') |
|
| 144 | for collection in collections: |
|
| 145 | coll_title = getattr(collection, 'title', 'Untitled') |
|
| 146 | try: |
|
| 147 | if not hasattr(collection, 'visibility'): logging.warning(f"Skip invalid: '{coll_title}'."); continue |
|
| 148 | logging.info(f"Attempting to pin: '{coll_title}'") |
|
| 149 | hub = collection.visibility() |
|
| 150 | hub.promoteHome(); hub.promoteShared() |
|
| 151 | message = f"INFO - Collection '{coll_title}' pinned successfully." |
|
| 152 | logging.info(message) |
|
| 153 | if webhook_url: send_discord_message(webhook_url, message) |
|
| 154 | except Exception as e: logging.error(f"Error pinning '{coll_title}': {e}") |
|
| 155 | ||
| 156 | def send_discord_message(webhook_url, message): |
|
| 157 | """Sends a message to the specified Discord webhook URL.""" |
|
| @@ 140-154 (lines=15) @@ | ||
| 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.""" |
|
| 142 | if not collections: logging.info("Pin list is empty."); return |
|
| 143 | webhook_url = config.get('discord_webhook_url') |
|
| 144 | for collection in collections: |
|
| 145 | coll_title = getattr(collection, 'title', 'Untitled') |
|
| 146 | try: |
|
| 147 | if not hasattr(collection, 'visibility'): logging.warning(f"Skip invalid: '{coll_title}'."); continue |
|
| 148 | logging.info(f"Attempting to pin: '{coll_title}'") |
|
| 149 | hub = collection.visibility() |
|
| 150 | hub.promoteHome(); hub.promoteShared() |
|
| 151 | message = f"INFO - Collection '{coll_title}' pinned successfully." |
|
| 152 | logging.info(message) |
|
| 153 | if webhook_url: send_discord_message(webhook_url, message) |
|
| 154 | except Exception as e: logging.error(f"Error pinning '{coll_title}': {e}") |
|
| 155 | ||
| 156 | def send_discord_message(webhook_url, message): |
|
| 157 | """Sends a message to the specified Discord webhook URL.""" |
|