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

@@ -180,7 +180,7 @@
if (plugins.music.enabled) {
plugins.music.token = input.string("plugin_music_token")
info("Music token", plugins.music.token, {token:true})
for (const option of ["provider", "mode", "playlist"])
for (const option of ["provider", "mode", "playlist", "user"])
info(`Music ${option}`, q[`music.${option}`] = input.string(`plugin_music_${option}`))
for (const option of ["limit"])
info(`Music ${option}`, q[`music.${option}`] = input.number(`plugin_music_${option}`))

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

View File

@@ -94,8 +94,10 @@
"habits.days":{text:"Max events age", type:"number", min:1, max:30},
"habits.facts":{text:"Display facts", type:"boolean"},
"habits.charts":{text:"Display charts", type:"boolean"},
"music.provider":{text:"Provider", placeholder:"spotify"},
"music.playlist":{text:"Playlist url", placeholder:"https://embed.music.apple.com/en/playlist/"},
"music.limit":{text:"Limit", type:"number", min:1, max:100},
"music.user":{text:"Username", placeholder:"(default to GitHub login)"},
"posts.limit":{text:"Limit", type:"number", min:1, max:30},
"posts.user":{text:"Username", placeholder:"(default to GitHub login)"},
"posts.source":{text:"Source", type:"select", values:["dev.to"]},
@@ -124,8 +126,10 @@
"habits.days":14,
"habits.facts":true,
"habits.charts":false,
"music.provider":"",
"music.playlist":"",
"music.limit":4,
"music.user":"",
"posts.limit":4,
"posts.user":"",
"posts.source":"dev.to",