Skip to content

Commit

Permalink
Display total scrobble count of tag in taggings list (closes #28)
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua O'Sullivan committed Feb 21, 2020
1 parent 90b7c7f commit 784dc1c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/assets/js/Generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Generator {
var artist_name = artist.name.toLowerCase()
/**Adding the artist to the artists list... */
result.artists.push(artist_name)
result.listens[artist_name] = artist.playcount
result.listens[artist_name] = parseInt(artist.playcount)
/**Getting their tags... */
await axios.get("https://ws.audioscrobbler.com/2.0/?method=artist.getTopTags"+
"&api_key="+API_KEY+
Expand All @@ -88,12 +88,14 @@ class Generator {
result.taggings[tag.name] = [{artist:artist_name,count:tag.count}]
/**Initialising the count of taggings on the artist to the tag's library_total & saving the tag's URL... */
result.tag_meta[tag.name] = {library_total:tag.count/100,
url:tag.url}
url:tag.url,
tot_scrobbles:result.listens[artist_name]}
} else {
/**Adding the taggings of the tag on the artist to the tag's list in the taggings object... */
result.taggings[tag.name].push({artist:artist_name,count:tag.count})
/**Adding the count of taggings on the artist to the tag's library_total... */
result.tag_meta[tag.name].library_total += tag.count/100
result.tag_meta[tag.name].tot_scrobbles += result.listens[artist_name]
}
}
}.bind(this))
Expand Down
2 changes: 1 addition & 1 deletion src/components/TagsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<li class="tag" v-for='tag in tags' :key='tag' :tag='tag'>
<input type="checkbox" v-model="tag_meta[tag].shown"/>
<div>
<a :href="tag_meta[tag].url">{{ tag }}</a>:
<a :href="tag_meta[tag].url">{{ tag }}</a> ({{ tag_meta[tag].tot_scrobbles }} {{ tag_meta[tag].tot_scrobbles>1 ? 'listens' : 'listen' }}):
<taggings-list class="artist-list" :taggings="taggings[tag]"/>
</div>
</li>
Expand Down

0 comments on commit 784dc1c

Please sign in to comment.