-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from aberigle/add-lastfm
Add nowlistening
- Loading branch information
Showing
11 changed files
with
283 additions
and
180 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const url : string = "https://ws.audioscrobbler.com/2.0/" | ||
const example: string = '{"artist":{"mbid":"5a85c140-dcf9-4dd2-b2c8-aff0471549f3","#text":"Sam Smith"},"streamable":"0","image":[{"size":"small","#text":"https://lastfm.freetls.fastly.net/i/u/34s/649956aa44ebfbb5b6153edbd70b0da0.jpg"},{"size":"medium","#text":"https://lastfm.freetls.fastly.net/i/u/64s/649956aa44ebfbb5b6153edbd70b0da0.jpg"},{"size":"large","#text":"https://lastfm.freetls.fastly.net/i/u/174s/649956aa44ebfbb5b6153edbd70b0da0.jpg"},{"size":"extralarge","#text":"https://lastfm.freetls.fastly.net/i/u/300x300/649956aa44ebfbb5b6153edbd70b0da0.jpg"}],"mbid":"a2cded0a-6216-41f1-b9da-dc90738e5d46","album":{"mbid":"","#text":"Gloria"},"name":"How to Cry","@attr":{"nowplaying":"true"},"url":"https://www.last.fm/music/Sam+Smith/_/How+to+Cry"}' | ||
|
||
export async function getNowPlaying(user: string) { | ||
if (!import.meta.env.PROD) return JSON.parse(example) | ||
|
||
const uri : URL = new URL(url) | ||
|
||
uri.searchParams.append("format", "json") | ||
uri.searchParams.append("method", "user.getrecenttracks") | ||
uri.searchParams.append("user", user) | ||
uri.searchParams.append("limit", "1") | ||
uri.searchParams.append("api_key", "9ad1ebab368b74b48c4fbd6cf095087e") | ||
|
||
const response = await fetch(uri) | ||
const body = await response.json() | ||
return body.recenttracks?.track?.find((track : any) => track["@attr"]?.nowplaying) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
:root { | ||
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; | ||
line-height: 1.5; | ||
font-weight: 400; | ||
|
||
color-scheme: light dark; | ||
color: rgba(255, 255, 255, 0.87); | ||
background-color: #242424; | ||
|
||
font-synthesis: none; | ||
text-rendering: optimizeLegibility; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
-webkit-text-size-adjust: 100%; | ||
} | ||
|
||
body { | ||
margin: 0; | ||
display: flex; | ||
justify-content: space-around; | ||
min-height: 100vh; | ||
} | ||
|
||
#overlay { | ||
background-color: rgba(0, 0, 0, .4); | ||
z-index: 0; | ||
transition: all 300ms; | ||
position: absolute; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
#background { | ||
background-repeat: no-repeat; | ||
background-size: cover; | ||
background-position: center; | ||
z-index: -1; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
@media screen and (max-width: 480px) { | ||
:root { | ||
font-size: .8em; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
|
||
footer { | ||
width: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
z-index: 2; | ||
transition: all 300ms; | ||
position: absolute; | ||
bottom: 0; | ||
color: white; | ||
} | ||
|
||
#copyright { | ||
margin-left: 1em; | ||
color: white; | ||
text-decoration: none; | ||
} | ||
|
||
.uhurus { | ||
margin-right: 1em; | ||
} | ||
|
||
.uhurus .icon { | ||
display: inline-block; | ||
width: 1em; | ||
} | ||
|
||
.uhurus a { | ||
background-color: #00a362; | ||
color: white; | ||
font-weight: 400; | ||
|
||
text-decoration: none; | ||
padding: 0; | ||
transition: all 300ms; | ||
} | ||
|
||
.uhurus a:hover { | ||
background-color: #00a362; | ||
color:white; | ||
border-radius: 10%; | ||
padding: .2em 0; | ||
box-shadow: 0 0 .3em #00a362; | ||
} | ||
|
||
.clean #main { | ||
margin-top: -2em; | ||
opacity: 0; | ||
} | ||
|
||
.clean #overlay { | ||
background-color: transparent; | ||
} | ||
|
||
.clean footer { | ||
background-color: rgba(0, 0, 0, .4); | ||
box-shadow: 0 0 2em 2em rgba(0, 0, 0, .4); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import "./base.css" | ||
import "./main.css" | ||
import "./footer.css" | ||
import "./lastfm.css" |
Oops, something went wrong.