'Correct same data based on specific rules'

def _finalize(self):

    for key in self._keys:
        if (key in UNPRINTABLE_KEYS):
            continue
        value = getattr(self, key)
        if (value is None):
            continue
        if (key == 'image'):
            if isinstance(value, unicode):
                setattr(self, key, unicode_to_str(value))
            continue
        if isinstance(value, str):
            setattr(self, key, str_to_unicode(value))
        if isinstance(value, unicode):
            setattr(self, key, value.strip().rstrip().replace(u'\x00', u''))
        if (isinstance(value, list) and value and isinstance(value[0], Media)):
            for submenu in value:
                submenu._finalize()
    for (name, table) in self.tables.items():
        mapping = self.table_mapping.get(name, {})
        for (tag, attr) in mapping.items():
            if self.get(attr):
                continue
            value = table.get(tag, None)
            if (value is not None):
                if (not isinstance(value, (str, unicode))):
                    value = str_to_unicode(str(value))
                elif isinstance(value, str):
                    value = str_to_unicode(value)
                value = value.strip().rstrip().replace(u'\x00', u'')
                setattr(self, attr, value)
    if (('fourcc' in self._keys) and ('codec' in self._keys) and (self.codec is not None)):
        (self.fourcc, self.codec) = fourcc.resolve(self.codec)
    if ('language' in self._keys):
        (self.langcode, self.language) = language.resolve(self.language)
