View Single Post
02/18/22, 01:00 AM   #1
Messajah
AddOn Author - Click to view addons
Join Date: Feb 2022
Posts: 11
Arrow [Program] Minion Addon List Exporter

This was just a quick and dirty creation today since I needed to export a human-readable list of all my addons.

It reads your minion.xml file for your list of currently installed addons, and retrieves the names and URLs of each, and then outputs it in alphabetical order. You can easily pipe it into a text file for saving.

Most importantly: The addon names (and URLs) are all fetched directly from ESOUI, which means that your friends can effortlessly copy-paste each exact addon title and find it in Minion. And if they're unsure which exact addon you meant, then they can just click "Visit Webpage" in Minion to find the one whose URL matches the list you gave them.


It's written with native Python 3 libraries for maximum portability since it doesn't have any external dependencies.

Those that know how to use Python already know how to use it. Anyone else, feel free to ask those that do.

If anyone wants to develop this further, feel free to take the code/inspiration and do whatever you want with it! I just needed a quick little tool, so my work here is done and no further support will be provided at all.


How to Use:

1. Install Python if you don't have it already.

2. Save this script (code below) as C:\Users\YourNameHere\.minion\export_minion_addons.py (important, but replace "YourNameHere" with your actual username).

3. Open a PowerShell/Command Prompt window, type cd "C:\Users\YourNameHere\.minion" to navigate to the folder.

4. Run it with this command: python export_minion_addons.py

5. If you want to save the output to a file directly, run it with this command: python export_minion_addons.py > my_addon_list.txt (will save it to "my_addon_list.txt" in the minion folder).

That's the extent of tutorial I have energy to provide here. It probably took longer to write this text than the actual tool itself.


Alright, here's the code:

Code:
# Minion Addon List Exporter v1.0 by Messajah
# Project Page: https://www.esoui.com/forums/showthread.php?t=10077

from urllib.request import urlopen, Request
from xml.dom import minidom
import re


installed_addons = {}

with minidom.parse("minion.xml") as dom:
    minion = dom.getElementsByTagName("minion")[0]
    games = minion.getElementsByTagName("games")[0]
    for game in games.getElementsByTagName("game"):
        if game.getAttribute("game-id") != "ESO":
            continue

        print("Fetching Minion addon information from ESOUI.com...")

        addons = game.getElementsByTagName("addons")[0]
        for addon in addons.getElementsByTagName("addon"):
            uid = addon.getAttribute("uid")
            assert isinstance(uid, str) and len(uid) > 0, "uid must be a non-empty string"

            print(".", end="", flush=True)  # Progress indicator.

            r = urlopen(
                Request(
                    f"https://www.esoui.com/downloads/download{uid}",
                    data=None,
                    headers={
                        "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.85 Safari/537.36"
                    },
                )
            )

            body = r.read()
            assert isinstance(body, bytes), "expected a bytes object when reading webpage"
            body = body.decode("iso-8859-1")  # Yeah, ESOUI uses this ancient text encoding from the year 1985... haha.
            assert isinstance(body, str) and len(body) > 0, "esoui data must be a non-empty string. webpage download failed?"

            # Look for the info-page link to figure out the official addon URL and full title.
            # Example: <a href="info1703-CircularVotansMiniMap.html">Circular Votan's Mini Map</a>
            m = re.search(r"<a href=\"(info\d+-.+?\.html)\">(.+?)<\/a>", body)
            assert m, "unable to extract addon information from fetched webpage"

            title = m.group(2)
            url = f"https://www.esoui.com/downloads/{m.group(1)}"

            installed_addons[url] = title


print("\n\n\n--- Installed Addons: ---\n")

# Present the addon list alphabetically.
for addon in sorted(installed_addons.items(), key=lambda x:x[1]):
    print(f"## {addon[1]}\n{addon[0]}\n")

print("--- End of Addon List ---\n")


Example Output: See next message below.

Last edited by Messajah : 02/18/22 at 09:38 AM.
  Reply With Quote