wow-addon-updater icon indicating copy to clipboard operation
wow-addon-updater copied to clipboard

Support Zygor Guides

Open Technifocal opened this issue 5 years ago • 2 comments

This is a feature request to support Zygor Guides. While they do support Windows, Mac and Linux, having all my addons updated via a single solution automatically upon launching WoW (instead of having clients running in the background) is vastly preferred.

These are the following API calls available, from what I can tell. As these guides are not free of charge, you will need credentials (I have not tested on a free account). That said, some of the end points return data even without credentials (notably the hourly gold endpoint).

Zygor's API

AddOn and Guides

Get current addon version

GET https://data.zygorguides.com/updater/packager.php?do=query&user=${zygorUsername}&pass=${zygorPassword}

Response:

LOGIN OK
USER redacted redacted
ACCESS ELITE redacted redacted redacted redacted
VER 7.0.21656
PRODUCT sub-elite Zygor Elite Membership
PRODUCT levl-elite - Leveling & Loremaster
PRODUCT dung-elite - Dungeons & Gear
PRODUCT dair-elite - Dailies & Reputation
PRODUCT golp-elite - Gold & Professions
PRODUCT petm-elite - Pets & Mounts
PRODUCT tita-elite - Titles & Achievements
PRODUCT gold - Gold Auction Data
REM product list faked for elite
PRODUCTDIR ZygorGuidesViewer
CHG:
PROFESSIONS<br />
[B] Updated Jewelcrafting 1-300 - Fixed item ID for Delicate Copper Wire.<br />
<br />
EVENT<br />
* Set Lunar Festival quest guide as the current event trial guide.<br />

:CHG
END

The only data you need to parse is the LOGIN OK, VER and PRODUCTDIR (for the gold guide) lines.

Get addon

GET https://data.zygorguides.com/updater/packager.php?do=comp&user=${zygorUsername}&pass=${zygorPassword}

Gold realm data

Get realms

GET https://data.zygorguides.com/ahscan/realms-eu

Format seems to be: realmID|realmHumanName|connectedRealmId1,connectedRealmId2,connectedRealmId3

Accepted regions are:

  • eu
  • us
  • tw
  • kr
  • xx (with the only realm being Global), this is for all global data and should be installed regardless of the user's specified realm.

There may be more, but I'm on EU so :man_shrugging:

Get daily(? - I think) last update time

GET https://data.zygorguides.com/ahscan/?do=check&region=eu&realm=aerie-peak

Region and realm need to be replaced with the realms from the previous command

Get daily(? - I think) data

GET https://data.zygorguides.com/ahscan/?do=dump&region=eu&realm=aerie-peak&user=${zygorUsername}&pass=${zygorPassword}

This should then be saved into the AddOn directory under: PRODUCTDIR/Data/Gold/lowercase(regionID)_lowercase(realmID).lua

I.E. Interface/AddOns/ZygorGuidesViewer/Data/Gold/eu_aerie-peak.lua

You should then update PRODUCTDIR/Data/Gold/files.xml to include a child element to the Ui element as such:

<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/FrameXML/UI.xsd">
	<Script file="xx_global.lua" />
	<Script file="xx_global_h.lua" />
	<Script file="eu_aerie-peak.lua" />
	<Script file="eu_aerie-peak_h.lua" />
</Ui>

Get hourly last update time

Identical to the daily API command, but the URL is now https://data.zygorguides.com/ahscan/get_raw_data.php. For example:

GET https://data.zygorguides.com/ahscan/get_raw_data.php?do=check&region=eu&realm=aerie-peak

Get hourly data

Identical to the daily API command, but the URL is now https://data.zygorguides.com/ahscan/get_raw_data.php. For example:

GET https://data.zygorguides.com/ahscan/get_raw_data.php?do=dump&region=eu&realm=aerie-peak

This should then be written onto disk as: PRODUCTDIR/Data/Gold/lowercase(regionID)_lowercase(realmID)_h.lua `

I.E. Interface/AddOns/ZygorGuidesViewer/Data/Gold/eu_aerie-peak_h.lua

You should then update PRODUCTDIR/Data/Gold/files.xml to include a child element to the Ui element as such:

<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/FrameXML/UI.xsd">
	<Script file="xx_global.lua" />
	<Script file="xx_global_h.lua" />
	<Script file="eu_aerie-peak.lua" />
	<Script file="eu_aerie-peak_h.lua" />
</Ui>

Technifocal avatar Jan 27 '20 11:01 Technifocal

I ended up writing a class for Zygor, that said I'm really not happy with out it turned out (I don't usually program in Python). This is only for the guides, no gold (yet?):

import requests
import re
import urllib.parse

from updater.site.abstract_site import AbstractSite, SiteError
from updater.site.enum import GameVersion


class Zygor(AbstractSite):
    _URLS = [
        'https://zygorguides.com/',
    ]
    session = requests.session()
    def __init__(self, url: str, game_version: GameVersion):
        global actionUrl
        super().__init__(url, game_version)
        username = urllib.parse.quote_plus(url.split("/")[3])
        password = urllib.parse.quote_plus(url.split("/")[4])
        self.ENDPOINT = "https://data.zygorguides.com/updater/packager.php?user={username}&pass={password}&do={action}".format(username=username, password=password, action="{action}")

    def find_zip_url(self):
        return self.ENDPOINT.format(action="comp");

    def get_latest_version(self):
        try:
            page = Zygor.session.get(self.ENDPOINT.format(action="query"), headers={'User-Agent': 'wowaddonupdater'})
            page.raise_for_status()  # Raise an exception for HTTP errors
            content_string = str(page.content)
            main_version = re.findall(r"VER (?P<version>[\d\.]+)", content_string)[0];
            return main_version
        except Exception as e:
            print(e);
            raise self.version_error() from e
    def get_addon_name(self):
        return "ZygorGuides"

This also requires registration with site_handler.py and a user-agent added to addon_manager.py for get_addon_zip (as Zygor seems to block the standard python requests user-agent). Format for the addons.txt file is:

https://zygorguides.com/username/password

Main issues I see with it:

  1. Doesn't work with the gold module
  2. Has user-agent defined in-line, rather than a proper header object for the whole of wow-addon-updater(?)
  3. Doesn't work with classic (wouldn't be hard to implement)
  4. .format()s {action} with {action} which seems silly but my knowledge of Python is lacking
  5. Requires the username&password in plain text in your addons.txt file

That said, it does work.

Technifocal avatar Jan 27 '20 18:01 Technifocal

Hi @Technifocal thanks for swinging by

So, you're definitely the first person to request this, but it seems like you have a working solution for yourself. In my case, I would have no real way of developing or testing this on my own.

I think some of your issues could be fixed if I had a proper interface for a site to implement how to extract its contents to the filesystem, but I don't find too much motivation to rewrite that bit. :(

Anyways, nice job. If you continue to develop, open a PR and I can try to review it that way.

grrttedwards avatar Feb 04 '20 00:02 grrttedwards