iTunes Plug-in Notes
The Scripting Bridge code requires
iTunes.h, which will be generated automatically the first time you build. When it's created, it'll be in
DerivedSources (not part of your project). The easiest way to open it for reference is to highlight the filename on the import line and hit ⌃⌘J for "Jump to Definition".
You should familiarize yourself with Scripting Bridge a bit before making any changes. Particularly the sections that discuss performance.
In the end though, you just need to test everything out and see what works. Here are some tips specific to iTunes:
When you want to look through "all tracks", use the Music playlist, not the Library playlist.
iTunesApplication *iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"]; iTunesSource *library = [[[[iTunes sources] get] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"kind == %i", iTunesESrcLibrary]] objectAtIndex:0]; iTunesLibraryPlaylist *lp = [[[[library playlists] get] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"specialKind == %i", iTunesESpKMusic]] objectAtIndex:0];
Using the Library playlist can make certain things take thousands of times longer. (That's not an exaggeration.) Specifically, filtering out tracks with predicates involving
albumArtistis unusably slow (though it will eventually work).
When filtering the Music playlist for certain criteria, always call
geton the resulting array. This can be tricky, since
filteredArrayUsingPredicate:returns an NSArray which doesn't have a
get, but it can be made to work by casting it as an SBElementArray.
NSArray *tracks = [(SBElementArray *)[[musicPlaylist tracks] filteredArrayUsingPredicate:trackFilter] get];
Depending on what you search for, everything you do with the result can be very slow. By calling
geton it right away and using the result of that for everything else, you're essentially limiting the slowness to a single call.
fileTrackscan slow things down even if you use the
gettrick above. Using
tracksis quick. The only difference I've found is that the
locationproperty is sometimes missing from
fileTrackswill always have it. (You need location to add a track to a playlist.) But it turns out that using
geton the result as advised above soemhow causes
tracksto provide a
locationproperty. So, if you follow the above advice, this shouldn't be a problem.
The iTunes Library and Quicksilver's Catalog
Most plug-ins put things directly into Quicksilver's catalog. iTunes typically holds a large number of items and it's unlikely that someone will want them all in the catalog. (Do you need every individual song at your fingertips?)
You may have noticed that browsing through artists, albums, playlists, etc. is very fast in Quicksilver even though most of these things aren't in the catalog. The reason is that the plug-in reads in the entire iTunes library from
~/Music/iTunes/iTunes Music Library.xml into memory using
QSObjects you see when browsing around are generated on-the-fly from what's in the dictionary.
About Quicksilver Plugins on Github
This repository contains the current source code of a the Quicksilver Plugin / Module. If you're having issues with this plugin, feel free to log them at the Quicksilver issue tracker.
Before You Try It Out
Before trying out any of these plugins, it's always a good idea to BACKUP all of your Quicksilver data.
This is easily done by backing up the following folders
<user> stands for your short user name):
Before being able to build any of these plugins, you MUST set a new Source Tree for the
QSFramework in the XCode Preferences.
This is done by going into the XCode preferences, clicking 'Source Trees' and adding a new one with the following options:
Display Name: a suitable name, e.g.
/Applications/Quicksilver.app/Contents/Frameworks (or path of Quicksilver.app if different)
For some plugins to compile correctly a source tree must also be set for
QS_SOURCE_ROOT that points to the location of the Quicksilver source code you've downloaded onto your local machine.
Display Name: a suitable name, e.g.
Quicksilver source code root
/Users/<user>/<path to Quicksilver source code>
See the QSApp.com wiki for more information on Building Quicksilver.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Which basically means: whatever you do, I can't be held accountable if something breaks.