Example #1
0
def debug_file(filename, quiet=False, metadata=False):
    try:
        f = open(filename, 'rb')
    except IOError as e:
        (errno, strerror) = e.args
        log.error("Failed to open `%s': %s", filename, strerror)
        return False

    flv = tags.FLV(f)

    if not quiet:
        print(("=== `%s' ===" % filename))

    try:
        tag_generator = flv.iter_tags()
        for i, tag in enumerate(tag_generator):
            if quiet:
                # If we're quiet, we just want to catch errors
                continue
            # Print the tag information
            print(("#%05d %s" % (i + 1, tag)))
            # Print the content of onMetaData tags
            if (isinstance(tag, tags.ScriptTag)
                and tag.name == "onMetaData"):
                helpers.pprint(tag.variable)
                if metadata:
                    return True
    except MalformedFLV as e:
        message = e.args[0] % e.args[1:]
        log.error("The file `%s' is not a valid FLV file: %s",
                  filename, message)
        return False
    except tags.EndOfFile:
        log.error("Unexpected end of file on file `%s'", filename)
        return False

    f.close()

    return True
Example #2
0
def debug_file(filename, quiet=False, metadata=False):
    try:
        f = open(filename, 'rb')
    except IOError as e:
        (errno, strerror) = e.args
        log.error("Failed to open `%s': %s", filename, strerror)
        return False

    flv = tags.FLV(f)

    if not quiet:
        print(("=== `%s' ===" % filename))

    try:
        tag_generator = flv.iter_tags()
        for i, tag in enumerate(tag_generator):
            if quiet:
                # If we're quiet, we just want to catch errors
                continue
            # Print the tag information
            print(("#%05d %s" % (i + 1, tag)))
            # Print the content of onMetaData tags
            if (isinstance(tag, tags.ScriptTag) and tag.name == "onMetaData"):
                helpers.pprint(tag.variable)
                if metadata:
                    return True
    except MalformedFLV as e:
        message = e.args[0] % e.args[1:]
        log.error("The file `%s' is not a valid FLV file: %s", filename,
                  message)
        return False
    except tags.EndOfFile:
        log.error("Unexpected end of file on file `%s'", filename)
        return False

    f.close()

    return True
    if not quiet:
        print "=== `%s' ===" % filename

    try:
        tag_generator = flv.iter_tags()
        for i, tag in enumerate(tag_generator):
            if quiet:
                # If we're quiet, we just want to catch errors
                continue
            # Print the tag information
            print "#%05d %s" % (i + 1, tag)
            # Print the content of onMetaData tags
            if (isinstance(tag, tags.ScriptTag)
                and tag.name == "onMetaData"):
                helpers.pprint(tag.variable)
                if metadata:
                    return True
    except MalformedFLV, e:
        message = e[0] % e[1:]
        log.error("The file `%s' is not a valid FLV file: %s",
                  filename, message)
        return False
    except tags.EndOfFile:
        log.error("Unexpected end of file on file `%s'", filename)
        return False

    f.close()

    return True
Example #4
0
    flv = tags.FLV(f)

    if not quiet:
        print "=== `%s' ===" % filename

    ret_tags = []
    ret_msg = []
    try:
        tag_generator = flv.iter_tags()
        for i, tag in enumerate(tag_generator):
            # Print the tag information
            # Print the content of onMetaData tags
            msg = ''
            if (isinstance(tag, tags.ScriptTag) and tag.name == "onMetaData"):
                if not quiet:
                    helpers.pprint(tag.variable)
                    msg = "#%05d %s" % (i + 1, tag)
            elif isinstance(tag, tags.AudioTag) and tag.aac_packet_type == 1:  # AAC raw frame data
                msg = ("#%05d %s" % (i + 1, tag)).replace('AudioTag', 'AudioTag[%d]' % (len(tag.raw_data), ))
                tag = tryFixAudioTag(tag)
            elif isinstance(tag, tags.VideoTag) and tag.h264_packet_type == 1:  # AAC raw frame data
                msg = ("#%05d %s" % (i + 1, tag)).replace('VideoTag', 'VideoTag[%d]' % (tag.avc_raw.get('all_len', 0), ))
                tag = tryFixVideoTag(tag)
            else:
                if not quiet:
                    msg = "#%05d %s" % (i + 1, tag)

            ret_tags.append(tag)
            if msg:
                ret_msg.append(msg)
    except MalformedFLV, e: