spotify-data
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -24,1 +24,4 @@ var spotify = require('./'); | ||
spotify.lookup('spotify:user:minigod:playlist:5ACX9Pa6kRUWWv9ZWD5oH4', console.log); | ||
spotify.flatten('spotify:album:0AKaAXiqrwaXPSn9VNxK6N', console.log); | ||
spotify.playlist.flatten('minigod', '5ACX9Pa6kRUWWv9ZWD5oH4', console.log); |
31
index.js
@@ -36,3 +36,3 @@ var url = require('url'); | ||
Spotify.lookup = function(uri, extras, cb) { | ||
var parsed = Spotify.uri.parse(uri); | ||
var parsed = typeof uri === 'string' ? Spotify.uri.parse(uri) : uri; | ||
@@ -148,3 +148,3 @@ // Playlist | ||
href: Spotify.uri.formatURI({type:'track',id: el.attr('data-track')}), | ||
duration: el.attr('data-duration-ms'), | ||
duration: parseInt(el.attr('data-duration-ms')), | ||
cover: el.attr('data-ca'), | ||
@@ -167,6 +167,29 @@ artists: [] | ||
cb(null, tracks); | ||
var playlist = { | ||
playlist: { | ||
'playlist-id': Spotify.uri.formatURI({type:'playlist', }), | ||
title: $('div.title-content').text(), | ||
tracks: tracks, | ||
}, | ||
info: { | ||
type: 'playlist' | ||
} | ||
} | ||
cb(null, playlist); | ||
}); | ||
} | ||
Spotify.playlist.cover = function(user, id, cb) { | ||
// spotify-uri supports parsing of playlist, but not formating -.- | ||
var uri = ['spotify', 'user', user, 'playlist', id].join(':'); | ||
Spotify.cover(uri, cb); | ||
} | ||
Spotify.playlist.flatten = function(user, id, cb) { | ||
// spotify-uri supports parsing of playlist, but not formating -.- | ||
var uri = ['spotify', 'user', user, 'playlist', id].join(':'); | ||
Spotify.flatten(uri, cb); | ||
} | ||
/** | ||
@@ -189,2 +212,4 @@ * Flattens an URI to tracks. Ie. an album returns all tracks in the album. an artist returns all tracks by the artist. | ||
cb(null, res.album.tracks); | ||
} else if (res.info.type === 'playlist') { | ||
cb(null, res.playlist.tracks); | ||
} else if (res.info.type === 'artist') { | ||
@@ -191,0 +216,0 @@ var albums = []; |
{ | ||
"name": "spotify-data", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Simple spotify metadata. Supports playlist, cover art, artist, album and track.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16819
7
286