Add spotify link for song and artist

- Added Spotify link to song title
- Added Spotify logo svg that takes the user to Spotify to listen to the currently playing song
- Added Spotify link to song artist
This commit is contained in:
AlexandrosAlexiou
2021-11-29 21:45:15 +02:00
committed by Andrew Novac
parent a301a69078
commit 0bf396a69f
4 changed files with 59 additions and 8 deletions

5
.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
#MacOS
.DS_Store
# Environment variables
.env

View File

@@ -84,9 +84,10 @@ def barGen(barCount):
left += 4
return barCSS
def getTemplate():
try:
file = open("api/templates.json","r")
file = open("api/templates.json", "r")
templates = json.loads(file.read())
return templates["templates"][templates["current-theme"]]
except Exception as e:
@@ -117,17 +118,21 @@ def makeSVG(data):
if item["album"]["images"] == []:
image = PLACEHOLDER_IMAGE
else :
else:
image = loadImageB64(item["album"]["images"][1]["url"])
artistName = item["artists"][0]["name"].replace("&", "&")
songName = item["name"].replace("&", "&")
songURI = item["external_urls"]["spotify"]
artistURI = item["artists"][0]["external_urls"]["spotify"]
dataDict = {
"contentBar": contentBar,
"barCSS": barCSS,
"artistName": artistName,
"songName": songName,
"songURI": songURI,
"artistURI": artistURI,
"image": image,
"status": currentStatus,
}

View File

@@ -32,6 +32,7 @@
}
.song {
width: 300px;
color: #f7f7f7;
overflow:hidden;
margin-top: 3px;
@@ -42,6 +43,7 @@
}
.artist {
width: 300px;
color: #9f9f9f;
font-size: 20px;
margin-top: 4px;
@@ -72,6 +74,18 @@
animation: sound 0ms -800ms linear infinite alternate;
}
.spotify-logo {
position: fixed;
right: 20px;
top: 10px;
width: 25px;
filter: invert(1);
}
a {
text-decoration: none;
}
div {
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;
}
@@ -101,9 +115,16 @@
</a>
<div class="content">
<a href="{{songURI}}" target="_blank">
<div class="song">{{songName}}</div>
</a>
<a href="{{artistURI}}" target="_blank">
<div class="artist">{{artistName}}</div>
</a>
<div id="bars">{{contentBar|safe}}</div>
<a href="{{songURI}}" class="spotify-logo">
<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Spotify</title><path d="M12 0C5.4 0 0 5.4 0 12s5.4 12 12 12 12-5.4 12-12S18.66 0 12 0zm5.521 17.34c-.24.359-.66.48-1.021.24-2.82-1.74-6.36-2.101-10.561-1.141-.418.122-.779-.179-.899-.539-.12-.421.18-.78.54-.9 4.56-1.021 8.52-.6 11.64 1.32.42.18.479.659.301 1.02zm1.44-3.3c-.301.42-.841.6-1.262.3-3.239-1.98-8.159-2.58-11.939-1.38-.479.12-1.02-.12-1.14-.6-.12-.48.12-1.021.6-1.141C9.6 9.9 15 10.561 18.72 12.84c.361.181.54.78.241 1.2zm.12-3.36C15.24 8.4 8.82 8.16 5.16 9.301c-.6.179-1.2-.181-1.38-.721-.18-.601.18-1.2.72-1.381 4.26-1.26 11.28-1.02 15.721 1.621.539.3.719 1.02.419 1.56-.299.421-1.02.599-1.559.3z"/></svg>
</a>
</div>
</div>

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@@ -31,6 +31,7 @@
}
.song {
width: 300px;
color: #666;
overflow:hidden;
margin-top: 3px;
@@ -41,6 +42,7 @@
}
.artist {
width: 300px;
color: #b3b3b3;
font-size: 20px;
margin-top: 4px;
@@ -71,6 +73,17 @@
animation: sound 0ms -800ms linear infinite alternate;
}
.spotify-logo {
position: fixed;
right: 20px;
top: 10px;
width: 25px;
}
a {
text-decoration: none;
}
div {
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;
}
@@ -100,9 +113,16 @@
</a>
<div class="content">
<a href="{{songURI}}" target="_blank">
<div class="song">{{songName}}</div>
</a>
<a href="{{artistURI}}" target="_blank">
<div class="artist">{{artistName}}</div>
</a>
<div id="bars">{{contentBar|safe}}</div>
<a href="{{songURI}}" class="spotify-logo">
<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Spotify</title><path d="M12 0C5.4 0 0 5.4 0 12s5.4 12 12 12 12-5.4 12-12S18.66 0 12 0zm5.521 17.34c-.24.359-.66.48-1.021.24-2.82-1.74-6.36-2.101-10.561-1.141-.418.122-.779-.179-.899-.539-.12-.421.18-.78.54-.9 4.56-1.021 8.52-.6 11.64 1.32.42.18.479.659.301 1.02zm1.44-3.3c-.301.42-.841.6-1.262.3-3.239-1.98-8.159-2.58-11.939-1.38-.479.12-1.02-.12-1.14-.6-.12-.48.12-1.021.6-1.141C9.6 9.9 15 10.561 18.72 12.84c.361.181.54.78.241 1.2zm.12-3.36C15.24 8.4 8.82 8.16 5.16 9.301c-.6.179-1.2-.181-1.38-.721-.18-.601.18-1.2.72-1.381 4.26-1.26 11.28-1.02 15.721 1.621.539.3.719 1.02.419 1.56-.299.421-1.02.599-1.559.3z"/></svg>
</a>
</div>
</div>

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB