class Meta: database = Config.db()
def unify(title): """ Split on dash and only keeps first occurence of tokens """ tokens = tokenify(title) groups = OrderedDict() for token in tokens: groups.setdefault( remove_parentheses(token.lower()).strip(), []).append(token) # for each lower+no_parenthesis token, take the *longest* element return u' - '.join( sorted(values)[-1] for values in groups.values()) return prefixify(unify(authorify(title))).strip() @classmethod def clean_artists(cls, artists): return filter( lambda artist: artists != u'<Indéterminé>', map(lambda artist: ' '.join(artist.split(',')[::-1]).strip(), artists)) class MemoriesMusics(MemoriesBaseModel): class Meta: db_name = 'mmr_musics' # ensure that tables exists Config.db().create_tables( [MemoriesMovies, MemoriesTvs, MemoriesComics, MemoriesMusics], safe=True)