def tag_media_sibling_ordinal(tag):
if hasattr(tag, '<STR_LIT:name>') and tag.name != '<STR_LIT>':<EOL><INDENT>return None<EOL><DEDENT>nodenames = ['<STR_LIT>','<STR_LIT>','<STR_LIT>']<EOL>first_parent_tag = first_parent(tag, nodenames)<EOL>sibling_ordinal = None<EOL>if first_parent_tag:<EOL><INDENT>sibling_ordinal = <NUM_LIT:0><EOL>for media_tag in first_parent_tag.find_all(tag.name):<EOL><INDENT>if '<STR_LIT>' in tag.attrs and tag['<STR_LIT>'] == '<STR_LIT>':<EOL><INDENT>if '<STR_LIT>' in media_tag.attrs and tag['<STR_LIT>'] == '<STR_LIT>':<EOL><INDENT>sibling_ordinal += <NUM_LIT:1><EOL><DEDENT>if media_tag == tag:<EOL><INDENT>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if (('<STR_LIT>' not in media_tag.attrs)<EOL>or ('<STR_LIT>' in media_tag.attrs and tag['<STR_LIT>'] != '<STR_LIT>')):<EOL><INDENT>sibling_ordinal += <NUM_LIT:1><EOL><DEDENT>if media_tag == tag:<EOL><INDENT>break<EOL><DEDENT><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>sibling_ordinal = <NUM_LIT:1><EOL>for prev_tag in tag.find_all_previous(tag.name):<EOL><INDENT>if not first_parent(prev_tag, nodenames):<EOL><INDENT>if '<STR_LIT>' in tag.attrs and tag['<STR_LIT>'] == '<STR_LIT>':<EOL><INDENT>if supp_asset(prev_tag) == supp_asset(tag) and '<STR_LIT>' in prev_tag.attrs:<EOL><INDENT>sibling_ordinal += <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>if supp_asset(prev_tag) == supp_asset(tag) and '<STR_LIT>' not in prev_tag.attrs:<EOL><INDENT>sibling_ordinal += <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>return sibling_ordinal<EOL>
Count sibling ordinal differently depending on if the
mimetype is video or not