I’m trying to set an rest sensor to grab my latest watched movies and tv shows from trakt.tv.
Been arguing with ChatGPT for hours now, going round and round in circles. This is the closest I’ve gotten to a result:
sensor:
- platform: rest
name: Trakt Raw Episodes
resource: https://api.trakt.tv/sync/history/episodes?limit=10
headers:
Authorization: "Bearer my_trakt_access_token"
Content-Type: "application/json"
trakt-api-version: "2"
trakt-api-key: "my_trakt_client_id"
value_template: "{{ value_json[0]['episode']['title'] }}"
json_attributes_path: "$[0]" # Path to the first item
json_attributes:
- show
- episode
scan_interval: 1800 # 30 minutes
it gives me these attributes for the latest watched serie:
show:
title: Those About to Die
year: 2024
ids:
trakt: 201759
slug: those-about-to-die
tvdb: 422772
imdb: tt10569934
tmdb: 218589
tvrage: null
episode:
season: 1
number: 1
title: Rise or Die
ids:
trakt: 7252146
tvdb: 9567190
imdb: tt21400864
tmdb: 4170850
tvrage: null
How can I get for the last 10?
Running a api test gives me this result:
curl -H "Authorization: Bearer your_trakt_access_token" \
-H "Content-Type: application/json" \
-H "trakt-api-version: 2" \
-H "trakt-api-key: your_trakt_client_id" \
"https://api.trakt.tv/sync/history/episodes?limit=10"
content:
- id: 9863756987
watched_at: "2024-07-29T16:16:11.000Z"
action: scrobble
type: episode
episode:
season: 1
number: 1
title: Rise or Die
ids:
trakt: 7252146
tvdb: 9567190
imdb: tt21400864
tmdb: 4170850
tvrage: null
show:
title: Those About to Die
year: 2024
ids:
trakt: 201759
slug: those-about-to-die
tvdb: 422772
imdb: tt10569934
tmdb: 218589
tvrage: null
and 9 more shows/episodes