diff --git a/roisin_dubh_listings.pl b/roisin_dubh_listings.pl new file mode 100755 index 0000000..663ffb4 --- /dev/null +++ b/roisin_dubh_listings.pl @@ -0,0 +1,58 @@ +#!/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(Date::FORMAT_ISO8601, $event_date) . " + + + {introtext} . " + + " . $listing->{content} . " + ]]> + + Location: " . $listing->{name} . " + Event start time: " . $listing->{event_date_time} . " + 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: " . $listing->{sales_start} . " + On Sale?: " . yes_or_no($listing->{on_sale}) . " + + + "); + } +} +print("");