From e10111dd6fd0244d3327b2d5149b3e7da5dbbe69 Mon Sep 17 00:00:00 2001 From: todd Date: Thu, 28 Apr 2022 16:15:55 -0400 Subject: [PATCH] fix: telegram doesn't like some movie posters #49 ver: 2.1.4 --- searcharr.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/searcharr.py b/searcharr.py index 89c7ee1..9cc1e5e 100644 --- a/searcharr.py +++ b/searcharr.py @@ -22,7 +22,7 @@ import sonarr import settings -__version__ = "2.1.3" +__version__ = "2.1.4" DBPATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data") DBFILE = "searcharr.db" @@ -382,7 +382,7 @@ def cmd_movie(self, update, context): reply_markup=reply_markup, ) except BadRequest as e: - if str(e) == "Wrong type of the web page content": + if str(e) in self._bad_request_poster_error_messages: logger.error( f"Error sending photo [{r['remotePoster']}]: BadRequest: {e}. Attempting to send with default poster..." ) @@ -453,7 +453,7 @@ def cmd_series(self, update, context): reply_markup=reply_markup, ) except BadRequest as e: - if str(e) == "Wrong type of the web page content": + if str(e) in self._bad_request_poster_error_messages: logger.error( f"Error sending photo [{r['remotePoster']}]: BadRequest: {e}. Attempting to send with default poster..." ) @@ -591,7 +591,7 @@ def callback(self, update, context): reply_markup=reply_markup, ) except BadRequest as e: - if str(e) == "Wrong type of the web page content": + if str(e) in self._bad_request_poster_error_messages: logger.error( f"Error sending photo [{r['remotePoster']}]: BadRequest: {e}. Attempting to send with default poster..." ) @@ -641,7 +641,7 @@ def callback(self, update, context): reply_markup=reply_markup, ) except BadRequest as e: - if str(e) == "Wrong type of the web page content": + if str(e) in self._bad_request_poster_error_messages: logger.error( f"Error sending photo [{r['remotePoster']}]: BadRequest: {e}. Attempting to send with default poster..." ) @@ -704,7 +704,7 @@ def callback(self, update, context): reply_markup=reply_markup, ) except BadRequest as e: - if str(e) == "Wrong type of the web page content": + if str(e) in self._bad_request_poster_error_messages: logger.error( f"Error sending photo [{r['remotePoster']}]: BadRequest: {e}. Attempting to send with default poster..." ) @@ -786,7 +786,7 @@ def callback(self, update, context): reply_markup=reply_markup, ) except BadRequest as e: - if str(e) == "Wrong type of the web page content": + if str(e) in self._bad_request_poster_error_messages: logger.error( f"Error sending photo [{r['remotePoster']}]: BadRequest: {e}. Attempting to send with default poster..." ) @@ -851,7 +851,7 @@ def callback(self, update, context): reply_markup=reply_markup, ) except BadRequest as e: - if str(e) == "Wrong type of the web page content": + if str(e) in self._bad_request_poster_error_messages: logger.error( f"Error sending photo [{r['remotePoster']}]: BadRequest: {e}. Attempting to send with default poster..." ) @@ -905,7 +905,7 @@ def callback(self, update, context): reply_markup=reply_markup, ) except BadRequest as e: - if str(e) == "Wrong type of the web page content": + if str(e) in self._bad_request_poster_error_messages: logger.error( f"Error sending photo [{r['remotePoster']}]: BadRequest: {e}. Attempting to send with default poster..." ) @@ -1761,6 +1761,11 @@ def _xlate(self, key, **kwargs): logger.error(f"No translation found for key [{key}]!") return "(translation not found)" + _bad_request_poster_error_messages = [ + "Wrong type of the web page content", + "Wrong file identifier/http url specified", + ] + if __name__ == "__main__": args = parse_args()