define common region/realm request path
authorMischa POSLAWSKY <perl@shiar.org>
Wed, 21 Aug 2019 21:56:52 +0000 (23:56 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Wed, 21 Aug 2019 22:31:16 +0000 (00:31 +0200)
Name mysterious parameters used to access profile data.
Subdivision values are for Europe as documented on:
<https://develop.battle.net/documentation/guides/regionality-partitions-and-localization>

Remains hardcoded without support for configurable region
and adaptability for multiple realms (no Russian members yet).

getsc2clan

index cc38e4d9c1da9f84bd0c8cda0122421b61018fb9..02990826636280b35663c791a9d8872c883334c5 100755 (executable)
@@ -18,6 +18,7 @@ $profiles && @{$profiles}
        or die "Usage: $0 <profile id>... [<clan name>...]\n";
 my ($clanmatch) = map { $_ && qr/\A(?:$_)\z/i } join '|', @{$clanmatches || []};
 
+my @realmget = (profile => 2 => 1); # common request path for european data
 sub blizget {
        state $bliz = do {
                my @authdata = do './.blizzard.passwd.pl' and not $@ || $!
@@ -40,7 +41,7 @@ sub blizget {
 
 # prefer deprecated interface to prevent costly ladder search
 my @ladderdata = map {
-       blizget(legacy => profile => 2 => 1 => $_ => 'ladders')
+       blizget(legacy => @realmget => $_ => 'ladders')
 } @{$profiles};
 
 # merge relevant ladder data of all users
@@ -87,7 +88,7 @@ say JSON->new->canonical->pretty->encode({
                @ladders
        ],
        members  => [map {
-               blizget(metadata => profile => 2 => 1 => $_->{id})
+               blizget(metadata => @realmget => $_->{id})
                # lacks mmr, fav race (available in new api)
        } @members],
 }) =~ s/(?: \G \d,? | \[ ) \K \s+ (?=\d|\])/ /grx; # concat arrays of single digits