Credit sequence/Credits

Minecraft Wiki article. Categories: Game_terms

📌 Mirrored from Minecraft Wiki

This article is reproduced from Credit sequence/Credits on the Minecraft Wiki. Mirrored from revision 3710429. It is licensed CC BY-NC-SA 3.0 by the Minecraft Wiki contributors — not under the Codex’s CC BY-SA 4.0, and it may not be used commercially. Edits belong upstream, not here.

This template was generated by the following Python code, assuming credits.json is the Java or Bedrock credits file and api-result.json from this query are located in the current directory.

Known names are taken from Special:WhatLinksHere/Template:Infobox person.

import json

TEMPLATE_START = "{{:Credit_sequence/Credits/Part"
known_names = ["4J Studios"]
credits = []

with open("credits.json", encoding="utf-8") as f:
    credits = json.load(f)

# api-result.json saved from
# https://minecraft.wiki/api.php?action=query&prop=transcludedin&pageids=5530&tinamespace=0&tilimit=500&format=json
with open("api-result.json", encoding="utf-8") as f:
    known_names.extend(i["title"] for i in json.load(f)["query"]["pages"]["5530"]["transcludedin"])

with open("credits.mediawiki", "w", encoding="utf-8") as f:
    f.write("{{collapse|title=<h3>Credits transcript</h3>|content={{scrollable container|height=500px|\n")

    for section in credits:
        s_name = section["section"]
        assert s_name != ""
        f.write(f"{TEMPLATE_START}|section={s_name}|disciplines=\n")

        for discipline in section["disciplines"]:
            d_name = discipline["discipline"] or "no"
            f.write(f"  {TEMPLATE_START}|discipline={d_name}|titles=\n")

            for title in discipline["titles"]:
                t_name = title["title"] or "no"
                f.write(f"    {TEMPLATE_START}|title={t_name}|names=\n")

                for name in title["names"]:
                    match name.split(" (", maxsplit=1):
                        case [name]:
                            if name in known_names:
                                name = f"[[{name}]]"
                        case [name, company]:
                            if name in known_names:
                                name = f"[[{name}]]"
                            name = f"{name} ({company}"  # undo the split
                        case _:
                            raise ValueError("Unexpected")

                    f.write(f"      {TEMPLATE_START}|name={name}}}}}\n")

                f.write("    }}\n")

            f.write("  }}\n")

        f.write("}}\n")

    f.write("}}\n")
    f.write("}}\n")

Sources