summaryrefslogtreecommitdiff
path: root/lib/RHRD/utils.pm
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-07-19 21:29:55 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-07-19 21:29:55 (GMT)
commit93236a4721a7cddaa0f553c76c69db80b19f35e5 (patch)
tree98dda866b42e846fe4a7a904566a7e48e1f5e99d /lib/RHRD/utils.pm
parent6a554f641a37af28a668cc938430a683c37247ef (diff)
add optional uri queries to fetch_parse_json
Diffstat (limited to 'lib/RHRD/utils.pm')
-rwxr-xr-xlib/RHRD/utils.pm10
1 files changed, 8 insertions, 2 deletions
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;