X-Git-Url: http://git.shiar.nl/sc2-widget/blobdiff_plain/eb6cb3960944b606e29f95c071450ee0cd3afe14..237a31256a99e3a8658febac9ee727ef00a24012:/getsc2clan diff --git a/getsc2clan b/getsc2clan index b23d2ac..498d0a3 100755 --- a/getsc2clan +++ b/getsc2clan @@ -8,21 +8,21 @@ use LWP::Authen::OAuth2; use JSON qw( decode_json ); use List::Util qw( all ); -my ($profileid, $clanmatch) = @ARGV; # clan host and name +my ($profileid, @clanmatches) = @ARGV; # clan host and names $profileid and $profileid =~ /\A\d+\z/ - or die "Usage: $0 []\n"; + or die "Usage: $0 [...]\n"; +my ($clanmatch) = map { $_ && qr/\A(?:$_)\z/i } join '|', @clanmatches; -my $bliz = LWP::Authen::OAuth2->new( - client_id => '7f0f95ac9529474f854ee8d68a12c3e0', - client_secret => 'Kfa8n98UAaDo4brOeqxe9C2kJE9pqpSd', - token_endpoint => 'https://us.battle.net/oauth/token', +my %auth = do './.blizzard.passwd.pl' or die "no auth setup: $!\n"; +my $bliz = LWP::Authen::OAuth2->new(%auth, + token_endpoint => 'https://eu.battle.net/oauth/token', request_required_params => [qw( client_id client_secret grant_type )], ); $bliz->request_tokens(grant_type => 'client_credentials'); sub blizget { my $args = join('/', @_); - my $res = $bliz->get("https://us.api.blizzard.com/sc2/$args"); + my $res = $bliz->get("https://eu.api.blizzard.com/sc2/$args"); $res->is_success or die $res->status_line; my $json = $res->decoded_content; return decode_json($json); @@ -38,7 +38,7 @@ my @ladders = ( } # activity desc grep { !$clanmatch or - all { fc $_->{clanName} eq fc $clanmatch } $_->{characters}->@* + all { $_->{clanName} =~ $clanmatch } $_->{characters}->@* } # members grep { $_->{ladder}->[0]->{division} } $ladderdata->{currentSeason}->@*