Wiktor's Website


Archiving and viewing anime/manga lists with python

Note: you need an MyAnimeList.net account and a web browser where you're logged to it for this to work, and python obviously.

Downloading your list from MAL is pretty tiresome task, you need to go to the specific url, manually pick each type of list, then download it and you are left with a 2 gzip files with very long filenames, that's especially painsome when you want to do this daily or whenever you update it.
Fortunately there is a way to automate it, the following python script let's you conveniently download your anime and manga lists, rename them to something readable by human, put them into single .tar archive and move them to specified directory.

Installation apt install python3 python3-pip curl
pip install browser_cookie3 BeautifulSoup4
curl -Lo mal-archive.py wiktor.in/anime/mal-archive.txt -Lo mal-show.py wiktor.in/anime/mal-show.txt
chmod +x mal-archive.py mal-show.py

Now we can use the script:

How output looks when running the script

There's nothing really much to configure here, however, you might want to change the directory where your lists save, date format and a web browser if you're using something other than firefox, this can be easily done by editing variables like animelist_path, current_date and cookies at the top of the script. Here you can see what browser are supported with the module used there.


Now, let's say that we want to view our list, the problem is, .xml format was made to be read by a computer, so it would be nice to convert our list to something readable by human, and python will help us with that too. This script parses .xml list files and prints our anime/manga from best to worst rated (You need to use anime or manga as an argument):

How output looks when running the script

If you've changed date format/path in the first script make sure to change that here too!
The advantage of this script is that it prints completed anime/manga to the standard output, so you can combine it with basic command-line utilities and operators such as:

mal-show.py anime | wc -l         # Show how many anime you have completed
mal-show.py anime | grep -i jojo  # Find specific entries
mal-show.py anime | less          # View in less
mal-show.py anime | grep -E '(8/10|9/10|10/10)'  # List entries rated 8/10+
mal-show.py anime > anime.txt     # Save your list to a text file

Update 28-05-2024:

I made an extended version of a mal-show script, this one let's you customize the output more by adding additional arguments. The simple version above of course still works. You can download it here.

You can access help by typing mal-showex -h (or --help):

How output looks when running the script

Usage examples:

mal-showex.py -Acs # Show completed anime along with scores
mal-showex.py -Aoe # Show on-hold anime along with episodes watched
mal-showex.py -Mre # Show currently reading manga along with chapters read
mal-showex.py -Acwodp # Show all anime you have in your list