From e76b691e78e273226cba9284cb8cd22a423319ed Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 2 Aug 2013 17:23:25 -0500 Subject: bucky2 --- bucky2/cgi-bin/api/index | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 bucky2/cgi-bin/api/index (limited to 'bucky2/cgi-bin/api/index') diff --git a/bucky2/cgi-bin/api/index b/bucky2/cgi-bin/api/index new file mode 100755 index 0000000..306e01e --- /dev/null +++ b/bucky2/cgi-bin/api/index @@ -0,0 +1,40 @@ +#!/usr/bin/perl + +use lib "../../lib"; +use Bucky; +use Bucky::Session; +my $bucky = new Bucky; +# my $session = new Bucky::Session; + +print "Content-type: text/plain\n\n"; + +# get most recent 80 threads +# for each thread, get most recent mp3 +# if no mp3, skip the thread + +my $threads = $bucky->db->select("thread", "order by lastmodified desc limit 80"); + +foreach my $t (@$threads) + { + my $z_thread = $t->{id}; + my $files = $bucky->db->select("file", "thread='$z_thread' and filename like '%mp3' order by date limit 1"); + my $file = {id=>undef,filename=>undef}; + if ($files) + { + $file = $files->[0]; + } + + my $z_title = $bucky->trim( $t->{title} ); + my $z_file = $file->{'id'}; + my $z_subtitle = $file->{'filename'}; + $z_subtitle =~ s/[^a-zA-Z0-9 ()\.]/ /g; + $z_subtitle =~ s/_/ /g; + $z_subtitle =~ s/\s+/ /g; + $z_subtitle =~ s/^\s//; + $z_subtitle =~ s/\s$//; + print join "\t", $z_thread, $z_title, $z_subtitle, $z_file; + print "\n"; + } + +1; + -- cgit v1.2.3-70-g09d2