Skip to content

Commit

Permalink
v0.10.6
Browse files Browse the repository at this point in the history
Merge branch 'dev'
  • Loading branch information
Zé Bateira committed May 26, 2014
2 parents d53c8cf + ae293c1 commit 8b11489
Show file tree
Hide file tree
Showing 8 changed files with 264 additions and 194 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ These are the contents of the script:
```sh
$ mkdir ~/Spotify ; cd ~/Spotify
$ rm -rf rama
$ rm rama_v0.10.5.tar.gz
$ curl https://github.com/carsy/rama-spotify/releases/download/v0.10.5/rama_v0.10.5.tar.gz
$ tar -xvf rama_v0.10.5.tar.gz
$ rm rama_v0.10.6.tar.gz
$ curl https://github.com/carsy/rama-spotify/releases/download/v0.10.6/rama_v0.10.6.tar.gz
$ tar -xvf rama_v0.10.6.tar.gz
$ open spotify:app:rama
```

Expand All @@ -60,6 +60,9 @@ If not, restart Spotify and then open the app by typing spotify:app:rama in the
[Releases]
----

[v0.10.6] - GraphController bug fixes
- handling metadata errors

[v0.10.5] - GraphController bug fixes
- when data is updated, the graph does not re-render

Expand Down Expand Up @@ -128,6 +131,7 @@ José Bateira
[here]:https://github.com/carsy/rama-spotify/releases/latest
[Releases]:https://github.com/carsy/rama-spotify/releases/latest
[issues]:https://github.com/carsy/rama-spotify/issues
[v0.10.6]:https://github.com/carsy/rama-spotify/releases/tag/v0.10.6
[v0.10.5]:https://github.com/carsy/rama-spotify/releases/tag/v0.10.5
[v0.10.2]:https://github.com/carsy/rama-spotify/releases/tag/v0.10.2
[v0.10]:https://github.com/carsy/rama-spotify/releases/tag/v0.10
Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

version="v0.10.5"
version="v0.10.6"

mkdir ~/Spotify ; cd ~/Spotify
rm -rf rama-spotify
Expand Down
44 changes: 8 additions & 36 deletions js/controllers/artistmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,41 +150,8 @@ require([
}
},
updateTags: function(artist) {
// Paul Lamere
// http://developer.echonest.com/forums/thread/353
// Artist terms (tags) ->
// what is the difference between weight and frequency

// term frequency is directly proportional to how often
// that term is used to describe that artist.
// Term weight is a measure of how important that term is
// in describing the artist. As an example of the difference,
// the term 'rock' may be the most frequently applied term
// for The Beatles. However, 'rock' is not very descriptive
// since many bands have 'rock' as the most frequent term.
// However, the most highly weighted terms for The Beatles
// are 'merseybeat' and 'british invasion', which give you
// a better idea of what The Beatles are all about
// than 'rock' does.
// We don't publish the details of our algorithms,
// but I can tell you that frequency is related to the
// simple counting of appearance of a term, whereas
// weight is related to TF-IDF as described
// here (http://en.wikipedia.org/wiki/Tf%E2%80%93idf).

// the url to query echonest's API
// the list of tags being sorted by weight.
var url =
"http://developer.echonest.com/api/v4/artist/" +
"terms?api_key=29N71ZBQUW4XN0QXF&format=json" +
"&sort=weight" +
"&id=" + this.artist.uri.replace('spotify', 'spotify-WW');

$.ajax({
url: url,
context: this
}).done(function(data) {

var fetchDone = function(data) {
// clear the displayed tags
this.elements.tags.reset();
this.elements.tagsTitle.reset();
Expand All @@ -211,15 +178,20 @@ require([
}

this.artist.tags = this.tags;
};

}).fail(function() {
var fetchFail = function() {
// Temporary fix for requests limit from echonest
// just... don't show any tags.
// Note: since the API key being used has request limits,
// sometimes the limit is reached very easily. If so
// don't show anything.
this.elements.tagsTitle.reset();
});
};

this.graphcontroller.fetchTags(this.artist.uri, 'weight')
.done(fetchDone.bind(this))
.fail(fetchFail.bind(this));
},
// control buttons update: shows/hides controls
// based on the artist
Expand Down
83 changes: 82 additions & 1 deletion js/controllers/graphcontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ require([
}
});

GraphController.BASE_URL =
'http://developer.echonest.com/api/v4/artist/terms';
GraphController.API_KEY = '29N71ZBQUW4XN0QXF';

GraphController.implement({
// parameter settings is a dependency.
// this means that at this point (when loadController runs)
Expand Down Expand Up @@ -104,13 +108,51 @@ require([
updateNodes: function() {
this.artistgraph.updateNodes();
},

getData: function() {
return this.artistgraph.data;
},


fetchTags: function(artistURI, sortType) {
// Paul Lamere
// http://developer.echonest.com/forums/thread/353
// Artist terms (tags) ->
// what is the difference between weight and frequency
// (values of sortType)

// term frequency is directly proportional to how often
// that term is used to describe that artist.
// Term weight is a measure of how important that term is
// in describing the artist. As an example of the difference,
// the term 'rock' may be the most frequently applied term
// for The Beatles. However, 'rock' is not very descriptive
// since many bands have 'rock' as the most frequent term.
// However, the most highly weighted terms for The Beatles
// are 'merseybeat' and 'british invasion', which give you
// a better idea of what The Beatles are all about
// than 'rock' does.
// We don't publish the details of our algorithms,
// but I can tell you that frequency is related to the
// simple counting of appearance of a term, whereas
// weight is related to TF-IDF as described
// here (http://en.wikipedia.org/wiki/Tf%E2%80%93idf).

// the url to query echonest's API.
// the list of tags are being sorted by weight.
return $.ajax({
url: GraphController.BASE_URL + '?' +
'api_key=' + GraphController.API_KEY + '&' +
'format=json' + '&' +
'sort=' + sortType + '&' +
'id=' + artistURI.replace('spotify', 'spotify-WW')
});
},

// Expands the specific given artist in the graph.
// the artist is required to be in the graph
expandNode: function(artist) {
this.artistgraph.highlightNode(artist);
this.highlightArtist(artist);
this.artistgraph.expandNode(
0,
artist,
Expand All @@ -134,6 +176,42 @@ require([
this.throbber.hide();
},

highlightNodes: function(nodes) {
_.each(nodes, this.highlightNode);
this.updateNodes();
_.each(nodes, this.unHighlightNode);
},

highlightArtist: function(artist) {
this.highlightNode(this.artistgraph.getNode(artist));
},
highlightNode: function(node) {
if (node.isRoot)
node.color = {
border: '#7fb701'
};
else
node.color = {
border: '#7fb701',
background: '#313336'
};
},
unHighlightNode: function(node) {
if (node.isRoot)
node.color = {
highlight: {
border: '#7fb701'
}
};
else
node.color = {
background: '#313336',
highlight: {
border: '#7fb701'
}
};
},

// Events

// Binds all the events related to the graph components.
Expand Down Expand Up @@ -183,6 +261,9 @@ require([
// update this.nowplayingArtist with the track's artist.
onPlayerChange: function(player) {

if (!player.track)
return;

// ignore change if it's playing an ad.
if (player.track.advertisement)
return;
Expand Down
Loading

0 comments on commit 8b11489

Please sign in to comment.