updated getTraktMovie to include movie ID and modify title display based on showImage flag

This commit is contained in:
dylan 2025-12-25 22:53:54 +00:00
parent 7656f7f501
commit 2a3bb8301c

View file

@ -169,7 +169,7 @@ export async function getTraktEpisode(username, id, showImage = true) {
return { text, url: link } return { text, url: link }
} }
export async function getTraktMovie(username, showImage = true) { export async function getTraktMovie(username, id, showImage = true) {
const res = await fetch( const res = await fetch(
`https://trakt.tv/users/${username}/history/movies/added/asc.atom?slurm=${process.env.TRAKT_SLURM}`, `https://trakt.tv/users/${username}/history/movies/added/asc.atom?slurm=${process.env.TRAKT_SLURM}`,
) )
@ -178,7 +178,10 @@ export async function getTraktMovie(username, showImage = true) {
const entry = dom.window.document.querySelector('entry') const entry = dom.window.document.querySelector('entry')
const title = entry.querySelector('title').textContent const title = entry.querySelector('title').textContent
const link = entry.querySelector('link').getAttribute('href') const link = entry.querySelector('link').getAttribute('href')
return { text: title, url: link } const text = !showImage
? title
: `${title} ![${title}](https://widgets.trakt.tv/users/${id}/watched/thumb@2x.jpg?type=movie&image_only=1)`
return { text, url: link }
} }
export async function getTraktEpisodeAndMovie(username, id, showImage = true) { export async function getTraktEpisodeAndMovie(username, id, showImage = true) {