mirror of
https://github.com/morpheus65535/bazarr.git
synced 2026-01-06 09:06:08 +08:00
Phase 2: Improve error handling for Plex webhook creation
- Add BadRequest import from plexapi.exceptions - Add specific handling for Plex API 422 validation errors (code 1998) - Provide actionable error messages explaining common failure reasons: - Plex Pass subscription required - Webhook URL not publicly accessible - Maximum webhook limit reached - Keep generic exception handler as fallback for other errors
This commit is contained in:
parent
e121f4c9a6
commit
c02e447d24
1 changed files with 18 additions and 0 deletions
|
|
@ -9,6 +9,7 @@ from datetime import datetime
|
|||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
from flask import request
|
||||
from flask_restx import Resource, reqparse, abort
|
||||
from plexapi.exceptions import BadRequest
|
||||
|
||||
from . import api_ns_plex
|
||||
from .exceptions import *
|
||||
|
|
@ -904,6 +905,23 @@ class PlexWebhookCreate(Resource):
|
|||
}
|
||||
}
|
||||
|
||||
except BadRequest as e:
|
||||
error_msg = str(e)
|
||||
logger.error(f"Plex API rejected webhook creation: {error_msg}")
|
||||
|
||||
# Parse common Plex error scenarios
|
||||
if '422' in error_msg:
|
||||
if '1998' in error_msg or 'validation' in error_msg.lower():
|
||||
return {
|
||||
'error': 'Plex rejected the webhook. This usually means:\n'
|
||||
'1. Plex Pass subscription is required but not active\n'
|
||||
'2. The webhook URL is not publicly accessible\n'
|
||||
'3. Maximum webhook limit reached (check plex.tv/webhooks)\n'
|
||||
f'Technical details: {error_msg}'
|
||||
}, 422
|
||||
|
||||
return {'error': f'Plex API error: {error_msg}'}, 502
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to create Plex webhook: {e}")
|
||||
return {'error': f'Failed to create webhook: {str(e)}'}, 502
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue