Taxel / PlexTraktSync

A python script that syncs the movies, shows and ratings between trakt and Plex (without needing a PlexPass or Trakt VIP subscription)
MIT License
1.61k stars 105 forks source link

Existing Trakt ratings are set to the same value and with a new date if a rating with the same value exist in Plex #1805

Closed SebbeJohansson closed 8 months ago

SebbeJohansson commented 8 months ago

Confirmation

The problem

Running the script with the default config file causes all ratings in Trakt with the same value as in Plex to have a new date set as when it was first run. This is not ideal for historical references. For me personally this means that all the dates for any ratings I've done for the last 10 years are now wrong. image

This problem is probably only a thing if you have the same rating set in both applications either manually or by a different application/install of the same application.

Steps to reproduce the behavior

  1. Setup the script with docker.
  2. Go through login and authentication against both trakt and plex.
  3. Run the script with docker-compose run --rm plextraktsync sync
  4. Check the ratings on trakt.
  5. Profit.

Error trace / logs

No response

Expected behavior

I expect only new ratings to update the date. If the rating is set to the same rating as it is already in trakt it makes no sense to re-set it.

Inspect of problematic items

No response

Workarounds

The only option for me right now is to NOT sync ratings at all to trakt.

Install method

docker-compose

Config file contents

Default config.

Version

0.28.18

Python Version

3.12.2

Plex Server Version

1.32.8.7639-fb6452ebf,

Operating System and Version

Ubuntu 20.04

glensc commented 8 months ago

didn't know you can submit date when adding rating... does trakt api support it?

simonc56 commented 8 months ago

Indeed, Trakt API have rated_at value when adding a rating.

  "movies": [
    {
      "rated_at": "2014-09-01T09:10:11.000Z",
      "rating": 5,
      "title": "Batman Begins",
      "year": 2005,
      "ids": {
        "trakt": 1,
        "slug": "batman-begins-2005",
        "imdb": "tt0372784",
        "tmdb": 272
      }
    },
    {
      "rating": 10,
      "ids": {
        "imdb": "tt0000111"
      }
    }
  ]
SebbeJohansson commented 8 months ago

@glensc All ratings you have ever created have a date so I just assumed! 😁

glensc commented 8 months ago

this app doesn't send the date, trakt just assumes current date. i have not looked does trakt api support sending date.

SebbeJohansson commented 8 months ago

@glensc yes it does. @simonc56 included the whole body that you can send before and that includes "rated_at".

glensc commented 8 months ago

Now the second part needs to support it as well. Does plex offer date when rating was made?

SebbeJohansson commented 8 months ago

@glensc I have no idea. I took a quick look in PyTrakt and found this: https://github.com/moogar0880/PyTrakt/blob/8a6d4f168a858447014fb4c2c0efceb47b30ebb7/trakt/sync.py#L40-L55

For me its just down to trakt supporting it. Plex doesn't display the ratings in a chronological order, so its not a big deal (for me) if plex doesn't have the correct date. Trakt: image Plex: image

glensc commented 8 months ago

@SebbeJohansson your response does not make any sense. what date would you send to trakt then if plex doesn't provide rating date? current date? but that's the existing behaviour already!

SebbeJohansson commented 8 months ago

@glensc Plex does have dates, it just doesn't display it anywhere. Sorry I wasn't clear. Since plex doesn't have a thing to display the date, it doesn't matter what the date inside of plex is except for when syncing to trakt.

glensc commented 8 months ago

You can try this PR at some point:

I could not test myself as trakt.tv seems to have availability issues.

glensc commented 8 months ago

Expected behavior

I expect only new ratings to update the date. If the rating is set to the same rating as it is already in trakt it makes no sense to re-set it.

In fact. this app does not update rating if rating is already in sync:

so, you could sync one way first: trakt to plex, then it will not overwrite the historic values.

SebbeJohansson commented 8 months ago

Could it be worth it to have a warning or something similar? I doubt I'm the only trakt user who cares about their dates and historical data.

glensc commented 8 months ago

Warning about what?

SebbeJohansson commented 8 months ago

That if you run it like I did (default config) all ratings in trakt will get a new date. Atleast until a fix is tested and released.

glensc commented 8 months ago

Um, why bother? or you are saying that the same can happen after the PR I created? Did you test it?

glensc commented 8 months ago

Um, why bother? or you are saying that the same can happen after the PR I created? Did you test it?

glensc commented 8 months ago

Um, why bother? or you are saying that the same can happen after the PR I created? Did you test it?

glensc commented 8 months ago

and again: this app does not overwrite ratings that are already there with same value (I linked you exact code that skips). so overwrite can only happen if your plex had different values. it's expected to overwrite as in default config plex has priority. if plex did not have ratings, there would not be any ratings present to sync to trakt.

are you saying something else happened?

SebbeJohansson commented 8 months ago

Haven't been able to test the PR. But if you think that it fixes the issue then I guess it's no need to add any docs about it. Just sounded like it might take a long time until the code is in the app, while a change to the Readme takes just 2 minutes.

My plex had no rating at all when I synced with default settings, while trakt had thousands. This has happened twice for me with two different installs and plex accounts. So I'm not convinced that what you think is true. Sadly Im not gonna be able to test with fresh accounts again for some time.

glensc commented 8 months ago

I myself create backup with this tool:

luckily I never needed it to restore anything, so I'm not sure how to use the backup :)

glensc commented 8 months ago

@SebbeJohansson regarding warning, sure, send a pr if it can cause overwrite, and then can discuss how can it be fixed