Taxel / PlexTraktSync

A python script that syncs the movies, shows and ratings between trakt and Plex (without needing a PlexPass or Trakt VIP subscription)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Watchlist sync deletes items on one side, but it should ignore syncing that side instead

profucius opened this issue · comments

Confirmation

  • I have read the README.md on the project homepage
  • I have checked if identical issue already exists
  • I have tried downgrading to find version that can be used as a workaround

The problem

When using PlexTraktSync sync command, the script fully syncs my watchlist on Plex to Trakt, and then deletes any Trakt watchlist that were not on Plex. I do not want anything deleted on Trakt, and that should not happen just because I have watchlist: false set in config.

Steps to reproduce the behavior

  1. Set config.yml
  2. Run plextraktsync sync
  3. Watch the command output as it syncs both watchlists.

Expected behavior

The script should sync any items in the Plex Watchlist to the Trakt Watchlist (watchlist: true), but then not sync the other way around at all (watchlist: false), especially not delete anything on Trakt Watchlist.

Config file contents

sync:
  plex_to_trakt:

    watchlist: true
  trakt_to_plex:

    watchlist: false

Install method

pipx

Version

0.29.8

Python Version

3.11.0

Plex Server Version

1.40.0.7998

Operating System and Version

Windows 11 22H2

This seems like a feature request. please edit your config here in the issue and keep only relevant options (watchlist) and remove empty prompts.

but what you ask seems needs another config option.

I have updated my original post. Below are more details about what I am requesting here.

If this is a feature request instead, then please consider this:

The current config terminology "watchlist" may need to be made more specific to ensure a clear understanding of the functionality. I look at the config file and see watchlist=true and I think "It will copy items in this direction only" whereas what it actually does is "It will copy items in this direction, AND delete to make a mirror in this direction, but only if they are both set to true", which is certainly confusing.

Compounding the confusion is that if both sides are set to watchlist=true, then it will mirror, which includes deleting from the source. But if only one side is true and one side is false, it will still copy to both sides, just not delete from one side. That does not make intuitive sense. If that is the intended feature, then perhaps the terminology in the config file should be changed from "watchlist" to "watchlist_mirror".

The functionality that I'm requesting is: If "watchlist" is set to true, it will copy in a direction but NOT mirror (aka, not delete from either side). And if set to false, then do not copy at all.


In plain language, I want to be able to copy Watchlist items from Plex to Trakt, but not copy Watchlist items from Trakt to Plex. The end result would be Plex always moves items into Trakt, so that Trakt is the kindof "master list", and so Trakt does NOT copy back over to Plex again.

The reason I am requesting for this is because I use another script that reads both my Plex and Trakt watchlists, and if they both have the same items (aka traditional sync), then it becomes a duplication nightmare. If I want to remove an item from the watchlist, I have to always remember to remove it from both Plex and Trakt watchlists, because otherwise PlexTraktSync will re-copy the deleted item from one back over to the other again.

An alternative to this idea would be for the script to include "differencing", aka to track when an item is removed from one watchlist and not copy it back to the other one. But that seems like even more work than what I am asking for, which is simply to have a line in the config file allow for copying one direction, but not the other, for the watchlists.

I hope this makes sense. I'm happy to rephrase or elaborate if needed.

These open issues relate in some sense:

Current logic of watchlist sync is here:

  • def watchlist_sync_item(self, m: Media, dry_run=False):
    if m.plex is None:
    if self.config.update_plex_wl:
    self.logger.info(f"Skipping {m.title_link} from Trakt watchlist because not found in Plex Discover", extra={"markup": True})
    elif self.config.update_trakt_wl:
    self.logger.info(f"Removing {m.title_link} from Trakt watchlist", extra={"markup": True})
    if not dry_run:
    m.remove_from_trakt_watchlist()
    return
    if m in self.plex_wl:
    if m not in self.trakt_wl:
    if self.config.update_trakt_wl:
    self.logger.info(f"Adding {m.title_link} to Trakt watchlist", extra={"markup": True})
    if not dry_run:
    m.add_to_trakt_watchlist()
    else:
    self.logger.info(f"Removing {m.title_link} from Plex watchlist", extra={"markup": True})
    if not dry_run:
    m.remove_from_plex_watchlist()
    else:
    # Plex Online search is inaccurate, and it doesn't offer search by id.
    # Remove known match from trakt watchlist, so that the search would not be attempted.
    # Example, trakt id 187634 where title mismatches:
    # - "The Vortex": https://trakt.tv/movies/the-vortex-2012
    # - "Big Bad Bugs": https://app.plex.tv/desktop/#!/provider/tv.plex.provider.vod/details?key=%2Flibrary%2Fmetadata%2F5d776b1cad5437001f7936f4
    del self.trakt_wl[m]
    elif m in self.trakt_wl:
    if self.config.update_plex_wl:
    self.logger.info(f"Adding {m.title_link} to Plex watchlist", extra={"markup": True})
    if not dry_run:
    m.add_to_plex_watchlist()
    else:
    self.logger.info(f"Removing {m.title_link} from Trakt watchlist", extra={"markup": True})
    if not dry_run:
    m.remove_from_trakt_watchlist()

Personally, I want this flow from playlist syncing:

  1. use plex watchlist, not plex playlist (watchlist_as_playlist: false)
  2. keep plex and trakt in sync (both watchlist: true)
  3. remove played items from the playlists (not yet supported)
  4. do not re-add items to playlist if they have been watched. not sure how to handle re-watches (not yet supported)

if both plex and trakt are set to watchlist = true .... shouldn't the script MIRROR those watchlists to they match exactly? (same watchlist on both sides)

sync:
  plex_to_trakt:
    watchlist: true

  trakt_to_plex:
    watchlist: true

Right now I have both watchlists set to true. But, for whatever reason, if I delete something from my PLEX watchlist, it doesn't remove it from my Trakt watchlist. The script simply RE-ADDS what I just removed in PLEX since it's still listed on my Trakt watchlist. But, if I delete something from my TRAKT watchlist, the script will remove it from my PLEX watchlist.

@JeanGionet please see already reported issues list from here:

there's no state stored for PlexTraktSync for it to know it if item was missing on one list, or you removed it.

Is there any update on this?

It would be nice if we could choose if we want to to append the content from a Plex watchlist to a Trakt watchlist and vice versa.
Rather than mirroring the entire content.

Currently it can be done only if you set both settings in True but in my case that it is not desired.

  plex_to_trakt:
    watchlist: true

  trakt_to_plex:
    watchlist: true

What I am looking is to have this option when you have one of the below settings:

  plex_to_trakt:
    watchlist: true

  trakt_to_plex:
    watchlist: false

OR

  plex_to_trakt:
    watchlist: false

  trakt_to_plex:
    watchlist: true

Based on the code posted above, it could be done by adding an extra condition before removing content.

 def watchlist_sync_item(self, m: Media, dry_run=False): 
     if m.plex is None: 
         if self.config.update_plex_wl: 
             self.logger.info(f"Skipping {m.title_link} from Trakt watchlist because not found in Plex Discover", extra={"markup": True}) 
         elif self.config.update_trakt_wl: 
             self.logger.info(f"Removing {m.title_link} from Trakt watchlist", extra={"markup": True}) 
             if not dry_run and not self.config.append_content: # append_content = new setting in config
                 m.remove_from_trakt_watchlist() 
         return 
     if m in self.plex_wl: 
         if m not in self.trakt_wl: 
             if self.config.update_trakt_wl: 
                 self.logger.info(f"Adding {m.title_link} to Trakt watchlist", extra={"markup": True}) 
                 if not dry_run: 
                     m.add_to_trakt_watchlist() 
             else: 
                 self.logger.info(f"Removing {m.title_link} from Plex watchlist", extra={"markup": True}) 
                 if not dry_run and not self.config.append_content: # append_content = new setting in config
                     m.remove_from_plex_watchlist() 
         else: 
             # Plex Online search is inaccurate, and it doesn't offer search by id. 
             # Remove known match from trakt watchlist, so that the search would not be attempted. 
             # Example, trakt id 187634 where title mismatches: 
             #  - "The Vortex": https://trakt.tv/movies/the-vortex-2012 
             #  - "Big Bad Bugs": https://app.plex.tv/desktop/#!/provider/tv.plex.provider.vod/details?key=%2Flibrary%2Fmetadata%2F5d776b1cad5437001f7936f4 
             del self.trakt_wl[m] 
     elif m in self.trakt_wl: 
         if self.config.update_plex_wl: 
             self.logger.info(f"Adding {m.title_link} to Plex watchlist", extra={"markup": True}) 
             if not dry_run: 
                 m.add_to_plex_watchlist() 
         else: 
             self.logger.info(f"Removing {m.title_link} from Trakt watchlist", extra={"markup": True}) 
             if not dry_run and not self.config.append_content: # append_content = new setting in config
                 m.remove_from_trakt_watchlist()

please submit code changes as pull requests.