Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync watched status and ratings with Plex Discover #1676

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

simonc56
Copy link
Collaborator

@simonc56 simonc56 commented Dec 26, 2023

🚧 Work in progress 🚧

Adds sync of watched status and ratings between Trakt and Plex even if you don't have the media in your Plex library.

Objective is to sync watched status of :

  • movies
  • episodes

and ratings of :

  • movies
  • shows
  • seasons
  • episodes

both ways between Trakt and Plex items not in the library. This feature doesn't work with managed users.

Side effect : when disabling a trakt watched status or rating, it will be back at next sync because Plex keeps it in its cloud database. Users may think it's a bug (see #1080).

ℹ️ You need to enable the Sync Watch states and Ratings to make Plex save the watched status and ratings of your medias after you delete them from your Plex server.


⚠️ Early development

To test this draft PR at your own risks (remember the --dry-run option ) :

  1. set watched_status and plex_online to true
  2. run a full sync

Currently, sync with Plex Discover is very slow (1 it/sec) because batch is not implemented yet for Plexapi Discover items (pkkid/python-plexapi#1090).

Do not hesitate to test and give feedback if you feel confortable with testing, so we can make this feature live asap 👍

closes #1142

@simonc56
Copy link
Collaborator Author

Many movies search on Plex Discover fail with the 30 items result limit.
Maybe using the year could improve results.

Examples of failed Plex search with resolve_trakt() :

Up (2009)
Her (2013)
The Game (1997)
Masquerade (2022)
Christmas & Co (2017)
The Last Frontier (2020)
Premonitions (2019)
RED (2010)

@simonc56 simonc56 force-pushed the plex-cloud-watched-status branch from e3cacdf to 6006102 Compare December 26, 2023 20:59
@simonc56 simonc56 force-pushed the plex-cloud-watched-status branch from 6006102 to 193a1f2 Compare December 27, 2023 13:24
@simonc56 simonc56 force-pushed the plex-cloud-watched-status branch from 193a1f2 to 9fa006b Compare December 27, 2023 13:26
@simonc56
Copy link
Collaborator Author

This feature could help to have fast 2-way sync with Plex Discover :

season = r[index]["number"]
number = None
ids = r[index]["ids"]
yield trakt_types[index](
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

point of yield in the other method was if you used @flatten_dict. how does it work without it for you? not tested code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reporting this.
I need to dive in this code again but have no time for this at the moment.
It was tested successfuly on my library.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you put the generator to set():

set(self.trakt.ratings.items["movies"])

it's what the @flatten_set would do


return ratings

@flatten_dict
def ratings(self, media_type: str):
"""Yield trakt id and rating of all rated media_type"""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method does not yield. the whole method returns a dict. see @flatten_dict decorator

items = set(self.trakt.watched_movies.values()).union(
set(self.trakt.ratings.items["movies"])
)
# items is a set() of trakt.movies.Movies already watched or rated (can a user rate without watch?)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can definitely rate movie without watching it:

title=title,
show=show,
season=season,
number=number,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

season and number could be undefined. you should probably use elseif rather another if and throw for unsupported index value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants