human
Complete this python program:
def get_metadata(stream):
assistant
#Here is the Python code you requested.

    """Return metadata as a L{MetaInfo} object
    """
    title = 'Unknown'
    mi = MetaInformation(title, ['Unknown'])
    stream.seek(0)
    try:
        if (stream.read(10) not in MAGIC):
            print >>sys.stderr, u"Couldn't    read    IMP    header    from    file"
            return mi
        def cString(skip=0):
            result = ''
            while 1:
                data = stream.read(1)
                if (data == '\x00'):
                    if (not skip):
                        return result
                    skip -= 1
                    (result, data) = ('', '')
                result += data
        stream.read(38)
        cString()
        (category, title, author) = (cString(), cString(1), cString(2))
        if title:
            mi.title = title
        if author:
            mi.authors = string_to_authors(author)
            mi.author = author
        if category:
            mi.category = category
    except Exception as err:
        msg = (u"Couldn't    read    metadata    from    imp:    %s    with    error    %s" % (mi.title, unicode(err)))
        print >>sys.stderr, msg.encode('utf8')
    return mi