Skip to content

{Ignore/Remove Redundancy} + {Condition for Directory} #7183

Closed Answered by mikf
alfa-147 asked this question in Q&A
Discussion options

You must be logged in to vote

You need to apply repl/REPLACEMENTS to all relevant tags first and then do the dict.fromkeys step.

I've slightly modified the transform function from #7183 (comment) here to filter out duplicates:

REPLACEMENTS = {
    "mori_calliope_ch."  : "HOLOLIVE",
}

def transform(data, func, src, dst=None):
    if dst is None:
        dst = src

    value = data.get(src)
    if not value:
        data[dst] = ""
    elif isinstance(value, (list, tuple)):
        uniq = dict.fromkeys(func(e) for e in value)
        data[dst] = list(uniq)
    else:
        data[dst] = func(value)


def repl(v):
    return REPLACEMENTS.get(v, v)

def replace(metadata):
    transform(metadata, repl, "tags_copyright")
    r…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@alfa-147
Comment options

@alfa-147
Comment options

@alfa-147
Comment options

@mikf
Comment options

mikf Apr 11, 2025
Maintainer

Answer selected by alfa-147
@alfa-147
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants