From 8e075850849a1855386e13f8ec576f3afe84ddf4 Mon Sep 17 00:00:00 2001 From: morpheus65535 Date: Mon, 28 Mar 2022 12:25:09 -0400 Subject: Fixed Plex webhook for series by having a more robust imdb parsing nd some logging in case of exception. #1780 --- bazarr/api/webhooks/plex.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bazarr/api/webhooks/plex.py b/bazarr/api/webhooks/plex.py index 32b9953a5..6584a13e2 100644 --- a/bazarr/api/webhooks/plex.py +++ b/bazarr/api/webhooks/plex.py @@ -3,7 +3,7 @@ import json import requests import os -import re +import logging from flask import request from flask_restful import Resource @@ -46,8 +46,12 @@ class WebHooksPlex(Resource): r = requests.get('https://imdb.com/title/{}'.format(episode_imdb_id), headers={"User-Agent": os.environ["SZ_USER_AGENT"]}) soup = bso(r.content, "html.parser") - series_imdb_id = soup.find('a', {'class': re.compile(r'SeriesParentLink__ParentTextLink')})['href'].split('/')[2] + script_tag = soup.find(id='__NEXT_DATA__') + script_tag_json = script_tag.string + show_metadata_dict = json.loads(script_tag_json) + series_imdb_id = show_metadata_dict['props']['pageProps']['aboveTheFoldData']['series']['series']['id'] except Exception: + logging.debug('BAZARR is unable to get series IMDB id.') return '', 404 else: sonarrEpisodeId = TableEpisodes.select(TableEpisodes.sonarrEpisodeId) \ -- cgit v1.2.3