dylandoamaral / trakt-integration

A Trakt integration for Home Assistant compatible with upcoming media card
MIT License
30 stars 12 forks source link

Make recommandation sensors compatible with upcoming-media-card #32

Closed thomasgermain closed 2 years ago

thomasgermain commented 2 years ago

Hello,

I just give a try to the integration; It works quite well, but I found out that some sensors (see below) are not compatible with upcoming-media-card, their doc says:

The first item in your JSON must contain these keys to set your defaults: title_default, line1_default, line2_default, line3_default, line4_default, and icon. The default text contents are set exactly like the card's text content config and use the same keywords. The default icon takes an mdi icon mdi:arrow-down.

Here is my integration config

trakt_tv:
  language: fr
  sensors:
    upcoming:
      show:
        days_to_fetch: 90
        max_medias: 5
      new_show:
        days_to_fetch: 90
        max_medias: 5
      premiere:
        days_to_fetch: 90
        max_medias: 5
      movie:
        days_to_fetch: 90
        max_medias: 10
    recommendation:
      show:
        max_medias: 3
      movie:
        max_medias: 10

It produces compatible sensors (upcoming sensors)

Here is an example of attributes:

data: 
- title_default: $title
  line1_default: $episode
  line2_default: $release
  line3_default: $rating - $runtime
  line4_default: $number - $studio
  icon: mdi:arrow-down-bold
- title: Stranger Things
  poster: https://image.tmdb.org/t/p/w500/bR6IRoQqgkXIHgkFeXwwLwyjEMU.jpg
  fanart: https://image.tmdb.org/t/p/w500/56v2KjBlU4XaOv9rVYEQypROD7P.jpg
  genres:
    - Drame
    - Mystère
    - Science-Fiction & Fantastique
  rating: 8.6
  studio: Netflix
  episode: 'Chapter One: The Hellfire Club'
  number: S04E01
  release: $day, $date $time
  airdate: '2022-05-27T07:00:00Z'

unit_of_measurement: items
icon: mdi:calendar
friendly_name: Trakt Upcoming Premieres

But the recommandation sensor are not compatible, for example (defaults are missing):

unit_of_measurement: shows icon: mdi:movie friendly_name: Trakt Recommendation Shows



It would be nice to have recommandation sensors compatible.

Thanks,

Thomas
dylandoamaral commented 2 years ago

It totally should be compatible, I will fix that !

thomasgermain commented 2 years ago

I can't get it to work :confused:

I can see there is now a first item at the beginning of the list for sensor.trakt_recommendation_movies:

data: 
- title_default: $title
  line1_default: $episode
  line2_default: $release
  line3_default: $rating - $runtime
  line4_default: $number - $studio
  icon: mdi:arrow-down-bold
- title: Deadpool
  poster: https://image.tmdb.org/t/p/w500/z5VjcCEioj2c2dvxmoqBW0Rj8Xj.jpg
  fanart: https://image.tmdb.org/t/p/w500/en971MEXui9diirXlogOrPKmsEn.jpg
  genres:
    - Action
    - Aventure
    - Comédie
  rating: 7.6
  studio: 20th Century Fox
  runtime: 109
[...]

But for for movie it uses the same defaults as shows, but apparently $episode and $number are only available for shows.

Anyway, I manually modified (through dev tool) attributes like the following, but it still doesn't work:

data:
  - title_default: $title
    line1_default: $empty
    line2_default: $empty
    line3_default: $empty
    line4_default: $empty
    icon: mdi:arrow-down-bold
  - title: Deadpool
    poster: https://image.tmdb.org/t/p/w500/z5VjcCEioj2c2dvxmoqBW0Rj8Xj.jpg
    fanart: https://image.tmdb.org/t/p/w500/en971MEXui9diirXlogOrPKmsEn.jpg
    genres:
      - Action
      - Aventure
      - Comédie
    rating: 7.6
    studio: 20th Century Fox
    runtime: 109
[...]

I also tested with sensor.trakt_recommendation_shows sensor, but same result.

I have no javascript error coming from the custom:upcoming-media-card :confused:

thomasgermain commented 2 years ago

Got it ! (Sorry for the double post)

Each item must contain an 'airdate', if none exists the item is skipped. This and a poster image are the only required items.

I just checked, none of the item of recommendation sensors has an airdate

dylandoamaral commented 2 years ago

It is okay, thank you, I will try to check that as soon as possible ! Thank you for your feedback ;).

dylandoamaral commented 2 years ago

I hope it will works now, if it is not, don't hesitate to open this issue again.

thomasgermain commented 2 years ago

It"s working correctly for recommandation sensors :+1: Thanks :) But there is a new issue, air date for shows is always airdate: '0001-01-01T00:00:00Z' :confused:. Do you want me to create another isssue ?

dylandoamaral commented 2 years ago

Hmmm this is fun, I thought python minimum date would be 1970-01-01. I use a best effort algorithm to get the air date since trakt doesn't give us this date on recommendation. I will still create a new issue to improve this algorithm.