Bugzilla – Bug 1749
Add support for indeces (subdiving tracks)
Last modified: 2011-11-06 23:22:37 UTC
Hope this is the right place for a feature request. I'm using indices (they further devide a track on a CD) and patched SlimServer v6.0.2 so that it fits my needs. But I think the idea behind it might be of broader interest. That's the reason for this "bug report". The following patch adds a very rumdimentary (only SQLite, only FLAC, only default web interface) support for indices to the Slimserver software. Sorry if this is crude code and omits many things, but this afternoon was the first time for me coding perl (besides one simple "hello world" before). But hopefully it's enough for you to get the idea... This patch (sorry for not reproducing the tabs correctly, is there an intelligent way for attaching diffs?) also includes a "shelfmark" (german: "Signatur") tag, which I use to locate the CDs in my shelf. --- /dev/null 2005-02-27 12:46:19.655273128 +0100 +++ SlimServer_v6.0.2/SQL/SQLite/Upgrades/8.sql 2005-07-03 15:45:31.000000000 +0200 @@ -0,0 +1,4 @@ +-- +-- Force db recreation by upping the schema + +UPDATE metainformation SET version = 8; --- SlimServer_v6.0.2/SQL/SQLite/dbcreate.sql.unmodified 2005-07-03 15:46:07.000000000 +0200 +++ SlimServer_v6.0.2/SQL/SQLite/dbcreate.sql 2005-07-03 16:40:08.000000000 +0200 @@ -11,7 +11,7 @@ total_time integer -- cumulative play time ); -INSERT INTO metainformation VALUES (7, 0, 0); +INSERT INTO metainformation VALUES (8, 0, 0); CREATE TABLE tracks ( id integer UNIQUE PRIMARY KEY NOT NULL, @@ -20,6 +20,9 @@ titlesort varchar, -- version of title used for sorting album integer, -- album object tracknum integer, -- track number in album + tracktotal integer, -- total number of tracks in album + indexnum integer, -- index number in track + indexmax integer, -- number of last index in track (indices count from zero!) ct varchar, -- content type of track tag integer, -- have we read the tags yet age integer, -- timestamp for listing @@ -83,6 +86,7 @@ CREATE TABLE albums ( id integer UNIQUE PRIMARY KEY NOT NULL, + shelfmark varchar, -- (unique) mark for the media (CD, DVD, Tape etc.) this album is on title varchar, -- title titlesort varchar, -- version of title used for sorting contributors varchar, -- stringified list of contributors --- SlimServer_v6.0.2/SQL/SQLite/sql.version.unmodified 2005-07-03 15:44:30.000000000 +0200 +++ SlimServer_v6.0.2/SQL/SQLite/sql.version 2005-07-03 15:45:16.000000000 +0200 @@ -8,3 +8,4 @@ 4 99999 5 99999 6 99999 +7 99999 --- SlimServer_v6.0.2/HTML/Default/songinfo.html.unmodified 2005-07-03 18:29:06.000000000 +0200 +++ SlimServer_v6.0.2/HTML/Default/songinfo.html 2005-07-03 23:00:23.000000000 +0200 @@ -75,6 +75,13 @@ </tr> [% END %] + [% IF track.album.shelfmark %] + <tr> + <td class="nowrap"> [% "SHELFMARK" | string; "COLON" | string %]</td> + <td> [% track.album.shelfmark | html %] </td> + </tr> + [% END %] + [% IF track.album.disc %] <tr> <td class="nowrap"> [% "DISC" | string; "COLON" | string %]</td> @@ -85,7 +92,14 @@ [% IF track.tracknum %] <tr> <td class="nowrap"> [% "TRACK" | string; "COLON" | string %]</td> - <td> [% track.tracknum | html %] </td> + <td> [% track.tracknum | html %][% IF track.tracktotal %]/[% track.tracktotal | html %][% END %] </td> + </tr> + [% END %] + + [% IF track.indexnum %] + <tr> + <td class="nowrap"> [% "INDEX" | string; "COLON" | string %]</td> + <td> [% track.indexnum | html %][% IF track.indexmax %]/[% track.indexmax | html %][% END %] </td> </tr> [% END %] --- SlimServer_v6.0.2/Slim/DataStores/DBI/Track.pm.unmodified 2005-07-03 16:33:03.000000000 +0200 +++ SlimServer_v6.0.2/Slim/DataStores/DBI/Track.pm 2005-07-03 17:40:39.000000000 +0200 @@ -31,6 +31,9 @@ our %otherColumns = ( 'size' => 'audio_size', 'offset' => 'audio_offset', + 'tracktotal' => 'tracktotal', + 'indexnum' => 'indexnum', + 'indexmax' => 'indexmax', 'year' => 'year', 'secs' => 'secs', 'cover' => 'cover', --- SlimServer_v6.0.2/Slim/DataStores/DBI/DataModel.pm.unmodified 2005-07-04 00:02:25.000000000 +0200 +++ SlimServer_v6.0.2/Slim/DataStores/DBI/DataModel.pm 2005-07-04 00:04:27.000000000 +0200 @@ -337,12 +337,12 @@ 'album' => ['albums.titlesort','albums.disc'], 'contributor' => ['contributors.namesort'], 'artist' => ['contributors.namesort'], - 'track' => ['tracks.multialbumsortkey', 'tracks.disc','tracks.tracknum','tracks.titlesort'], - 'tracknum' => ['tracks.disc','tracks.tracknum','tracks.titlesort'], + 'track' => ['tracks.multialbumsortkey', 'tracks.disc','tracks.tracknum','tracks.indexnum','tracks.titlesort'], + 'tracknum' => ['tracks.disc','tracks.tracknum','tracks.indexnum','tracks.titlesort'], 'year' => ['tracks.year'], 'lastPlayed' => ['tracks.lastPlayed'], 'playCount' => ['tracks.playCount'], - 'age' => ['tracks.age desc', 'tracks.disc', 'tracks.tracknum', 'tracks.titlesort'], + 'age' => ['tracks.age desc', 'tracks.disc', 'tracks.tracknum', 'tracks.indexnum', 'tracks.titlesort'], ); # This is a weight table which allows us to do some basic table reordering, --- SlimServer_v6.0.2/Slim/DataStores/DBI/DBIStore.pm.unmodified 2005-07-03 17:11:02.000000000 +0200 +++ SlimServer_v6.0.2/Slim/DataStores/DBI/DBIStore.pm 2005-07-03 18:17:20.000000000 +0200 @@ -865,6 +865,15 @@ if (defined $attributesHash->{'TRACKNUM'}) { $attributesHash->{'TRACKNUM'} = Slim::Music::Info::cleanTrackNumber($attributesHash->{'TRACKNUM'}); } + if (defined $attributesHash->{'TRACKTOTAL'}) { + $attributesHash->{'TRACKTOTAL'} = Slim::Music::Info::cleanTrackNumber($attributesHash->{'TRACKTOTAL'}); + } + if (defined $attributesHash->{'INDEXNUM'}) { + $attributesHash->{'INDEXNUM'} = Slim::Music::Info::cleanTrackNumber($attributesHash->{'INDEXNUM'}); + } + if (defined $attributesHash->{'INDEXMAX'}) { + $attributesHash->{'INDEXMAX'} = Slim::Music::Info::cleanTrackNumber($attributesHash->{'INDEXMAX'}); + } # Turn the tag SET into DISC and DISCC if it looks like # or #/# if ($attributesHash->{'SET'} and $attributesHash->{'SET'} =~ /(\d+)(?:\/(\d+))?/) { @@ -1163,7 +1172,7 @@ # Normalize ARTISTSORT in ContributorTrack->add() the tag may need to be split. See bug #295 # # Push these back until we have a Track object. - for my $tag (qw(COMMENT BAND COMPOSER CONDUCTOR GENRE ARTIST ARTISTSORT PIC APIC ALBUM ALBUMSORT DISCC)) { + for my $tag (qw(COMMENT BAND COMPOSER CONDUCTOR GENRE ARTIST ARTISTSORT PIC APIC ALBUM ALBUMSORT DISCC SHELFMARK)) { next unless defined $attributes->{$tag}; @@ -1265,6 +1274,7 @@ my $album = $attributes->{'ALBUM'}; my $disc = $attributes->{'DISC'}; my $discc = $attributes->{'DISCC'}; + my $shelfmark = $attributes->{'SHELFMARK'}; my $albumObj; # Create a singleton for "No Album" @@ -1360,6 +1370,7 @@ $albumObj->disc($disc) if $disc; $albumObj->discc($discc) if $discc; + $albumObj->shelfmark($shelfmark) if $shelfmark; $albumObj->update(); $track->album($albumObj); @@ -1380,6 +1391,7 @@ push @keys, $albumName || ''; push @keys, $disc if defined($disc); push @keys, sprintf("%03d", $track->tracknum) if defined($track->tracknum); + push @keys, sprintf("%03d", $track->indexnum) if defined($track->indexnum); push @keys, $track->titlesort() || ''; $track->multialbumsortkey(join ' ', @keys); --- SlimServer_v6.0.2/Slim/DataStores/DBI/Album.pm.unmodified 2005-07-03 19:36:35.000000000 +0200 +++ SlimServer_v6.0.2/Slim/DataStores/DBI/Album.pm 2005-07-03 19:37:19.000000000 +0200 @@ -10,7 +10,7 @@ $class->table('albums'); - $class->columns(Essential => qw/id title titlesort contributors artwork_path disc discc musicmagic_mixable/); + $class->columns(Essential => qw/id title titlesort contributors artwork_path disc discc shelfmark musicmagic_mixable/); $class->columns(Stringify => qw/title/); --- SlimServer_v6.0.2/Slim/Buttons/TrackInfo.pm.unmodified 2005-07-03 21:46:06.000000000 +0200 +++ SlimServer_v6.0.2/Slim/Buttons/TrackInfo.pm 2005-07-03 22:35:10.000000000 +0200 @@ -257,9 +257,27 @@ push (@{$client->trackInfoLines}, $client->string('ALBUM') . ": $album"); push (@{$client->trackInfoContent}, 'ALBUM'); } - + + if (my $shelfmark = $track->album()->shelfmark()) { + push (@{$client->trackInfoLines}, $client->string('SHELFMARK') . ": $shelfmark"); + push (@{$client->trackInfoContent}, undef); + } + if (my $tracknum = $track->tracknum()) { - push (@{$client->trackInfoLines}, $client->string('TRACK') . ": $tracknum"); + if (my $tracktotal = $track->tracktotal()) { + push (@{$client->trackInfoLines}, $client->string('TRACK') . ": $tracknum/$tracktotal"); + } else { + push (@{$client->trackInfoLines}, $client->string('TRACK') . ": $tracknum"); + } + push (@{$client->trackInfoContent}, undef); + } + + if (my $indexnum = $track->indexnum()) { + if (my $indexmax = $track->indexmax()) { + push (@{$client->trackInfoLines}, $client->string('INDEX') . ": $indexnum/$indexmax"); + } else { + push (@{$client->trackInfoLines}, $client->string('INDEX') . ": $indexnum"); + } push (@{$client->trackInfoContent}, undef); } --- SlimServer_v6.0.2/Slim/Formats/FLAC.pm.unmodified 2005-07-03 16:01:38.000000000 +0200 +++ SlimServer_v6.0.2/Slim/Formats/FLAC.pm 2005-07-03 16:07:04.000000000 +0200 @@ -24,12 +24,13 @@ use IO::Seekable qw(SEEK_SET); my %tagMapping = ( + 'INDEXNUMBER' => 'INDEXNUM', 'TRACKNUMBER' => 'TRACKNUM', 'DISCNUMBER' => 'SET', 'URL' => 'URLTAG', ); -my @tagNames = qw(ALBUM ARTIST BAND COMPOSER CONDUCTOR DISCNUMBER TITLE TRACKNUMBER DATE); +my @tagNames = qw(SHELFMARK ALBUM ARTIST BAND COMPOSER CONDUCTOR DISCNUMBER TITLE TRACKNUMBER TRACKTOTAL INDEXNUMBER INDEXMAX DATE); # peem id (http://flac.sf.net/id.html http://peem.iconoclast.net/) my $PEEM = 1835361648; --- SlimServer_v6.0.2/strings.txt.unmodified 2005-07-03 18:30:11.000000000 +0200 +++ SlimServer_v6.0.2/strings.txt 2005-07-03 19:24:45.000000000 +0200 @@ -5908,6 +5908,13 @@ PT Faixa SE Sp�r +INDEX + DE Index + EN Index + ES �ndice + FR Index + IT Indice + SONGTITLE DE Liedertitel DK Sangtitel @@ -6005,6 +6012,10 @@ PT Disco SE Skiva +SHELFMARK + DE Signatur + EN Shelfmark + LENGTH DE Dauer DK Varighed
Created attachment 593 [details] Adds index support for SQLite/FLAC/Default web interface Same patch as in the original bug report. Sorry for that...
Will revisit after 6.1. Thanks.
Created attachment 775 [details] Updated patch to work with slimserver v6.1.1 Besides updating the patch, the following changed: - now uses same DB version as the unpatched slimserver to ease patching against upcoming slimserver releases - added index support to fishbone interface
Unassigned bugs cannot have a priority.