#!/usr/bin/perl use strict; use warnings; use utf8; use JSON; use Date; use Date::Parse; # use UTF-8 when writing to STDOUT binmode(STDOUT, ":encoding(utf8)"); sub yes_or_no { my ($boolean) = @_; return($boolean eq "1" ? "Yes" : "No"); } my $listings = decode_json(`curl "https://roisindubh.net/remote/searchlistings.json"`)->{results}; print(" Róisín Dubh Listingshttps://roisindubh.net/listings/"); foreach my $listing (@$listings) { my $event_date = str2time($listing->{event_date_time}); # only print data if event data is in the future if ($event_date > Date::now()) { print(" <![CDATA[" . $listing->{pagetitle} . "]]> https://roisindubh.net/listings/" . $listing->{alias} . " " . Date::strftime("%a, %d %b %Y %H:%M:%S %z", $event_date) . " {introtext} . " " . $listing->{content} . " ]]> Location: " . $listing->{name} . " Event start time: " . Date::strftime("%Y-%m-%d %a %H:%M:%S", $event_date) . " Late night?: " . yes_or_no($listing->{late_night}) . " Postponed?: " . yes_or_no($listing->{postponed}) . " Ticket Price: €" . $listing->{prices}->{regular} . " Ticket Allocation: " . $listing->{ticket_allocation} . " Tickets remaining?: " . yes_or_no($listing->{ticket_remaining}) . " Sales start time: " . Date::strftime("%Y-%m-%d %a %H:%M:%S", str2time($listing->{sales_start})) . " On Sale?: " . yes_or_no($listing->{on_sale}) . " "); } } print("");