Add top genre to Track object

- merge from chris/audio_features branch
- fixed crashing when new artist doesn't have genre
- get genre/artist data using user secret
- removed punctuation from user secret
This commit is contained in:
2018-06-11 18:34:54 -04:00
8 changed files with 150 additions and 83 deletions

View File

@@ -11,20 +11,19 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<ul>
{% for artist in artist_data %}
<li>{{ artist.name }} - {{ artist.num_songs }}</li>
{% endfor %}
</ul>
<pre> {% filter force_escape %} {% debug %} {% endfilter %} </pre>
<script src="https://d3js.org/d3.v5.min.js"></script>
<script>
d3.json("{% url "get_artist_data" user_id %}").then(function(data) {
/* console.log("artists");
d3.json("{% url "get_artist_data" user_secret %}").then(function(data) {
data.forEach(function(d) {
console.log(d.name, d.num_songs);
});
}); */
console.log("genres");
d3.json("{% url "get_genre_data" user_secret %}").then(function(data) {
data.forEach(function(d) {
console.log(d.name, d.num_songs);
console.log(d.genre, d.num_songs);
});
});
</script>

View File

@@ -16,11 +16,10 @@
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<p>Logged in as {{ id }}</p>
<h2>Display name {{ user_name }}</h2>
<ul>
{% for genre_name, genre_count in genre_dict.items %}
<li>{{ genre_name }} - {{ genre_count }}</li>
{% endfor %}
</ul>
<script src="{% static "spotifyvis/scripts/user_data.js" %}"></script>
<script>
sessionStorage.setItem('user_secret', "{{ user_secret }}");
getAudioFeatureData('instrumentalness', sessionStorage.getItem('user_secret'));
</script>
</body>
</html>