Skip to content

Commit

Permalink
More albums added, I can now add albums using open.spotify.com urls
Browse files Browse the repository at this point in the history
  • Loading branch information
NotNeelPatel committed May 23, 2023
1 parent 380f6e8 commit 972225e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion assets/albums.json

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions assets/scripts/add_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ def add_to_json(album_data):
token = get_token()

if __name__ == "__main__":
album = str(sys.argv[1])
if str(sys.argv[1]) == '--manual':
print(sys.argv[0])
album_token = search_album(album, token)
# --url used when searching doesn't work
if str(sys.argv[1]) in ['--url', '--u']:
album = str(sys.argv[1])
url = str(sys.argv[2])
album_token = url[31:-26]
else:
album = str(sys.argv[1])
album_token = search_album(album, token)

if album_token is None:
print('Error: No album id')
Expand Down
2 changes: 1 addition & 1 deletion assets/scripts/album.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def get_album_data(album_token, token) -> dict:
track_ids += t["id"] + "%2C"

duration = convert_ms(duration_ms)

#acousticness, danceability, energy, instrumentalness, valence
feature_values = get_track_features(track_ids[:-3], total_tracks, token)

Expand Down
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
<body>
<header>
<h1>Albums That I Enjoy</h1>
<h3 style="text-align:center">by neel patel</h3>
<h3 style="text-align:center">by <a href="https://notneelpatel.github.io">neel patel</a> | <a href="https://github.com/NotNeelPatel/Albums"> GitHub Repo</a></h3>
<h4 id="num-albums" style="text-align:center">A collection of 100+ hand-picked albums</h4>
<br />
<br />
</header>
Expand Down
6 changes: 2 additions & 4 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ function createEntries(firstTime) {
.then((data) => {
if (firstTime) {
albumData = data;
document.getElementById("num-albums").innerHTML = "A collection of " + (Object.keys(albumData).length) + " hand-picked albums";
} else {
entryContainer.innerHTML = "";
}
Expand Down Expand Up @@ -126,19 +127,16 @@ function filter() {
parameters.push(key);
}
});
console.log(parameters);


for (let i = 0; i < albumData.length; i++) {
albumData[i].score = 0;
for(let j = 0; j < parameters.length; j++){
let p = parameters[j]
let s = document.getElementById(p+"-slider");
console.log(albumData[i][p])
albumData[i].score += Math.pow(s.value - albumData[i][p] * 10, 2)
}
}

console.log(albumData)
albumData.sort(function(a, b) {
return a.score - b.score;
});
Expand Down

0 comments on commit 972225e

Please sign in to comment.