def get_json(self, **params): from resources.lib.third_party import xml_to_dict from xml.parsers.expat import ExpatError # pylint: disable=no-name-in-module response = self.get(**params) if response is None: return None try: if not response.content: return None elif xml_to_dict.parse(response.text).get("root", {}).get("@response", {}) == "False": return None elif xml_to_dict.parse(response.text).get("root", {}).get("error", {}): return None return self._handle_response( xml_to_dict.parse(response.text).get("root", {}).get("movie")) except (ValueError, AttributeError, ExpatError): g.log_stacktrace() g.log( "Failed to receive JSON from OMDb response - response: {}". format(response), "error", ) return None
def get_json(self, **params): response = self.get(**params) if response is None: return None try: if not response.content: return None return self._handle_response( xml_to_dict.parse(response.text).get("root", {}).get("movie")) except (ValueError, AttributeError): g.log_stacktrace() g.log( "Failed to receive JSON from OMDb response - response: {}". format(response), "error", ) return None