Log in

User:LordHelmchen

LHpi is LordHelmchen's price import library and sitescripts for Magic Album.

LHpi is a collection of lua scripts to be used by Magic Album, but is not part of Magic Album and thus updated and supported seperately.

Discuss, ask for help and leave feedback at the corresponding Forum Thread.

Contents

Sitescripts

The sitescripts are the actual price import scripts, written in lua. They use the Magic Album Lua API and the LHpi library to query and parse a website and import the price information into Magic Album. Most of the program logic is contained in the library, so the sitescript needs to hold only site-specific information and a few functions that are not easily generalizable.

In theory, you should not be dependent on a new version once a new set is available: just add new entries to site.sets table in the sitescript. Being easy to update yourself was one of the design goals.

Sitescripts will need to provide

  • a table of supported sets with language and url infix fields
  • a table of supported languages with url infix field
  • a function to build urls
  • a function to parse the html raw data into data fields via regular expressions (and the regex itself)
  • optionally, they can also provide
    • functions for site specific data manipulation, in case the site has some strange formatting the library does not understand
    • a one-to-one name map for names that differ between the site and Magic Album's database
    • tables to map card names to picture versions, in case the one-to-one map and LHpi's defaults are not sufficient
    • a table with expected card count numbers for LHpi's sanity checks.

magicuniverse.de

Sitescript version 2.1
used LHpi version 2.1
updated last on 2013-04-10
size kB

[www.magicuniverse.de/html/einzelkarten.php?menue|Magic Universe] is a German site with German and English cards, priced in €.

This site started it all, since I wanted prices in local currency, and my FLG apparently uses them as price reference.

mtgmintcard.com

Sitescript version 2.1
uses LHpi version 2.1
updated last on 2013-04-10
size kB

Functionally the same as "MTG Mint Card.lua" by Goblin Hero and Stromglad1.

When I wanted to generalize my script for easy addaption to other sites, this provided me with a good baseline, since I could search MA for cards that my script missed but should have set. Also, the site is easy to querry and parse. They do have a currency chooser, so I started by trying to make a mtgmintcard-Euro script. I failed, but salvaged the wreck for default $ prices.

magic.tcgplayer.com PriceGuide

Sitescript version 2.1
uses LHpi version 2.1
updated last on 2013-04-10
size kB

Price Guide claims to accumulate prices from 75 online vendors. They are priced in $. Their tables give a high, low and average price; the sitescript contains a variable to select which one of those it should use.

As requested by Golob [1]. I have only adjusted the syntax of his avsets to LHpi. and added the card count expectations table. Also, Promo and most special sets have not been tested yet and are commented out.

trader-online.de

Sitescript version 2.0
uses LHpi version 2.1
updated last on 2013-04-10
size kB

Online is a German site with German and English cards, priced in €.

I found this site while looking for Token images, found it to be parseable by sitescript, and decided to use it as a test on how well the library was adapted to support additional sites.

The LHpi Library

Library version 2.1
Tested with Ma version 1.5.2.264
updated last on 2013-04-10
size kB

The LHpi library is a lua script that uses the Magic Album Lua API and can be used by LHpi sitesccripts.


It is not expected to be fast, but as reliable as possible:
It first compares the user requested sets and languages with what the sitescript has available and builds a table of urls to querry, seperated by set.
Then it loops though the sets that are both available and selected:
The raw html data is fetched, parsed and entered into an intermediate table of all prices for the current edition, merging regular and foil prices to minimize calls to ma.SetPrice.
Should the same card (defined by set,card,language,(picture-)version ) be encountered again, it compares the prices. If they are equal, the new price is discarded; if they differ (Yes, magcuniverse.de's database is quirky), it uses the average price. Cards that are suffxed with a condition description are currently disregarded.
Once that cardsetTable is completed (all urls belonging to the set are parsed), it sends the prices to MA. Finally, it compares the count of set prices with the number of cards in the set (or, if given, the expectation given in the sitescript).

Installation

  1. Download at least one sitescript and the LHpi libray version the sitescript uses.
  2. Unzip into the "Prices" subdirectory of your Magic Album installation.
  3. mark the sitescript (not the library) from Magic Album's Price Manager dialog.

version history

I decided to start all versions at 2.0, since it's the continuation of magicuniverseDEv1.6.lua, but with enough changes to varant the next major version number. Do not expect revision numbers to stay synched. The sitescripts will know which library version they need and attempt to load the right one or exit gracefully.

LHpi lib

magicuniverseDE

mtgmintcard

tcgplayerPriceGuide

trader-onlineDE

License

The LHpi library and all sitescripts are released as open source under the [General Public License].

Other scripts

Just for refference: These unrelated pricing scripts exist

  • "MTG Mint Card.lua" by Goblin Hero and Stromglad1 is included with Magic Album as a working script example.
  • "Import Prices" by woogerboy21.