From 93236a4721a7cddaa0f553c76c69db80b19f35e5 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Tue, 19 Jul 2016 23:29:55 +0200 Subject: add optional uri queries to fetch_parse_json diff --git a/lib/RHRD/utils.pm b/lib/RHRD/utils.pm index f3a76bf..b08705d 100755 --- a/lib/RHRD/utils.pm +++ b/lib/RHRD/utils.pm @@ -29,6 +29,7 @@ use DateTime::TimeZone; use LWP::Simple; use URI::Fetch; use JSON::MaybeXS; +use URI::QueryParam; sub get_rd_week { @@ -161,11 +162,16 @@ sub cmdline_dow sub fetch_parse_json { - my ($url, $ua_str, $headers) = @_; + my ($url, $ua_str, $headers, $queries) = @_; my $uri = URI->new($url); - $ua_str = "Radio Helsinki Rivendell Utilities" unless $ua_str; + if (defined $queries) { + while(my ($name, $value) = each %{$queries}) { + $uri->query_param($name => $value); + } + } + $ua_str = "Radio Helsinki Rivendell Utilities" unless $ua_str; my $ua = LWP::UserAgent->new; $ua->agent($ua_str); $ua->env_proxy; -- cgit v0.10.2