Skip to content

Commit

Permalink
Fix only confidence of 2 pickaparts in scrobble
Browse files Browse the repository at this point in the history
  • Loading branch information
PapiOphidian committed Nov 17, 2023
1 parent ec4ec50 commit 71da007
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/runtime-website/src/music/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ export class Queue {
for (const row of connections ?? []) {
const params = new URLSearchParams({
method: "track.scrobble",
"artist[0]": pickedApart.confidence === 2 ? pickedApart.artist : track.author,
"track[0]": pickedApart.confidence === 2 ? pickedApart.title : track.title,
"artist[0]": pickedApart.artist,
"track[0]": pickedApart.title,
"timestamp[0]": String(Math.floor(Date.now() / 1000)),
"duration[0]": String(track.lengthSeconds),
"chosenByUser[0]": track.requester.id === row.user_id ? "1" : "0",
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-website/src/music/tracktypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export class Track {

try {
lyrics = await common.genius.getLyrics(picked.title, picked.artist)
if (!lyrics && picked.confidence === 1) lyrics = await common.genius.getLyrics(picked.artist, picked.title)
if (!lyrics && picked.artist && picked.confidence === 1) lyrics = await common.genius.getLyrics(picked.artist, picked.title)
} catch {
lyrics = null
}
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-website/src/music/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const common = {

genius: {
getLyrics(title: string, artist: string | undefined = void 0): Promise<string | null> {
return fetch(`https://some-random-api.ml/lyrics?title=${encodeURIComponent(`${artist} - ${title}`)}`)
return fetch(`https://some-random-api.ml/lyrics?title=${encodeURIComponent(artist ? `${artist} - ${title}` : title)}`)
.then(d => d.json())
.then(j => j.lyrics ?? j.error ?? null)
.catch(() => null)
Expand Down

0 comments on commit 71da007

Please sign in to comment.