added functions to fetch trakt movie history and combine episode and movie titles
This commit is contained in:
parent
7c14805c4f
commit
0fc03e780c
1 changed files with 17 additions and 0 deletions
17
utils.js
17
utils.js
|
|
@ -119,6 +119,23 @@ export async function getTraktEpisode(username, id, showImage = true) {
|
|||
return `${cleanTitle} `
|
||||
}
|
||||
|
||||
export async function getTraktMovie(username, showImage = true) {
|
||||
const res = await fetch(
|
||||
`https://trakt.tv/users/${username}/history/movies/added/asc.atom?slurm=${process.env.TRAKT_SLURM}`,
|
||||
)
|
||||
const data = await res.text()
|
||||
const dom = new JSDOM(data)
|
||||
const entry = dom.window.document.querySelector('entry')
|
||||
const title = entry.querySelector('title').textContent
|
||||
return markdownCharEscape(title)
|
||||
}
|
||||
|
||||
export async function getTraktEpisodeAndMovie(username, id, showImage = true) {
|
||||
const episode = await getTraktEpisode(username, id, showImage)
|
||||
const movie = await getTraktMovie(username, showImage)
|
||||
return `${episode} and ${movie}`
|
||||
}
|
||||
|
||||
export async function getReadingBooklogr(booklogrUrl, booklogrUser) {
|
||||
const res = await fetch(`${booklogrUrl}/v1/profiles/${booklogrUser}`)
|
||||
const data = await res.json()
|
||||
|
|
|
|||
Loading…
Reference in a new issue