Quantcast
Channel: Squeezebox : Community : Forums
Viewing all articles
Browse latest Browse all 10706

Virtual Libraries - help beginner please

$
0
0
Hello.

I'm trying to use Virtual Libraries to rebuild a couple of menus I had previously created with Erland's plugin. I don't have any experience with SQL but I'm quite willing to learn.
So if I understand all this correctly, I have to 'master' 3 steps to get my own custom menus/virtual libraries:

Quote:

1) use the Library demo as a starting point to create the Plugin.pm, install.xml and strings.txt I need for my own plugin

2) figure out the correct SQL to be used in the plugin in each case

3) create the menus in LMS
Some typical examples of menus I would like to create are:

  • a comments based menu group "AAA" with submenus artists, albums, genres, years, songs for all tracks that include comment AAA but not comment BBB and not comment CCC
    By "songs" I mean a submenu for virtual libraries (with few songs) which when clicked upon shows only the tracks (like in the Favorites menu).
  • a menu group "Compilations" with submenus artists, albums, genres, years (for all compilations)
  • a menu "Random Compilations" - exactly like the built-in random albums menu, only for compilations = 20 random compilation albums
  • a menu group "3 Stars+" with submenus artists, albums, genres, years for all tracks rated 3 stars or higher


Unfortunately, I already got stuck with the comments based menu AAA. The 4 menus show up (on the top menu level) but the entries are all wrong or even empty (on the track level). I didn't manage to create a "songs" submenu so far.
Here's my Plugin.pm (without comments):

Code:

package Plugins::MyCustomMenus::Plugin;
use strict;

use base qw(Slim::Plugin::Base);

use Slim::Menu::BrowseLibrary;
use Slim::Music::VirtualLibraries;
use Slim::Music::Import;
use Slim::Utils::Log;

sub initPlugin {
        my $class = shift;

        foreach ( {
                id => 'AAA',
                name => 'All AAA Tracks',
                # %s is being replaced with the library's ID
                sql => qq{
                        INSERT OR IGNORE INTO library_track (library, track)
                                SELECT '%s', tracks.id
                                FROM tracks
                                LEFT JOIN comments ON
                                WHERE
                                        comments.track = tracks.id
                                        AND comments.value LIKE '%AAA%'
                                        AND not exists (select * from comments
                                                where
                                                        comments.track=tracks.id and
                                                        comments.value like '%BBB%' and
                                                        comments.value like '%CCC%'
                                                        )
                        group by tracks.id
                }
        } ) {
                Slim::Music::VirtualLibraries->registerLibrary($_);
        }
       
        my @menus = ( {
                name => 'AAA_ARTISTS',
                icon => 'html/images/artists.png',
                feed => \&Slim::Menu::BrowseLibrary::_artists,
                id  => 'AAA_TracksByArtist',
                weight => 25,
        virtualID => 'AAA',
        },{
                name => 'AAA_ALBUMS',
                icon => 'html/images/albums.png',
                feed => \&Slim::Menu::BrowseLibrary::_albums,
                id  => 'AAA_TracksByAlbum',
                weight => 25,
        virtualID => 'AAA',
        },{
                name => 'AAA_GENRES',
                icon => 'html/images/genres.png',
                feed => \&Slim::Menu::BrowseLibrary::_genres,
                id  => 'AAA_TracksByGenres',
                weight => 25,
        virtualID => 'AAA',
        },{
                name => 'AAA_YEARS',
                icon => 'html/images/years.png',
                feed => \&Slim::Menu::BrowseLibrary::_years,
                id  => 'AAA_TracksByYears',
                weight => 25,
        virtualID => 'AAA',
        } );
       
        foreach (@menus) {
                Slim::Menu::BrowseLibrary->registerNode({
                        type        => 'link',
                        name        => $_->{name},
                        params      => { library_id => Slim::Music::VirtualLibraries->getRealId($_->{virtualID}) },
                        feed        => $_->{feed},
                        icon        => $_->{icon},
                        jiveIcon    => $_->{icon},
                        homeMenuText => $_->{name},
                        condition    => \&Slim::Menu::BrowseLibrary::isEnabledNode,
                        id          => $_->{id},
                        weight      => $_->{weight},
                        cache        => 1,
                });
        }
        $class->SUPER::initPlugin(@_);
}
1;

My questions for this one:
1) where are the mistakes in my SQL?
2) How do I manage to make all 5 menus (artists, albums, genres, years, songs) submenus of 1 menu group AAA:

Code:

AAA > artists
        > albums
        > genres
        > years
        > songs

It is possible I think (because one of Erland's plugins used to do that) but I don't know how.

And finally, would it even be possible to group all of my custom made menus under 1 menu entry, like My Custom Menus > AAA >all of AAA submenus, My Custom Menus > Compilations > all of "Compilations' submenus... ?

Thank you very much for your much needed help.

Viewing all articles
Browse latest Browse all 10706

Trending Articles