Last.fm music provider (#73)

This commit is contained in:
Raphaël Thériault
2021-01-22 15:40:38 -05:00
committed by GitHub
parent be806eaf94
commit 7ef8e65951
7 changed files with 151 additions and 2 deletions

View File

@@ -1083,6 +1083,69 @@
})
}
}
//Last.fm api
if (/^https:..ws.audioscrobbler.com/.test(url)) {
//Get recently played tracks
if (/user.getrecenttracks/.test(url)) {
console.debug(`metrics/compute/mocks > mocking lastfm api result > ${url}`)
const artist = faker.random.word()
const album = faker.random.words(3)
const track = faker.random.words(5)
const date = faker.date.recent()
return ({
status:200,
data:{
recenttracks:{
"@attr":{
page:"1",
perPage:"1",
user:"RJ",
total:"100",
pages:"100",
},
track:[
{
artist:{
mbid:"",
"#text":artist,
},
album:{
mbid:"",
"#text":album,
},
image:[
{
size:"small",
"#text":faker.image.abstract(),
},
{
size:"medium",
"#text":faker.image.abstract(),
},
{
size:"large",
"#text":faker.image.abstract(),
},
{
size:"extralarge",
"#text":faker.image.abstract(),
},
],
streamable:"0",
date:{
uts:Math.floor(date.getTime() / 1000),
"#text":date.toUTCString().slice(5, 22),
},
url:faker.internet.url(),
name:track,
mbid:"",
},
],
},
},
})
}
}
//Twitter api
if (/^https:..api.twitter.com/.test(url)) {
//Get user profile