1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 20:27:58 +01:00
Files
pentadactyl-pm/melodactyl/content/library.js
Kris Maglione a59d88fee7 Basic Songbird 1.9a support.
--HG--
rename : xulmus/AUTHORS => melodactyl/AUTHORS
rename : xulmus/Makefile => melodactyl/Makefile
rename : xulmus/NEWS => melodactyl/NEWS
rename : xulmus/TODO => melodactyl/TODO
rename : xulmus/chrome.manifest => melodactyl/chrome.manifest
rename : xulmus/components/commandline-handler.js => melodactyl/components/commandline-handler.js
rename : xulmus/components/protocols.js => melodactyl/components/protocols.js
rename : xulmus/content/config.js => melodactyl/content/config.js
rename : xulmus/content/dactyl.dtd => melodactyl/content/dactyl.dtd
rename : xulmus/content/library.js => melodactyl/content/library.js
rename : xulmus/content/logo.png => melodactyl/content/logo.png
rename : xulmus/content/xulmus.xul => melodactyl/content/melodactyl.xul
rename : xulmus/content/player.js => melodactyl/content/player.js
rename : xulmus/content/xulmus.svg => melodactyl/content/xulmus.svg
rename : xulmus/contrib/vim/Makefile => melodactyl/contrib/vim/Makefile
rename : xulmus/contrib/vim/ftdetect/xulmus.vim => melodactyl/contrib/vim/ftdetect/melodactyl.vim
rename : xulmus/contrib/vim/mkvimball.txt => melodactyl/contrib/vim/mkvimball.txt
rename : xulmus/contrib/vim/syntax/xulmus.vim => melodactyl/contrib/vim/syntax/melodactyl.vim
rename : xulmus/defaults/preferences/dactyl.js => melodactyl/defaults/preferences/dactyl.js
rename : xulmus/install.rdf => melodactyl/install.rdf
rename : xulmus/locale/en-US/all.xml => melodactyl/locale/en-US/all.xml
rename : xulmus/locale/en-US/autocommands.xml => melodactyl/locale/en-US/autocommands.xml
rename : xulmus/locale/en-US/browsing.xml => melodactyl/locale/en-US/browsing.xml
rename : xulmus/locale/en-US/dactyl.dtd => melodactyl/locale/en-US/dactyl.dtd
rename : xulmus/locale/en-US/gui.xml => melodactyl/locale/en-US/gui.xml
rename : xulmus/locale/en-US/intro.xml => melodactyl/locale/en-US/intro.xml
rename : xulmus/locale/en-US/player.xml => melodactyl/locale/en-US/player.xml
rename : xulmus/locale/en-US/tabs.xml => melodactyl/locale/en-US/tabs.xml
rename : xulmus/skin/icon.png => melodactyl/skin/icon.png
2010-10-02 10:44:19 -04:00

65 lines
2.2 KiB
JavaScript

// Copyright (c) 2009 by Prathyush Thota <prathyushthota@gmail.com>
// Copyright (c) 2009 by Doug Kearns <dougkearns@gmail.com>
//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
// TODO: flesh this out
const Library = Module("library", {
init: function () {
this.MAIN_LIBRARY = LibraryUtils.mainLibrary;
},
/**
* Converts an XPCOM enumerator to a JavaScript array.
*
* @param {nsISimpleEnumerator|nsIStringEnumerator|nsIArray} enum The enumerator to convert.
* @returns {Array}
*/
_toJSArray: function _toJSArray(enum) ArrayConverter.JSArray(enum),
/**
* Returns an array of all the artist names in the main library.
*
* @returns {string[]}
*/
getArtists: function getArtists() this._toJSArray(this.MAIN_LIBRARY.getDistinctValuesForProperty(SBProperties.artistName)),
// FIXME: Prathyush do we really want to remove duplicates? If so, why not tracks too? --djk
/**
* Returns an array of all the album names for <b>artist</b> in the
* main library.
*
* @param {string} artist The artist's name.
* @returns {string[]}
*/
getAlbums: function getAlbums(artist) {
let albums = this._toJSArray(this.MAIN_LIBRARY.getItemsByProperty(SBProperties.artistName, artist))
.map(function (track) track.getProperty(SBProperties.albumName));
return util.Array.uniq(albums);
},
/**
* Returns an array of all the track names for <b>artist</b> and
* <b>album</b> in the main library.
*
* @param {string} artist The artist's name.
* @param {string} album The album's name.
* @returns {string[]}
*/
getTracks: function getTracks(artist, album) {
let properties = services.create("mutablePropertyArray");
properties.appendProperty(SBProperties.artistName, artist);
properties.appendProperty(SBProperties.albumName, album);
return this._toJSArray(this.MAIN_LIBRARY.getItemsByProperties(properties))
.map(function (track) track.getProperty(SBProperties.trackName));
}
}, {
}, {
});
// vim: set fdm=marker sw=4 ts=4 et: