Permalink
Browse files

add Export to CSV option for playlists

  • Loading branch information...
1 parent 3915cb6 commit 6ebecb2e5ec9ddb4517fad45f8e6a35f2e02cb0c @matt-h committed Jan 18, 2012
Showing with 22 additions and 0 deletions.
  1. +22 −0 rdio-enhancer.js
View
@@ -206,6 +206,28 @@ function injectedJs() {
return false;
}
});
+ item.menu_items.splice(play_next_insert + 4, 0,
+ {
+ title: "Export to CSV",
+ visible: function() {
+ return true;
+ },
+ action: function() {
+ var i = data.tracks.length;
+ var csv = [["Name", "Artist", "Album", "Track Number"].join(",")];
+ while(i--) {
+ csv.push([
+ '"' + data.tracks[i].name + '"',
+ '"' + data.tracks[i].artist + '"',
+ '"' + data.tracks[i].album + '"',
+ data.tracks[i].trackNum
+ ].join(","));
+ }
+ window.location = 'data:text/csv;charset=utf8,' + encodeURIComponent(csv.join("\n"));
+ R.Notifications.show(data.name + ' downloaded to CSV. You may need to rename the file to include .csv to open it with your spreadsheet application.');
+ return false;
+ }
+ });
}
// if this is a Track
else if(datatype === 't') {

0 comments on commit 6ebecb2

Please sign in to comment.