diff options
Diffstat (limited to 'cgi-bin/playlist')
| -rwxr-xr-x | cgi-bin/playlist | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/cgi-bin/playlist b/cgi-bin/playlist new file mode 100755 index 0000000..9b87d6a --- /dev/null +++ b/cgi-bin/playlist @@ -0,0 +1,81 @@ +#!/usr/bin/perl + +use localbucky; +use URI::Escape; + +$dbh = DBI->connect ($dsn); + +our ($USER, $lastlog) = checkin(); +our $loggedin = ($USER != -1); + +our ($t, $kw, $files) = playlist_init(); +playlist_run($t, $kw, $files); + +sub playlist_run + { + my ($t, $kw, $files) = @_; + my $sorty = sub { sort {lc($a->{filename}) cmp lc($b->{filename})} @_ }; + + my $z_title = $t->{title}; + my $z_link = qq($BUCKY/).details_link().qq(/$t->{id}); + $z_link .= get_revision($t) if ($USER != -1); + + my $rss = <<__RSS__; +<rss version="2.0" xmlns:media="http://"> +<channel> +<title>$z_title</title> +<link>$z_link</link> +__RSS__ + + foreach my $file ($sorty->(@$files)) + { + next if (($file->{username} ne $USER->{username}) && $file->{private} && !$whitelist && $USER->{ulevel} != 3); + next unless ($file->{filename} =~ /mp3$/i); + my $z_file = $file->{filename}; + my $z_filepath = uri_escape($file->{filename}); + my $z_content = "https://$BUCKY_HOST$live_path/$file->{thread}/$z_filepath"; + $rss .= <<__RSS__; +<item> +<title>$z_file</title> +<link>$z_content</link> +<description></description> +<media:content url="$z_content" type="audio/mpeg" /> +</item> +__RSS__ + } + + $rss .= "</channel>\n</rss>\n"; + + print "Content-type: text/xml\n\n"; + $rss =~ s/&/&/g; + print $rss; + } + +sub playlist_init + { + $input->{id} ||= $input->{object_from_uri} if defined($input->{object_from_uri}); + my $id = exists($input->{id}) ? $input->{id} : error("No such thread!"); + + my $t = get_thread($id); + error("No such post.") if ($t == -1); + my $kw = get_keyword($t->{keyword}); + + my $files = get_files($t->{id}); +# my $comments = get_comments ($t->{id}); + + if ( ! check_privacy($t, $kw) ) # || check_participation($files, $comments) ) + #unless ( check_privacy($t, $kw) || check_participation($files, $comments) ) + { error("No such post!"); } + + # Reset NULL viewed + if ( ! $t->{viewed} ) + { $t->{viewed} = 0; } + + # Increment viewed for this thread +# $t->{viewed}++; + # Update thread viewed count +# update_thread_viewed( $t->{id}, $t->{viewed} ); + + return ($t, $kw, $files); # $comments); + } + |
