├── .github
└── workflows
│ └── gh-pages-deploy.yml
├── .gitignore
├── LICENSE.md
├── README.md
├── babel.config.js
├── deploy.sh
├── package-lock.json
├── package.json
├── public
├── favicon.ico
└── index.html
├── src
├── App.vue
├── assets
│ ├── js
│ │ ├── Generator.js
│ │ └── Utils.js
│ └── scss
│ │ ├── _vars.scss
│ │ ├── reset.css
│ │ ├── style.scss
│ │ └── themes.scss
├── components
│ ├── ArtistsList.vue
│ ├── CloudBox.vue
│ ├── CollapseButton.vue
│ ├── ControlPanel.vue
│ ├── ControlPanelOption.vue
│ ├── ResultTitle.vue
│ ├── TaggingsList.vue
│ └── TagsList.vue
└── main.js
└── vue.config.js
/.github/workflows/gh-pages-deploy.yml:
--------------------------------------------------------------------------------
1 | name: gh-pages-deploy
2 |
3 | on:
4 | push:
5 | branches: [ master ]
6 |
7 | jobs:
8 | autodeploy:
9 | runs-on: ubuntu-latest
10 |
11 | steps:
12 | - uses: actions/checkout@v2
13 |
14 | - name: Install and Build
15 | run: |
16 | npm install
17 | npm run build
18 |
19 | - name: Deploy
20 | uses: JamesIves/github-pages-deploy-action@releases/v3
21 | with:
22 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23 | BRANCH: gh-pages
24 | FOLDER: dist
25 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | /dist
4 |
5 | # local env files
6 | .env.local
7 | .env.*.local
8 |
9 | # Log files
10 | npm-debug.log*
11 | yarn-debug.log*
12 | yarn-error.log*
13 |
14 | # Editor directories and files
15 | .idea
16 | .vscode
17 | *.suo
18 | *.ntvs*
19 | *.njsproj
20 | *.sln
21 | *.sw?
22 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Joshua O'Sullivan
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # lastfm-tag-cloud
2 | A last.fm tag cloud generator built with Vue!
3 |
4 | Give it a whirl: [https://tagcloud.rainosullivan.com/](https://tagcloud.rainosullivan.com/)
5 |
6 | ## How are the tags chosen & scaled?
7 |
8 | A sample of your artists (up to the size and from the time period you specify) is taken from last.fm via the [user.getTopArtists](https://www.last.fm/api/show/user.getTopArtists) endpoint. For each artist, their top tags are fetched, using [artist.getTopTags](https://www.last.fm/api/show/artist.getTopTags).
9 |
10 | Each tag has a `count` on each artist that has a maximum value of 100. This `count` is a percentage of the people who have tagged that artist that tagged it this tag (e.g. if one person tags an artist "Lo-Fi", and a hundred people tag that artist, then "Lo-Fi" would have a `count` of 1 on that artist.).
11 |
12 | Consider the following three example artists, with the following three sample tags and their corresponding counts on each artist:
13 |
14 | | Artist | Scrobbles | Tag 1: Count | Tag 2: Count | Tag 3: Count |
15 | | ----------- | --------- | -------------- | -------------- | ------------- |
16 | | Tennis | 2019 | Lo-Fi: 100 | Indie Pop: 100 | Chillwave: 70 |
17 | | Men I Trust | 1330 | Dream Pop: 100 | Indie: 67 | Indie Pop: 60 |
18 | | Thundercat | 700 | Funk: 100 | Electronic: 91 | Jazz: 74 |
19 |
20 | Before we move on, the sum of each tag's `count` over all the artists in your sample is calculated, and used as a razor - only up to the top 100 tags by this metric are kept, the rest are discarded to avoid reaching the last.fm API's rate limits.
21 |
22 | Two metrics are then taken about each tag from last.fm using the [tag.getInfo](https://www.last.fm/api/show/tag.getInfo) endpoint: the tag's `reach`, which is defined as the number of users who have used the tag; and the tag's `total` (last.fm call this `taggings` in their docs but it's labelled as `total` in the actual data???), which is the total amount of times the tag has been used over all artists on last.fm.
23 |
24 | Here are some `reach` and `total`/`taggings` values for the tags used above:
25 |
26 | | Tag | Reach | Total/Taggings |
27 | | ---------- | ------ | -------------- |
28 | | Lo-Fi | 32892 | 160851 |
29 | | Indie Pop | 64939 | 367857 |
30 | | Chillwave | 7922 | 31368 |
31 | | Dream Pop | 24113 | 118911 |
32 | | Indie | 253595 | 2017702 |
33 | | Funk | 82092 | 422156 |
34 | | Electronic | 254177 | 2372062 |
35 | | Jazz | 146580 | 1150923 |
36 |
37 | Now we have all the data, we can start using it.
38 |
39 | A `score` is created for each tag as the sum of the products of the scores of the tag (divided by 100) on each artist, and your scrobbles of that artist. For example, "Indie Pop" from the example above would have a `score` of `(100/100 * 2019) + (60/100 * 1330) = 2541.4`.
40 |
41 | This `score` of each tag is then scaled (multiplied) by:
42 |
43 | - The sum of the `count` of that tag on the artists in your sample, divided by the `total` of that tag from the `tag.getInfo` endpoint (this is intended to capture how much of the total uses of that tag fall within your sample).
44 | - The number of artists within your sample that are tagged that tag, squared.
45 | - The base-10 logarithm of the `reach` of that tag from the `tag.getInfo` endpoint (so, a tag gets twice as big for every factor of 10 people that use it - 1 would be half the size of 10, 10 half the size of 100, 100 of 1000...).
46 |
47 | For "Indie Pop", this would be `2541.4 * ((100 + 60) / 367857) * 2^2 * log_10(64939) = ~21.28`.
48 |
49 | This value is arbitrary, before it is passed to [timdream's word cloud generator](https://github.com/timdream/wordcloud2.js/) they're all scaled non-linearly to be in the range of 25-200. If you want to see exactly how this is done, check the CloudBox component's Mounted function. It's not that exciting.
50 |
51 | I've tried to make this take into account the "uniqueness" of the tag to a user's library, as if they were all just scored by frequency the biggest tag on everyone's clouds would probably just be "all". If this causes issues for you, I know. See [here](https://github.com/TheTeaCat/lastfm-tag-cloud/issues/10). I don't care. :rowboat:
52 |
53 | ## What does the tag filter do?
54 |
55 | The tag filter checks tags against an offensive word list, "all", "seen live" and a geohash filter to remove tags that are overly generic/obscene.
56 |
57 | The source of the tag filter's offensive word list is [Ofcom's September 2016 Attitudes to potentially offensive language and gestures on TV and radio research report](https://www.ofcom.org.uk/__data/assets/pdf_file/0022/91624/OfcomOffensiveLanguage.pdf). Those used are the medium, strong, and stronger words that are **not** marked as "least recognised".
58 |
59 | ## Acknowledgements
60 |
61 | I'm using [timdream's word cloud generator](https://github.com/timdream/wordcloud2.js/).
62 |
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: [
3 | '@vue/cli-plugin-babel/preset'
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/deploy.sh:
--------------------------------------------------------------------------------
1 | npm run build
2 | cd dist
3 | git init
4 | git add -A
5 | git commit -m "deploy"
6 | git push -f git@github.com:theteacat/lastfm-tag-cloud.git master:gh-pages
7 | cd ..
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "tag-cloud",
3 | "version": "0.1.0",
4 | "private": true,
5 | "scripts": {
6 | "serve": "vue-cli-service serve",
7 | "build": "vue-cli-service build",
8 | "lint": "vue-cli-service lint"
9 | },
10 | "dependencies": {
11 | "axios": "^0.19.2",
12 | "core-js": "^3.6.5",
13 | "vue": "^2.6.12",
14 | "vue-cookies": "^1.7.3",
15 | "vue-router": "^3.4.3",
16 | "wordcloud": "^1.1.1"
17 | },
18 | "devDependencies": {
19 | "@vue/cli-plugin-babel": "^4.5.4",
20 | "@vue/cli-plugin-eslint": "^4.5.4",
21 | "@vue/cli-service": "^4.5.4",
22 | "babel-eslint": "^10.1.0",
23 | "eslint": "^5.16.0",
24 | "eslint-plugin-vue": "^5.0.0",
25 | "node-sass": "^4.14.1",
26 | "sass-loader": "^9.0.3",
27 | "vue-template-compiler": "^2.6.12"
28 | },
29 | "eslintConfig": {
30 | "root": true,
31 | "env": {
32 | "node": true
33 | },
34 | "extends": [
35 | "plugin:vue/essential",
36 | "eslint:recommended"
37 | ],
38 | "rules": {},
39 | "parserOptions": {
40 | "parser": "babel-eslint"
41 | }
42 | },
43 | "browserslist": [
44 | "> 1%",
45 | "last 2 versions"
46 | ]
47 | }
48 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheTeaCat/lastfm-tag-cloud/a83d5e7f7f8d7efc6ca78d40fe920e057017a9f4/public/favicon.ico
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |