From: <ny...@us...> - 2006-05-05 13:54:35
|
Revision: 13 Author: nyaochi Date: 2006-05-05 06:54:22 -0700 (Fri, 05 May 2006) ViewCVS: http://svn.sourceforge.net/pmplib/?rev=13&view=rev Log Message: ----------- Added sample JSPL files. Added Paths: ----------- trunk/lib/playlist/sample/ trunk/lib/playlist/sample/artist.jspl trunk/lib/playlist/sample/artists.jspl trunk/lib/playlist/sample/top_ranking.jspl Added: trunk/lib/playlist/sample/artist.jspl =================================================================== --- trunk/lib/playlist/sample/artist.jspl (rev 0) +++ trunk/lib/playlist/sample/artist.jspl 2006-05-05 13:54:22 UTC (rev 13) @@ -0,0 +1,39 @@ +/* + * Artist playlist + * + * This JSPL extracts tracks performed by the artist whose name is + * is specified by either variable 'artist_name' or filename of this JSPL. + * + */ + +// Change this to specify the artist name +var artist_name = ""; + +include("playlist.js"); + +function main(media, source) +{ + // Check artist_name. + if (!artist_name) { + // Retrieve an artist name from the filename. + var begin = 0, end = source.length; + for (var i = 0;i < source.length;++i) { + if (source[i] == '\\' || source[i] == '/') + begin = i; + if (source[i] == '.') + end = i; + } + artist_name = source.slice(begin, end); + } + + // Convert the artist name to lower case. + artist_name = artist_name.toLowerCase(); + + var pl = new Playlist(); + for (var i = 0;i < media.length;++i) + if (media[i].artist.toLowerCase() == artist_name) + pl.push(media[i]); + pl.order("album", "track_number"); + + return pl; +} Added: trunk/lib/playlist/sample/artists.jspl =================================================================== --- trunk/lib/playlist/sample/artists.jspl (rev 0) +++ trunk/lib/playlist/sample/artists.jspl 2006-05-05 13:54:22 UTC (rev 13) @@ -0,0 +1,29 @@ +/* + * Artists playlist + * + * This JSPL generates multiple playlists each of which collects tracks + * performed by an artist. + * + */ + +include("playlist.js"); + +function main(media, playlist) +{ + var pls = new Object(); + + for (var i = 0;i < media.length;++i) { + var artist = media[i].artist.toLowerCase(); + var pl = pls[artist]; + if (pl == undefined) + pl = pls[artist] = new Playlist(); + pl.push(media[i]); + } + + for (var name in pls) { + var pl = pls[name]; + pl.order("album", "track_number"); + } + + return pls; +} Added: trunk/lib/playlist/sample/top_ranking.jspl =================================================================== --- trunk/lib/playlist/sample/top_ranking.jspl (rev 0) +++ trunk/lib/playlist/sample/top_ranking.jspl 2006-05-05 13:54:22 UTC (rev 13) @@ -0,0 +1,26 @@ +/* + * Top ranking playlist + * + * This playlist uses play_count field to generate a ranking playlist. + * The play_count field is currently set by iRiver H10, H10Jr, and U10. + * + */ + + +// Change this to specify the number of top tracks. +var num_top = 50; + +include("playlist.js"); + +function main(media, source) +{ + var pl = new Playlist(); + + for (var i = 0;i < media.length;++i) + pl.push(media[i]); + + pl.order("-play_count"); + + var end = Math.min(pl.length, num_top); + return pl.slice(0, end); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |