How to use the tinytag.tinytag.MP4.Parser function in tinytag

To help you get started, we’ve selected a few tinytag examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github devsnd / tinytag / tinytag / tinytag.py View on Github external
time_scale = struct.unpack('>I', walker.read(4))[0]
                duration = struct.unpack('>q', walker.read(8))[0]
            return {'duration': float(duration) / time_scale}

        @classmethod
        def debug_atom(cls, data):
            stderr(data)  # use this function to inspect atoms in an atom tree
            return {}

    # The parser tree: Each key is an atom name which is traversed if existing.
    # Leaves of the parser tree are callables which receive the atom data.
    # callables return {fieldname: value} which is updates the TinyTag.
    META_DATA_TREE = {b'moov': {b'udta': {b'meta': {b'ilst': {
        # see: http://atomicparsley.sourceforge.net/mpeg-4files.html
        b'\xa9alb': {b'data': Parser.make_data_atom_parser('album')},
        b'\xa9ART': {b'data': Parser.make_data_atom_parser('artist')},
        b'aART':    {b'data': Parser.make_data_atom_parser('albumartist')},
        # b'cpil':    {b'data': Parser.make_data_atom_parser('compilation')},
        b'\xa9cmt': {b'data': Parser.make_data_atom_parser('comment')},
        b'disk':    {b'data': Parser.make_number_parser('disc', 'disc_total')},
        b'\xa9wrt': {b'data': Parser.make_data_atom_parser('composer')},
        b'\xa9day': {b'data': Parser.make_data_atom_parser('year')},
        b'\xa9gen': {b'data': Parser.make_data_atom_parser('genre')},
        b'gnre':    {b'data': Parser.parse_id3v1_genre},
        b'\xa9nam': {b'data': Parser.make_data_atom_parser('title')},
        b'trkn':    {b'data': Parser.make_number_parser('track', 'track_total')},
    }}}}}

    # see: https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html
    AUDIO_DATA_TREE = {
        b'moov': {
            b'mvhd': Parser.parse_mvhd,
github devsnd / tinytag / tinytag / tinytag.py View on Github external
b'aART':    {b'data': Parser.make_data_atom_parser('albumartist')},
        # b'cpil':    {b'data': Parser.make_data_atom_parser('compilation')},
        b'\xa9cmt': {b'data': Parser.make_data_atom_parser('comment')},
        b'disk':    {b'data': Parser.make_number_parser('disc', 'disc_total')},
        b'\xa9wrt': {b'data': Parser.make_data_atom_parser('composer')},
        b'\xa9day': {b'data': Parser.make_data_atom_parser('year')},
        b'\xa9gen': {b'data': Parser.make_data_atom_parser('genre')},
        b'gnre':    {b'data': Parser.parse_id3v1_genre},
        b'\xa9nam': {b'data': Parser.make_data_atom_parser('title')},
        b'trkn':    {b'data': Parser.make_number_parser('track', 'track_total')},
    }}}}}

    # see: https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html
    AUDIO_DATA_TREE = {
        b'moov': {
            b'mvhd': Parser.parse_mvhd,
            b'trak': {b'mdia': {b"minf": {b"stbl": {b"stsd": {b'mp4a':
                Parser.parse_audio_sample_entry
            }}}}}
        }
    }

    IMAGE_DATA_TREE = {b'moov': {b'udta': {b'meta': {b'ilst': {
        b'covr': {b'data': Parser.make_data_atom_parser('_image_data')},
    }}}}}

    VERSIONED_ATOMS = {b'meta', b'stsd'}  # those have an extra 4 byte header
    FLAGGED_ATOMS = {b'stsd'}  # these also have an extra 4 byte header

    def _determine_duration(self, fh):
        self._traverse_atoms(fh, path=self.AUDIO_DATA_TREE)
github devsnd / tinytag / tinytag / tinytag.py View on Github external
b'\xa9cmt': {b'data': Parser.make_data_atom_parser('comment')},
        b'disk':    {b'data': Parser.make_number_parser('disc', 'disc_total')},
        b'\xa9wrt': {b'data': Parser.make_data_atom_parser('composer')},
        b'\xa9day': {b'data': Parser.make_data_atom_parser('year')},
        b'\xa9gen': {b'data': Parser.make_data_atom_parser('genre')},
        b'gnre':    {b'data': Parser.parse_id3v1_genre},
        b'\xa9nam': {b'data': Parser.make_data_atom_parser('title')},
        b'trkn':    {b'data': Parser.make_number_parser('track', 'track_total')},
    }}}}}

    # see: https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html
    AUDIO_DATA_TREE = {
        b'moov': {
            b'mvhd': Parser.parse_mvhd,
            b'trak': {b'mdia': {b"minf": {b"stbl": {b"stsd": {b'mp4a':
                Parser.parse_audio_sample_entry
            }}}}}
        }
    }

    IMAGE_DATA_TREE = {b'moov': {b'udta': {b'meta': {b'ilst': {
        b'covr': {b'data': Parser.make_data_atom_parser('_image_data')},
    }}}}}

    VERSIONED_ATOMS = {b'meta', b'stsd'}  # those have an extra 4 byte header
    FLAGGED_ATOMS = {b'stsd'}  # these also have an extra 4 byte header

    def _determine_duration(self, fh):
        self._traverse_atoms(fh, path=self.AUDIO_DATA_TREE)

    def _parse_tag(self, fh):
        self._traverse_atoms(fh, path=self.META_DATA_TREE)
github devsnd / tinytag / tinytag / tinytag.py View on Github external
# The parser tree: Each key is an atom name which is traversed if existing.
    # Leaves of the parser tree are callables which receive the atom data.
    # callables return {fieldname: value} which is updates the TinyTag.
    META_DATA_TREE = {b'moov': {b'udta': {b'meta': {b'ilst': {
        # see: http://atomicparsley.sourceforge.net/mpeg-4files.html
        b'\xa9alb': {b'data': Parser.make_data_atom_parser('album')},
        b'\xa9ART': {b'data': Parser.make_data_atom_parser('artist')},
        b'aART':    {b'data': Parser.make_data_atom_parser('albumartist')},
        # b'cpil':    {b'data': Parser.make_data_atom_parser('compilation')},
        b'\xa9cmt': {b'data': Parser.make_data_atom_parser('comment')},
        b'disk':    {b'data': Parser.make_number_parser('disc', 'disc_total')},
        b'\xa9wrt': {b'data': Parser.make_data_atom_parser('composer')},
        b'\xa9day': {b'data': Parser.make_data_atom_parser('year')},
        b'\xa9gen': {b'data': Parser.make_data_atom_parser('genre')},
        b'gnre':    {b'data': Parser.parse_id3v1_genre},
        b'\xa9nam': {b'data': Parser.make_data_atom_parser('title')},
        b'trkn':    {b'data': Parser.make_number_parser('track', 'track_total')},
    }}}}}

    # see: https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html
    AUDIO_DATA_TREE = {
        b'moov': {
            b'mvhd': Parser.parse_mvhd,
            b'trak': {b'mdia': {b"minf": {b"stbl": {b"stsd": {b'mp4a':
                Parser.parse_audio_sample_entry
            }}}}}
        }
    }

    IMAGE_DATA_TREE = {b'moov': {b'udta': {b'meta': {b'ilst': {
        b'covr': {b'data': Parser.make_data_atom_parser('_image_data')},