Ticket #13619: 02_add_option_to_return_raw_content.patch

File 02_add_option_to_return_raw_content.patch, 1.7 KB (added by rcrdnalor, 8 months ago)

Add option to return raw data

  • mythtv/bindings/python/MythTV/services_api/send.py

    diff --git a/mythtv/bindings/python/MythTV/services_api/send.py b/mythtv/bindings/python/MythTV/services_api/send.py
    index ca8347fe8f..082558a2f8 100644
    a b class Send(object): 
    141141                         its response in XML rather than JSON. Defaults to
    142142                         False.
    143143
     144        opts['rawxml']:  If True, causes the backend to send it's response in
     145                         XML as bytes. This can be easily parsed by python's
     146                         'lxml.etree.fromstring()'. Defaults to False.
     147
    144148        opts['wrmi']:    If True and there is postdata, the URL is then sent to
    145149                         the server.
    146150
    class Send(object): 
    296300        if self.opts['usexml']:
    297301            return response.text
    298302
     303        if self.opts['rawxml']:
     304            return response.content
     305
    299306        try:
    300307            return response.json()
    301308        except ValueError as err:
    class Send(object): 
    320327        if not isinstance(self.opts, dict):
    321328            self.opts = {}
    322329
    323         for option in ('noetag', 'nogzip', 'usexml', 'wrmi', 'wsdl'):
     330        for option in ('noetag', 'nogzip', 'usexml', 'rawxml', 'wrmi', 'wsdl'):
    324331            try:
    325332                self.opts[option]
    326333            except (KeyError, TypeError):
    class Send(object): 
    396403        else:
    397404            self.session.headers.update({'Accept-Encoding': 'gzip,deflate'})
    398405
    399         if self.opts['usexml']:
     406        if self.opts['usexml'] or self.opts['rawxml']:
    400407            self.session.headers.update({'Accept': ''})
    401408        else:
    402409            self.session.headers.update({'Accept': 'application/json'})