summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormorpheus65535 <[email protected]>2022-03-28 12:25:09 -0400
committermorpheus65535 <[email protected]>2022-03-28 12:25:09 -0400
commit8e075850849a1855386e13f8ec576f3afe84ddf4 (patch)
tree25e0bb412943f50f3e95cc95f3b60d2d09ba8543
parentd04e8f19aadf456b3b658571a041ea661af3be6e (diff)
downloadbazarr-8e075850849a1855386e13f8ec576f3afe84ddf4.tar.gz
bazarr-8e075850849a1855386e13f8ec576f3afe84ddf4.zip
Fixed Plex webhook for series by having a more robust imdb parsing nd some logging in case of exception. #1780
-rw-r--r--bazarr/api/webhooks/plex.py8
1 files 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) \