Skip to content

Instantly share code, notes, and snippets.

@thirdratecyberpunk
Created September 27, 2021 23:20
Show Gist options
  • Save thirdratecyberpunk/98cfb9738c93fa1a4bcb417b3257f71f to your computer and use it in GitHub Desktop.
Save thirdratecyberpunk/98cfb9738c93fa1a4bcb417b3257f71f to your computer and use it in GitHub Desktop.
MyAnimeList export file to Letterboxd format
"""
Takes in a given MAL export file and generates a list of movies
in .csv format supported by LetterBoxd
"""
import xmltodict
import json
import pandas as pd
allowed_types = ["Movie", "OVA"]
# Read the XML file
with open("your_anime_list.xml", "r") as file:
# convert to a JSON
# I swear this was easier, it's like MAL was using xml
# as JSON
data_dict = xmltodict.parse(file.read())
file.close()
# find all anime that is a) completed and b) a movie
# could make this also find OVAs/series but I'm using LetterBoxd
# for movie tracking
# find all anime tags
anime = data_dict.get("myanimelist").get("anime")
# filter if they're completed and in the type of shows we're allowing
completed_movies = [[a.get("series_title"), a.get("my_score"), a.get("my_finish_date")] for a in anime if (a.get("my_status") == "Completed") and (a.get("series_type") in allowed_types)]
# populate the .csv file with the appropriate movies
df = pd.DataFrame(completed_movies, columns=["Title", "Rating10","WatchedDate"])
# save to csv file
df.to_csv("letterboxd_anime.csv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment