summaryrefslogtreecommitdiff
path: root/bucky2/cgi-bin/api/index
diff options
context:
space:
mode:
Diffstat (limited to 'bucky2/cgi-bin/api/index')
-rwxr-xr-xbucky2/cgi-bin/api/index40
1 files changed, 40 insertions, 0 deletions
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;
+