'Set extended attributes on downloaded file (if xattr support is found).'

def run(self, info):

    self._downloader.to_screen(u"[metadata]    Writing    metadata    to    file's    xattrs")
    filename = info[u'filepath']
    try:
        xattr_mapping = {u'user.xdg.referrer.url': u'webpage_url', u'user.dublincore.title': u'title', u'user.dublincore.date': u'upload_date', u'user.dublincore.description': u'description', u'user.dublincore.contributor': u'uploader', u'user.dublincore.format': u'format'}
        for (xattrname, infoname) in xattr_mapping.items():
            value = info.get(infoname)
            if value:
                if (infoname == u'upload_date'):
                    value = hyphenate_date(value)
                byte_value = value.encode(u'utf-8')
                write_xattr(filename, xattrname, byte_value)
        return ([], info)
    except XAttrUnavailableError as e:
        self._downloader.report_error(str(e))
        return ([], info)
    except XAttrMetadataError as e:
        if (e.reason == u'NO_SPACE'):
            self._downloader.report_warning((u"There's    no    disk    space    left    or    disk    quota    exceeded.    " + u'Extended    attributes    are    not    written.'))
        elif (e.reason == u'VALUE_TOO_LONG'):
            self._downloader.report_warning(u'Unable    to    write    extended    attributes    due    to    too    long    values.')
        else:
            msg = u"This    filesystem    doesn't    support    extended    attributes.    "
            if (compat_os_name == u'nt'):
                msg += u'You    need    to    use    NTFS.'
            else:
                msg += u'(You    may    have    to    enable    them    in    your    /etc/fstab)'
            self._downloader.report_error(msg)
        return ([], info)
