https://bugs.gpodder.org/show_bug.cgi?id=1663

--- Comment #2 from [email protected] 2012-09-10 15:11:28 BST ---
I had to alter the get_header_param function of download.py and now it works.

Proposed function (see also attached diff):

def get_header_param(headers, param, header_name):
    """Extract a HTTP header parameter from a dict

    Uses the "email" module to retrieve parameters
    from HTTP headers. This can be used to get the
    "filename" parameter of the "content-disposition"
    header for downloads to pick a good filename.

    Returns None if the filename cannot be retrieved.
    """
    value = None
    try:
        headers_string = ['%s:%s'%(k,v) for k,v in headers.items()]
        msg = email.message_from_string('\n'.join(headers_string))
        if header_name in msg:
            raw_value = msg.get_param(param, header=header_name)
            value = email.utils.collapse_rfc2231_value(raw_value)
    except Exception, e:
        logger.error('Cannot get %s from %s', param, header_name,
exc_info=True)

    return value

-- 
Configure bugmail: https://bugs.gpodder.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.
_______________________________________________
gPodder-Bugs mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/gpodder-bugs

Reply via email to