summaryrefslogtreecommitdiff
path: root/cgi-bin/playlists/album.pm
diff options
context:
space:
mode:
Diffstat (limited to 'cgi-bin/playlists/album.pm')
-rw-r--r--cgi-bin/playlists/album.pm197
1 files changed, 197 insertions, 0 deletions
diff --git a/cgi-bin/playlists/album.pm b/cgi-bin/playlists/album.pm
new file mode 100644
index 0000000..89f9273
--- /dev/null
+++ b/cgi-bin/playlists/album.pm
@@ -0,0 +1,197 @@
+package album;
+
+use Globals;
+use CGI;
+use Globals qw(%PLATTERS);
+use Globals qw(@CUSTOM);
+use Globals qw($delim);
+use strict;
+
+sub new {
+ my $self = {
+ mime => "text/html",
+ playlist => undef,
+ artist => undef,
+ coverCount => 0,
+ info => undef,
+ platter => undef,
+ currentAlbum => undef,
+ playlink => undef,
+ custom => undef,
+ foreign => undef
+ };
+
+ my $query = CGI::new();
+ my $target = $query->cookie("target");
+
+ if ( $target =~ /narrow/ )
+ {
+ $self->{playlist} = openTemplate("albumNarrow");
+ }
+ else
+ {
+ $self->{playlist} = openTemplate("album");
+ }
+
+ bless ($self);
+ return $self;
+}
+
+sub desc {
+ return "Used internally to build album views";
+ }
+
+sub header {
+ my $self = shift;
+ my ($artist, $album) = @_;
+ $self->{artist} = $artist;
+ $self->{album} = $album;
+ #print $artist;
+ foreach ( @CUSTOM ) {
+ if ($artist eq $_) {
+ $self->{custom} = 1;
+ last;
+ }
+ }
+ # make a nice display for the albums
+ $album =~ /(\d{2} - |)(.*?)( \((\d{4})\)|)$/;
+ my $albumname = $2; my $year = $4;
+ my $htmlalbum = '<a href="front.plx?artist='.makeUnNice($artist).'&album='.makeUnNice($album).'" class="heading" target="_top" title="Platter link to '.$album.'"><span class="title">'.makeHTML($2).'</span></a>';
+ $htmlalbum = '' if ($albumname eq 'Miscellany');
+
+ # initialise the playlist
+ $self->{playlist} =~ s/%ALBUM%/$album/g;
+ $self->{playlist} =~ s/%HTMLALBUM%/$htmlalbum/g;
+ $self->{playlist} =~ s/%ARTIST%/$artist/g;
+ $self->{playlist} =~ s/%YEAR%/<br>&nbsp;<b>$year<\/b>/g;
+ $self->{playlink} = 'search.plx?artist='.makeUnNice($artist).'&album='.makeUnNice($album).'&exact=1&searchFor=track&inv=%INV%&filter=music,video,shortcut';
+ $self->{currentAlbum} = makeNice($album);
+
+}
+
+sub track {
+ my $self = shift;
+ my ($folder, $trackartist, $album, $year, $track, $url, $platter) = @_;
+
+ if ($track =~ /(cover|artist).*\.(gif|jpg|png)$/i) {
+ # put the image and label in if not there yet
+ if (!($self->{coverCount})) {
+ my $cover = '<p><a href="javascript:nextCover()"><img border=0 name="cover" id="cover" alt="Click for next image"></a><br>'.
+ '<small>Image from <strong name="coversource" id="coversource">Nobody</strong>&nbsp;(<span name="coverno" id="coverno">0</span> of %TOTALCOVERS%)</small><script>nextCover();</script>';
+
+ $self->{playlist} =~ s/%COVER%/$cover/;
+ }
+
+ # insert into the javascript arrays
+
+ my $coverLoc = "locations[$self->{coverCount}] = '".makeJs('http://'.$PLATTERS{$platter}.$url)."';\n ";
+ $self->{playlist} =~ s/%LOCATIONS%/$coverLoc%LOCATIONS%/;
+ my $coverSource = "sources[$self->{coverCount}] = '$platter';\n ";
+ $self->{playlist} =~ s/%SOURCES%/$coverSource%SOURCES%/;
+
+ $self->{coverCount}++;
+
+ }
+ elsif ($track =~ /info\.txt$/i) {
+ $self->{info} .= '<p><i>'.$platter.' says:</i><br>'.getFile('http://'.$PLATTERS{$platter}.$url)."\n";
+ }
+ else { # add the track
+
+ # look to see if we're on a child album and report it
+ my $trackhtml;
+ my $nicealbum = makeNice($album);
+
+ if ($self->{currentAlbum} ne $nicealbum) {
+ my $albumstub = $nicealbum;
+ $albumstub =~ s/^\Q$self->{album}\E\///;
+ $trackhtml = '<br><b>'.makeHTML($albumstub)."</b>\n";
+ }
+
+ $self->{currentAlbum} = $nicealbum;
+
+ # link to other folder if present
+ my $foreigner;
+ foreach (($folder, $trackartist)) {
+ my $thisArtist = $_;
+ my $thisNiceArtist = makeNice($thisArtist);
+ if ($thisArtist && !($thisNiceArtist =~ /^$self->{artist}$/i) && !($thisNiceArtist =~ /^$folder$/i) ) {
+ $foreigner = '<br><small><i>';
+ $foreigner .= 'with ' if (!$self->{custom});
+ $foreigner .= '<a href="artist.plx?name='.makeUnNice($thisArtist).'&exact=1" target="_parent">'.makeHTML($thisArtist).'</a></i></small>' ;
+ }
+ }
+
+ # paste the track in
+ $trackhtml .= '<li><a href="'.makeTrackURL($PLATTERS{$platter}, $url, $folder, $trackartist, $track ).'"><img src="/platdoc/img/filebutton_s.png" border=0 align="top"></a><a href="'.makeTrackPlaylist($folder, $trackartist, $album, $track, $platter).'"><img src="/platdoc/img/playbutton_s.png" border=0 align="top"> '.makeHTML($track)."</a>$foreigner</li>\n%TRACKS%";
+
+ $self->{playlist} =~ s/%TRACKS%/$trackhtml/;
+
+ # check if extract of another album
+ if (!$self->{foreign} && $self->{album} ne 'Miscellany') {
+ my $artistlink = makeNice($folder);
+ if ($artistlink && $artistlink ne $self->{artist}) { # link to proper artist page
+ $self->{foreign} = "&nbsp;<i>from <a href=\"artist.plx?name=".makeUnNice($artistlink)."&album=".$album."\" target=\"_parent\">$artistlink</a>";
+ }
+ else {
+ $self->{foreign} = " "; # don't check again
+ }
+ }
+
+ # update the host
+ if ($self->{platter} eq "") {
+ $self->{platter} = $platter;
+ }
+ elsif ($self->{platter} ne $platter && $self->{platter} ne 'Various') {
+ $self->{platter} = 'Various';
+ }
+
+ }
+}
+
+sub dump {
+ my $self = shift;
+ # remove any unused placeholders
+ $self->{playlist} =~ s/%COVER%//;
+ $self->{playlist} =~ s/%TRACKS%//;
+ $self->{playlist} =~ s/%SOURCES%//;
+ $self->{playlist} =~ s/%LOCATIONS%//;
+ $self->{playlist} =~ s/%TOTALCOVERS%/$self->{coverCount}/g;
+
+ # info
+ my $info = $self->{info};
+ my $infolink;
+ if (!$info) {
+ $info = '<p><i>No further info available</i>' ;
+ }
+ else {
+ $infolink = '<a href="#info"><img src="/platdoc/img/infobutton.png" width=32 height=32 border=0 alt="Information"></a>';
+ }
+
+ my $playbutton; my $hostreport;
+
+ # playbutton
+ if ($self->{platter}) {
+ $playbutton = '<a href="'.$self->{playlink}.'">'.
+ '<img src="/platdoc/img/playbutton.png" width=32 height=32 border=0 alt="Play"></a>';
+ $hostreport = 'Hosted by <strong>%SOURCE%</strong>';
+ }
+ $self->{playlist} =~ s/%PLAYBUTTON%/$playbutton/;
+ $self->{playlist} =~ s/%HOST%/$hostreport/;
+
+
+ #all other vars
+ my $source = $self->{platter};
+ $self->{playlist} =~ s/%SOURCE%/$source/;
+
+ $source = '' if ($source eq 'Various');
+ $self->{playlist} =~ s/%INV%/$source/;
+
+ $self->{playlist} =~ s/%INFO%/$info/;
+ $self->{playlist} =~ s/%INFOBUTTON%/$infolink/;
+
+ my $link = $self->{foreign};
+ $self->{playlist} =~ s/%FOREIGN%/$link/;
+ return $self->{playlist};
+ }
+
+return 1;