typecrazy789 wrote: 
> I'm ashamed to say I didn't know about this - this more or less does
> what I want perfectly. But is there a way to add more than one folder to
> a library view, or would I need to actually move files into a single
> folder to make it work? I tried adding more than one path using several
> characters to separate but nothing worked.

What are you using to define sub libraries? The sub library demo plugin?


This is an example of how I made a modified version of it to have sub
libraries defined on folders:


Code:
--------------------
    
  
  package Plugins::mc2Library::Plugin;
  
  # This program is free software; you can redistribute it and/or
  # modify it under the terms of the GNU General Public License,
  # version 2.
  
  use strict;
  
  use base qw(Slim::Plugin::Base);
  
  use Slim::Menu::BrowseLibrary;
  use Slim::Music::Import;
  use Slim::Utils::Log;
  
  sub initPlugin {
        my $class = shift;
  
        # Define some virtual libraries.
        # - id:        the library's ID. Use something specific to your plugin 
to prevent dupes.
        # - name:      the user facing name, shown in menus and settings
        # - sql:       a SQL statement which creates the records in 
library_track
        # - scannerCB: a sub ref to some code creating the records in 
library_track. Use scannerCB
        #              if your library logic is a bit more complex than a 
simple SQL statement.
        foreach ( {
                id => 'mc2classica',
                name => 'Classica',
                # %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 
                                 WHERE url LIKE 'file:///F:/Classica/%'
                }
        },{
                id => 'mc2Jazz',
                name => 'Jazz',
                # %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 
                                 WHERE url LIKE 'file:///E:/Jazz/%' 
                }
        },{
                id => 'mc2Rock',
                name => 'Rock',
                # %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 
                                 WHERE url LIKE 'file:///E:/Rock/%'
                }
        },{
                id => 'mc2Blues',
                name => 'Blues',
                # %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 
                                 WHERE url LIKE 'file:///E:/Blues/%'
                }
        },{
                id => 'mc2Audiophile',
                name => 'Audiophile',
                # %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 
                                 WHERE url LIKE 'file:///E:/Audiophile/%'
                }
        },{
                id => 'mc2Disco',
                name => 'Disco',
                # %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 
                                 WHERE url LIKE 'file:///E:/Disco/%'
                }
        },{
                id => 'mc2Lounge',
                name => 'Lounge',
                # %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 
                                 WHERE url LIKE 'file:///E:/Lounge/%'
                }
        },{
                id => 'mc2Latina',
                name => 'Latina',
                # %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 
                                 WHERE url LIKE 'file:///E:/Latina/%'
                }
        },{
                id => 'mc2Other',
                name => 'Altro',
                scannerCB => sub {
                        my $id = shift;
                        
                        # We could do some serious processing here. But for the 
sake of it we're
                        # just going to run another SQL query:
                        my $dbh = Slim::Schema->dbh;
                
                        $dbh->do( qq{
                                INSERT OR IGNORE INTO library_track (library, 
track)
                                        SELECT '$id', tracks.id
                                        FROM tracks 
                                        WHERE url NOT LIKE 'file:///E:/Latina/%'
  AND url NOT LIKE 'file:///E:/Lounge/%'
  AND url NOT LIKE 'file:///E:/Disco/%'
  AND url NOT LIKE 'file:///E:/Audiophile/%'
  AND url NOT LIKE 'file:///E:/Blues/%'
  AND url NOT LIKE 'file:///E:/Rock/%'
  AND url NOT LIKE 'file:///E:/Jazz/%'
  AND url NOT LIKE 'file:///F:/Classica/%'
                        } );
                }
        } ) {
                Slim::Music::VirtualLibraries->registerLibrary($_);
        }
        
        my @menus = ( {
                name => 'PLUGIN_MC2_LIBRARY_CLASSICAL_ARTISTS',
                icon => 'html/images/artists.png',
                feed => \&Slim::Menu::BrowseLibrary::_artists,
                id   => 'artistsInMc2Classica',
                weight => 15,
        },{
                name => 'PLUGIN_MC2_LIBRARY_CLASSICAL_ALBUMS',
                icon => 'html/images/albums.png',
                feed => \&Slim::Menu::BrowseLibrary::_albums,
                id   => 'albumsInMc2Classica',
                weight => 16,
        } );
        
        # this demonstrates how to make use of libraries without switching 
        # the full browsing experience to one particular library
        # create some custom menu items based on one library
        foreach (@menus) {
                Slim::Menu::BrowseLibrary->registerNode({
                        type         => 'link',
                        name         => $_->{name},
                        params       => { library_id => 
Slim::Music::VirtualLibraries->getRealId('mc2classica') },
                        feed         => $_->{feed},
                        icon         => $_->{icon},
                        jiveIcon     => $_->{icon},
                        homeMenuText => $_->{name},
                        condition    => 
\&Slim::Menu::BrowseLibrary::isEnabledNode,
                        id           => $_->{id},
                        weight       => $_->{weight},
                        cache        => 1,
                });
        }
        
        $class->SUPER::initPlugin(@_);
  }
  
  1;
  
  
--------------------



________________________________________________________________________
Author of C-3PO plugin,  Squeezelite-R2, Falcon Web interface - See
www.marcoc1712.it
------------------------------------------------------------------------
marcoc1712's Profile: http://forums.slimdevices.com/member.php?userid=34842
View this thread: http://forums.slimdevices.com/showthread.php?t=101701

_______________________________________________
beta mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/beta

Reply via email to