WoW supports addons (coded in lua) that enchance the UI and help with gameplay.
These addons can need updating frequently, and once you have a few it can become tedious to keep them all up to date (or annoying on patch day when a few of them break.).
To solve this problem some addons have their own updaters, or rss feeds for updates - This can still be annoying as you have updaters for loads of addons that you need to run at once, and some addons don't provide this ability.
Another problem which affected me is that these updaters are all windows based (obviously, the game is for windows) and whilst they could probably run in wine, its still not an optimal situation.
To get round this problem, I decided to make a php script that can check the popular sites (Curse, WoWInterface) etc for updates to addons, and download them automatically.
My solution is a php script that can be found
here.
All addons have a special file called a "toc file". This file contains information about the addon (Name, Dependancies, files to use) that the wow client uses to make the addon run.
Additionally most Addons also include a "Version" field in this file.
Once the script has been configured, it reads this toc file to find the current version, then it goes to the website that hosts the addon to find the current version. If these 2 versions do not match, the version from the website is downloaded.
Not all addons define the Version field (some prefer to put the version field into the Title field, eg [My Addon (2.0)]), or use a different internal version number than the verison number on the website (eg a SVN Revision internally, and a release version externally).
This causes a problem! How does the updater know if it needs to download the new version?
Answer: It doesn't.
In such cases, the first time the updater is run it will download the addon, assuming that it is out of date. However when addons are downloaded, their "toc file" is automatically updated with a field called "X-DF-Version" which will be set to the version number that was detected on the download site. Then in future the updater will use this value instead of the normal "Version" value when checking for updates.
Due to the fact WoWUI do not expose any form of version number for mods on their listing page, WoWUI mods are versioned based on the "Last Updated" date, and the "Download Size" combined (eg "184.84 kB16/05/2008")
This is not ideal (multiple updates in a day might not be picked up if its only a minor change that doesn't result in a different download size), so I reccomend trying to use an alternative source than WoWUI if using this updater.
Basic usage of the updater is quite simple, you add an "addAddon" line near the top, and then run it.
addAddon("Atlas", CURSE, "Atlas");
This tells the script the name of the addon is "Atlas", it is from Curse, and it is addon id "Atlas" at curse. (taken from http://wow.curse.com/downloads/wow-addons/details/Atlas.aspx)
addAddon("AtlasLoot Enhanced", CURSE, "AtlasLoot-Enhanced", "AtlasLoot");
This tells the script the same information as before (name, download location, ID), but also contains an extra bit of information, the name that the addon uses for the WoW Client.
The first field (The name of the addon) must match the description on the addon page, the fourth field must match the name of the folder the addon uses in the Interface/AddOns directory. These are often different!
addAddon("Grimoire Keeper", CURSE, "Grimoire-Keeper", "GrimoireKeeper", array("FileVersionRegex" => "/## Title: GrimoireKeeper (.*)/"));
This has all the field of the last example, but also contains a new field used for advanced usage.
As mentioned before, some addons put their version in the Title field, Grimoire Keeper is one of them.
The updater uses
Regular Expressions to do most of its work, finding the version from the TOC is one of these. Normally it will look for the "Version" field (or X-DF-Version) but you may want to include this to stop it downloading the addon needlessly the first time it is run. (After the first run this change isn't really needed, as X-DF-Version takes priority over other methods of getting the Version)
This addon is no longer required, but is used here mearly as an example
addAddon("CTMod", CUSTOM, 0, "CT_Core",
array("downloadurl" => "http://www.ctmod.net/media/packages/Advanced.zip",
"custom_url" => "http://www.ctmod.net/downloads/",
"custom_versionregex" => "/<b>This package contains:<\/b> CT_Core v(.*?),/",
"FileVersionRegex" => '/^## Version: (.*) \(.*$/i'));
This is one of the most advanced examples of usage (and also most prone to breaking, if the design of the website changes or so).
This defines a few advanced fields:
- downloadurl
- This is the file that will be downloaded if the addon is out of date
- custom_url
- This is the web page that will be checked to get the current version (and/or download url) of the addon
- custom_versionregex
- This is the regular expression used to find the current version
FileVersionRegex is also defined to get the right version.
addAddon("FeedOMatic", CUSTOM, 0, "GFW_FeedOMatic",
array("custom_url" => "http://fizzwidget.com/notes/feedomatic/feed",
"custom_versionregex" => "/<title>Feed-O-Matic (.*?)<\/title>/",
"custom_downloadregex" => "/<enclosure url=\"(http:\/\/fizzwidget.com\/downloads\/.*?)\" length/"));
This is included here to show an alternative to "downloadurl", "custom_downloadregex" can also be used to extract the download URL from the page.
Any usage questions can be directed to
wow-updater@dataforce.org.uk