This script is intended to be used for migrating from MyAnimeList to your own Jekyll based site. Export your anime list there, and adapt the script to point to the right directory.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python3

import re
import xml.etree.ElementTree as ElementTree


def main():
    # update the paths here
    xml_path = "/home/tyil/downloads/palemoon/animelist.xml"
    out_dir = "/home/tyil/projects/private/jekyll/tyil/_anime/"

    # open the xml file
    tree = ElementTree.parse(xml_path)
    root = tree.getroot()

    for anime in root:
        # skip your info
        if anime.tag == "myinfo":
            continue

        # clean up the file name
        f = re.sub("[?!:☆♪.,/]", "", anime.find("series_title").text)
        f = f.lower()
        f = f.replace(" ", "-")
        f = re.sub("-+", "-", f)

        # open the stream and write the front matter to it
        s = open(out_dir + f + ".md", "w")
        s.write("---\n")
        s.write("title: \"%s\"\n" % anime.find("series_title").text)
        s.write("episodes: %s\n" % anime.find("series_episodes").text)

        status = anime.find("my_status").text

        if status == "Plan to Watch":
            s.write("status: planned\n")

        if status == "Watching":
            s.write("status: watching\n")
            s.write("progression: %s\n" % anime.find("my_watched_episodes").text)

        if status == "Completed":
            s.write("status: completed\n")
            s.write("rating: %s\n" % anime.find("my_score").text)

        s.write("---\n")
        s.close()

if __name__ == '__main__':
    main()