#!/usr/bin/perl
##
# File : get_modo_artids.pl
# Date : 12/Nov/2017
# Author : spjspj
# Purpose : Get the artid for each face art of each card from modo (mtgo)
# this then goes into some form of image such as:
# http://mtgoclientdepot.onlinegaming.wizards.com/Graphics/Cards/Pics/161922_typ_reg_sty_050.jpg
# "" /00100_typ_reg_sty_001.jpg
# "" /01440_typ_reg_sty_010.jpg
# "" /102392_typ_reg_sty_010.jpg
# "" /400603_typ_reg_sty_050.jpg
# This program expects that you've copied the relevant .xml files from an installation of mtgo
# into the current working directory for this perl script:
# For example: CARDNAME_STRING.xml, client_BNG.xml,
# Also, it expects to be running on windows
##
use strict;
use LWP::Simple;
use POSIX qw(strftime);
# From xmage code - fix from MODO to XMAGE type set codes
my %fix_set_codes;
$fix_set_codes {"2U"} = "2ED";
$fix_set_codes {"3E"} = "3ED";
$fix_set_codes {"4E"} = "4ED";
$fix_set_codes {"5E"} = "5ED";
$fix_set_codes {"6E"} = "6ED";
$fix_set_codes {"7E"} = "7ED";
$fix_set_codes {"AL"} = "ALL";
$fix_set_codes {"AP"} = "APC";
$fix_set_codes {"AN"} = "ARN";
$fix_set_codes {"AQ"} = "ATQ";
$fix_set_codes {"CM1"} = "CMA";
$fix_set_codes {"DD3_DVD"} = "DVD";
$fix_set_codes {"DD3_EVG"} = "EVG";
$fix_set_codes {"DD3_GLV"} = "GLV";
$fix_set_codes {"DD3_JVC"} = "JVC";
$fix_set_codes {"DK"} = "DRK";
$fix_set_codes {"EX"} = "EXO";
$fix_set_codes {"FE"} = "FEM";
$fix_set_codes {"HM"} = "HML";
$fix_set_codes {"IA"} = "ICE";
$fix_set_codes {"IN"} = "INV";
$fix_set_codes {"1E"} = "LEA";
$fix_set_codes {"2E"} = "LEB";
$fix_set_codes {"LE"} = "LEG";
$fix_set_codes {"MI"} = "MIR";
$fix_set_codes {"MM"} = "MMQ";
$fix_set_codes {"MPS_KLD"} = "MPS";
$fix_set_codes {"NE"} = "NEM";
$fix_set_codes {"NE"} = "NMS";
$fix_set_codes {"OD"} = "ODY";
$fix_set_codes {"PR"} = "PCY";
$fix_set_codes {"PS"} = "PLS";
$fix_set_codes {"P2"} = "PO2";
$fix_set_codes {"PO"} = "POR";
$fix_set_codes {"PK"} = "PTK";
$fix_set_codes {"ST"} = "STH";
$fix_set_codes {"TE"} = "TMP";
$fix_set_codes {"CG"} = "UDS";
$fix_set_codes {"UD"} = "UDS";
$fix_set_codes {"GU"} = "ULG";
$fix_set_codes {"UZ"} = "USG";
$fix_set_codes {"VI"} = "VIS";
$fix_set_codes {"WL"} = "WTH";
# Main
{
my $card = $ARGV [0];
# Example: Abandoned Sarcophagus
my $vals = `find /I "CARDNAME" *CARDNAME*STR*`;
my %ids;
my %set_names;
my $count = 0;
while ($vals =~ s/^.*CARDNAME_STRING_ITEM id='(.*?)'>(.*?)<\/CARDNAME_STRING.*\n//im)
{
$ids {$1} = $2;
$count++;
}
print ("Finished reading $count names\n");
#$vals = `find /I "<" *client*`;
$vals = `findstr /I "CARDNAME_STRING DIGITALOBJECT ARTID CLONE FRAMESTYLE " *lient* | find /I /V "_DO.xml"`;
my $current_artid = "";
my $current_clone_id = "";
my $current_doc_id = "";
my $current_line = "";
my $current_name = "";
my $current_set = "";
my $num_set = 1;
my %docid_to_clone;
while ($vals =~ s/^(.*)\n//im)
{
my $line = $1;
$line =~ m/^client_(.*)?\.xml/;
$current_set = $1;
# *** IN
# *** IN
#
# *** IN
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
if ($line =~ m/