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

Duplicate when multiple library with same movie/show #476

Closed
imjuzcy opened this issue Sep 6, 2021 · 30 comments · Fixed by #477 or #482
Closed

Duplicate when multiple library with same movie/show #476

imjuzcy opened this issue Sep 6, 2021 · 30 comments · Fixed by #477 or #482
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@imjuzcy
Copy link
Contributor

imjuzcy commented Sep 6, 2021

The problem

A description of what the bug is, including a complete traceback (if applicable)

When a movie is in two or more libraries, for example "Movies" and "4K Movies" (which I think is quite common for people to have), it is synced twice in total, once for each library, even though the movie had only been watched once.

Expected behavior

Only sync once if same movie/show is present in two or more libraries.

Steps to reproduce the behavior

Sync a show or movie that is present in two or more libraries.

Workarounds

Exclude all but one library of the same type, but this would mean if a movie is only in a library that is excluded, it won't be synced.

Environment

  • Version: 0.13.24
  • Python version: 3.9
  • Platform: Ubuntu
@imjuzcy imjuzcy added the bug Something isn't working label Sep 6, 2021
@simonc56
Copy link
Collaborator

simonc56 commented Sep 6, 2021

Can you give more details please.
Give a step-by-step description of problem and a step-by-step description of expected behaviour.

it is synced twice in total, once for each library, even though the movie had only been watched once.

Yeah, every movies are synced over and over every day, even if you just watch them once. 😄

Only sync once if same movie/show is present in two or more libraries.

Ok which one is the first to sync then ?

I think I understand the problem but I'd like you to tell exactly what you want.

Refs:

@glensc
Copy link
Collaborator

glensc commented Sep 6, 2021

you can explain the scenario by including "inspect" output of both movies. the command should print the play history of your items.

python3 -m plex_trakt_sync inspect <movie_id> 

where movie_id is XXX from the url:

as likely what is happening is that you watched movie with imdb id=123 in one library, and on next sync run the same movie with the same imdb id is matched and marked as watched as well. I don't think it's recorded as a duplicate match in trakt, but in plex with the time of the sync.

it's indeed unclear what is the synced twice meaning here. adds two plays in trakt? marks both played in plex? adds multiple plays to one of the plex items?

@glensc
Copy link
Collaborator

glensc commented Sep 6, 2021

there's an easy workaround if you want to sync just watch status from plex to trakt:

  • use watch command

use sync command only for collection updating, not watches.

@glensc
Copy link
Collaborator

glensc commented Sep 6, 2021

perhaps it's possible to make PlexTraktSync to distinguish the same imdb match but different quality after we added the collection metadata support:

@imjuzcy
Copy link
Contributor Author

imjuzcy commented Sep 6, 2021

Okay so to describe the issue and what I expect to happen more precisely:

I have two movie libraries on my Plex Server, "Movies" and "4K Movies".

Let's say I watch "Avengers: Endgame" from the library "Movies", but I also have "Avengers: Endgame" in the library "4K Movies".

So even though I only watched the movie once from the library "Movies", in Plex, "Avengers: Endgame" is marked as watched in both libraries "Movies" and "4K Movies".

So when I run PlexTraktSync afterwards, it first parse the library "4K Movies", and when it sees "Avengers: Endgame" in this library is marked as watched, it tells Trakt that to mark it as watched. After it finished parsing "4K Movies", it parses "Movies", and sees "Avengers: Endgame" in this library again marked as watched, so it tells Trakt to mark it as watched again. So at the end you can see in https://trakt.tv/users/_username_/history that there is two records of "Avengers: Endgame" on the same date.

One workaround I can think of is to also record the time when the movie/episode was watched in the cache, and when PlexTraktSync finds a movie that is watched, it should compare the time when it was watched with the record before telling Trakt, to prevent "double syncing" of the same watch session.

@glensc glensc added enhancement New feature or request help wanted Extra attention is needed and removed bug Something isn't working labels Sep 7, 2021
@simonc56
Copy link
Collaborator

simonc56 commented Sep 7, 2021

@glensc I thought this PR #168 prevent this kind of problem.
A watched status by PlexTraktSync platform in Plex should not be synced back to trakt.

image

@simonc56
Copy link
Collaborator

simonc56 commented Sep 7, 2021

So even though I only watched the movie once from the library "Movies", in Plex, "Avengers: Endgame" is marked as watched in both libraries "Movies" and "4K Movies".

For now, that is the expected behaviour. You have watched the movie, no matter on which device or where or when (trakt->plex sync) or how.

@imjuzcy
Copy link
Contributor Author

imjuzcy commented Sep 7, 2021

@twolaw yes, I understand that that is expected behavior. But the issue is that in https://trakt.tv/users/_username_/history, synced items are shown twice, which is weird when the movie "Avengers: Endgame" only showed up once in last_update.log.

@imjuzcy
Copy link
Contributor Author

imjuzcy commented Sep 7, 2021

Upon further inspection, the line INFO: Marking as watched in Trakt: <tmdb:299534:<Movie:234617:Avengers-Endgame>> appears on console (CLI) twice with different ratingKey (234617 in this example), but only once in last_update.log.

Console:

...
INFO: Marking as watched in Trakt: <tmdb:299534:<Movie:234617:Avengers-Endgame>>
...
INFO: Marking as watched in Trakt: <tmdb:299534:<Movie:70762:Avengers-Endgame>>
...

last_update.log:

...
INFO: Marking as watched in Trakt: <tmdb:299534:<Movie:70762:Avengers-Endgame>>
...

@simonc56
Copy link
Collaborator

simonc56 commented Sep 7, 2021

This is normal, ratingKey is the Plex id. One for your HD version and one for your 4K version.
HD version watched status was sent at first sync. 4K watched status at second sync (the issue).

the issue is that in https://trakt.tv/users/_username_/history, synced items are shown twice, which is weird when the movie "Avengers: Endgame" only showed up once in last_update.log.

I agree, see my previous comment with a screenshot.

@imjuzcy
Copy link
Contributor Author

imjuzcy commented Sep 7, 2021

I agree, see my previous comment with a screenshot.

Maybe I misunderstood you, but I don't think it is syncing the watched status by PlexTraktSync platform in Plex back to trakt. If a movie is only available as HD in my Plex and not 4K, it'll only show up in trakt once. Only those that I have two versions of, will show up twice.

@glensc
Copy link
Collaborator

glensc commented Sep 7, 2021

@imjuzcy you haven't provided inspect command output asked previously.

@glensc
Copy link
Collaborator

glensc commented Sep 7, 2021

@twolaw #168 doesn't solve anything. there's no code that checks the platform.

however, as I already wrote, this issue problem could be solved by matching collection parameters:

@imjuzcy
Copy link
Contributor Author

imjuzcy commented Sep 7, 2021

So to systematically reproduce the issue:

  1. I set up two new libraries in Plex: "TestHD" and "Test4K"
  2. I copied a movie, "21 Bridges" that I have both 4K and HD version of to the respective libraries, and another movie "Stuber" to only "TestHD".
  3. So "TestHD" has two movies: "21 Bridges" and "Stuber", whereas "Test4K" has only one movie "21 Bridges"
  4. I go on Plex, go to "Test4K" and mark "21 Bridges" as played, and then go to "TestHD" and mark "Stuber" as played.
  5. I run PlexTraktSync.

Console output:

INFO: PlexTraktSync [83ded352: Merge pull request #470 from twolaw/plex-fallback-ip-for-docker @2021-09-06 16:27:56]
INFO: Syncing with Plex imjuzcy and Trakt imjuzcy
Sync Movies: True
Sync Shows: True
INFO: Loaded Trakt lists in 2.5 seconds
Plex Server version: 1.24.2.4973-2b1b51db9, updated at: 2021-09-07 10:26:23
Server has 4 libraries: ['Test4K', 'TestHD']
/home/ubuntu/PlexTraktSync/plex_trakt_sync/walker.py:122: TqdmExperimentalWarning: rich is experimental/alpha
  pb = self._progressbar(iterable, **kwargs)
INFO: Marking as watched in Trakt: <tmdb:535292:<Movie:328637:21-Bridges>>
Processing Test4K 100% ━━━━━━━━━━━━━━━━━━━━━ 1/1  [ 0:00:01 < 0:00:00 , ? it/s ]
INFO: Test4K processed in 1.4 seconds
INFO: Marking as watched in Trakt: <tmdb:535292:<Movie:328597:21-Bridges>>
INFO: Marking as watched in Trakt: <tmdb:513045:<Movie:328618:Stuber>>
Processing TestHD 100% ━━━━━━━━━━━━━━━━━━━━━ 2/2  [ 0:00:02 < 0:00:00 , 1 it/s ]
INFO: TestHD processed in 2.4 seconds
INFO: Updated plex watchlist in 0.0 seconds

last_update.log:

2021-09-07 10:29:40,721 INFO[PlexTraktSync]:PlexTraktSync [83ded352: Merge pull request #470 from twolaw/plex-fallback-ip-for-docker @2021-09-06 16:27:56]
2021-09-07 10:29:40,725 INFO[PlexTraktSync]:Syncing with Plex imjuzcy and Trakt imjuzcy
2021-09-07 10:29:43,224 INFO[PlexTraktSync]:Loaded Trakt lists in 2.5 seconds
2021-09-07 10:29:44,128 INFO[PlexTraktSync]:Marking as watched in Trakt: <tmdb:535292:<Movie:328637:21-Bridges>>
2021-09-07 10:29:44,624 INFO[PlexTraktSync]:Test4K processed in 1.4 seconds
2021-09-07 10:29:45,540 INFO[PlexTraktSync]:Marking as watched in Trakt: <tmdb:535292:<Movie:328597:21-Bridges>>
2021-09-07 10:29:46,543 INFO[PlexTraktSync]:Marking as watched in Trakt: <tmdb:513045:<Movie:328618:Stuber>>
2021-09-07 10:29:47,015 INFO[PlexTraktSync]:TestHD processed in 2.4 seconds
2021-09-07 10:29:47,015 INFO[PlexTraktSync]:Updated plex watchlist in 0.0 seconds
2021-09-07 10:29:47,745 INFO[PlexTraktSync]:Completed full sync in 7.0 seconds

Trakt history:
image

./plex_trakt_sync.sh inspect 328637:

PlexTraktSync inspect [83ded352: Merge pull request #470 from twolaw/plex-fallback-ip-for-docker @2021-09-06 16:27:56]
Inspecting 328637: <tmdb:535292:<Movie:328637:21-Bridges>>
URL: https://app.plex.tv/desktop/#!/server/1c500eb9a271e3a53e0c5dcb425908b9ccd818da/details?key=/library/metadata/328637
Media.Type: movie
Media.Guid: 'plex://movie/5d777067ad5437001f821436'
Media.Guids: [<Guid:imdb://tt8688634>, <Guid:tmdb://535292>, <Guid:tvdb://22403>]
Audio: '5.1(side)', 'English (DTS-HD MA 5.1)'
Video: 'hevc'
Guids:
  Guid: tmdb://535292, Id: 535292, Provider: tmdb
  Guid: tvdb://22403, Id: 22403, Provider: tvdb
  Guid: imdb://tt8688634, Id: tt8688634, Provider: imdb
Metadata: {'collected_at': '2020-11-27:T19:17:44.000Z', 'media_type': 'digital', 'resolution': 'uhd_4k', 'hdr': 'hdr10', 'audio': 'dts', 'audio_channels': '5.1'}
Trakt: https://trakt.tv/movies/387139
Watched on Plex: True
Watched on Trakt: True
Play history:
- 2021-09-07 10:29:21 by imjuzcy with Microsoft Edge on Microsoft Edge

./plex_trakt_sync.sh inspect 328597:

PlexTraktSync inspect [83ded352: Merge pull request #470 from twolaw/plex-fallback-ip-for-docker @2021-09-06 16:27:56]
Inspecting 328597: <tmdb:535292:<Movie:328597:21-Bridges>>
URL: https://app.plex.tv/desktop/#!/server/1c500eb9a271e3a53e0c5dcb425908b9ccd818da/details?key=/library/metadata/328597
Media.Type: movie
Media.Guid: 'plex://movie/5d777067ad5437001f821436'
Media.Guids: [<Guid:imdb://tt8688634>, <Guid:tmdb://535292>, <Guid:tvdb://22403>]
Audio: '5.1', 'English (HE-AAC 5.1)'
Video: 'hevc'
Guids:
  Guid: tmdb://535292, Id: 535292, Provider: tmdb
  Guid: tvdb://22403, Id: 22403, Provider: tvdb
  Guid: imdb://tt8688634, Id: tt8688634, Provider: imdb
Metadata: {'collected_at': '2020-02-07:T10:00:41.000Z', 'media_type': 'digital', 'resolution': 'hd_1080p', 'audio': 'aac', 'audio_channels': '5.1'}
Trakt: https://trakt.tv/movies/387139
Watched on Plex: True
Watched on Trakt: True
Play history:

./plex_trakt_sync.sh inspect 328618:

PlexTraktSync inspect [83ded352: Merge pull request #470 from twolaw/plex-fallback-ip-for-docker @2021-09-06 16:27:56]
Inspecting 328618: <tmdb:513045:<Movie:328618:Stuber>>
URL: https://app.plex.tv/desktop/#!/server/1c500eb9a271e3a53e0c5dcb425908b9ccd818da/details?key=/library/metadata/328618
Media.Type: movie
Media.Guid: 'plex://movie/5d7770337a53e9001e79d669'
Media.Guids: [<Guid:imdb://tt7734218>, <Guid:tmdb://513045>, <Guid:tvdb://28412>]
Audio: '7.1', 'English (DTS-HD MA 7.1)'
Video: 'h264'
Guids:
  Guid: tmdb://513045, Id: 513045, Provider: tmdb
  Guid: tvdb://28412, Id: 28412, Provider: tvdb
  Guid: imdb://tt7734218, Id: tt7734218, Provider: imdb
Metadata: {'collected_at': '2019-10-23:T16:50:28.000Z', 'media_type': 'digital', 'resolution': 'hd_1080p', 'audio': 'dts', 'audio_channels': '7.1'}
Trakt: https://trakt.tv/movies/360637
Watched on Plex: True
Watched on Trakt: True
Play history:
- 2021-09-07 10:29:12 by imjuzcy with Microsoft Edge on Microsoft Edge

@simonc56
Copy link
Collaborator

simonc56 commented Sep 7, 2021

perhaps it's possible to make PlexTraktSync to distinguish the same imdb match but different quality after we added the collection metadata support:

Maybe I'm missunderstanding but I think it's a bad solution because it could prevent to sync genuine watched status.
Example :

  1. user watch Waterworld on Plex HD library in january 2020
  2. user watch Waterworld on Plex 4K library in january 2021

Trakt is supposed to have Waterworld watched with 2 plays (january 2020 and january 2021). WRONG
So the script must sync all Plex quality versions of the movie.

Is it possible to add code to detect platform PlexTraktSync in Plex watched status ? That would be the solution imho.

@glensc
Copy link
Collaborator

glensc commented Sep 7, 2021

@twolaw here's an example of using history:

however, history works only for owned servers. for example, in the guest server, I get permission denied exception.

@simonc56
Copy link
Collaborator

simonc56 commented Sep 7, 2021

I wrote something wrong :

Trakt is supposed to have Waterworld watched with 2 plays (january 2020 and january 2021).
So the script must sync all Plex quality versions of the movie.

Script does NOT send another watched status :

if m.watched_on_plex is m.watched_on_trakt:
return

Other solution : cache the request sending watched status to trakt (for the running session only). Is memoize a kind of cache for the running session only ? will not work because seen_date is different.

def mark_watched_trakt(self):
self.trakt_api.mark_watched(self.trakt, self.plex.seen_date)

Other solution, update trakt watched_movies list :

  • at each mark_watched_trakt() with something like self.trakt_api.watched_movies.add(self.trakt)
  • or after each library scan with an additionnal request to trakt (worse idea)

@property
@memoize
@nocache
@rate_limit()
def watched_movies(self):
return set(
map(lambda m: m.trakt, self.me.watched_movies)
)

@glensc
Copy link
Collaborator

glensc commented Sep 7, 2021

please don't abuse @nocache to prevent duplicate api calls. way too clever code is difficult to maintain and understand.

@simonc56
Copy link
Collaborator

simonc56 commented Sep 7, 2021

@imjuzcy
Copy link
Contributor Author

imjuzcy commented Sep 7, 2021

Just tested it and it works. No more movie showing twice in Trakt.

@imjuzcy imjuzcy closed this as completed Sep 7, 2021
@imjuzcy
Copy link
Contributor Author

imjuzcy commented Sep 9, 2021

Show episodes are still showing up twice in Trakt's history with sync.

@imjuzcy imjuzcy reopened this Sep 9, 2021
@simonc56
Copy link
Collaborator

I know, i did not create the episode part for this.
It is in my to-do list.

@simonc56
Copy link
Collaborator

Try this PR #482 with watched episode(s), then with watched season(s) and then with full watched show(s) please.

@imjuzcy
Copy link
Contributor Author

imjuzcy commented Sep 11, 2021

I tested all three cases (one watched episode, one watched season, and one watched full show), the first library it sync successfully, and then when it goes to the second library, it still synced one episode and then encountered an error.

First sync when there is nothing to sync:

INFO: PlexTraktSync [3714fdd6: update trakt watched_shows during scan @2021-09-11 11:14:57]
INFO: Syncing with Plex imjuzcy and Trakt imjuzcy
Sync Movies: True
Sync Shows: True
INFO: Loaded Trakt lists in 2.3 seconds
Plex Server version: 1.24.2.4973-2b1b51db9, updated at: 2021-09-11 19:26:56
Server has 2 libraries: ['TestTV', 'TestTVHQ']
/home/ubuntu/PlexTraktSync/plex_trakt_sync/walker.py:122: TqdmExperimentalWarning: rich is experimental/alpha
  pb = self._progressbar(iterable, **kwargs)
Processing TestTV 100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3/3  [ 0:00:04 < 0:00:00 , 1 it/s ]
INFO: TestTV processed in 4.5 seconds
Processing TestTVHQ 100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4/4  [ 0:00:06 < 0:00:00 , 1 it/s ]
INFO: TestTVHQ processed in 6.1 seconds
INFO: Updated plex watchlist in 0.0 seconds
INFO: Completed full sync in 12.9 seconds

When there is one episode to sync:

INFO: PlexTraktSync [3714fdd6: update trakt watched_shows during scan @2021-09-11 11:14:57]
INFO: Syncing with Plex imjuzcy and Trakt imjuzcy
Sync Movies: True
Sync Shows: True
INFO: Loaded Trakt lists in 1.4 seconds
Plex Server version: 1.24.2.4973-2b1b51db9, updated at: 2021-09-11 19:26:56
Server has 2 libraries: ['TestTV', 'TestTVHQ']
/home/ubuntu/PlexTraktSync/plex_trakt_sync/walker.py:122: TqdmExperimentalWarning: rich is experimental/alpha
  pb = self._progressbar(iterable, **kwargs)
INFO: Marking as watched in Trakt: <tmdb:1203677:<Episode:330166:Stranger-Things-s01e02>>
Processing TestTV 100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3/3  [ 0:00:06 < 0:00:00 , 1 it/s ]
INFO: TestTV processed in 6.4 seconds
INFO: Marking as watched in Trakt: <tmdb:1203677:<Episode:330284:Stranger-Things-s01e02>>
Processing TestTVHQ  75% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╺━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3/4  [ 0:00:04 < 0:00:02 , 1 it/s ]
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/__main__.py", line 16, in <module>
    cli()
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1646, in invoke
    super().invoke(ctx)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/cli.py", line 23, in cli
    sync()
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/commands/sync.py", line 131, in sync
    sync_all(walker=w, trakt=trakt, plex=plex, dry_run=dry_run)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/commands/sync.py", line 40, in sync_all
    runner.sync(walker, listutil, dry_run=dry_run)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/sync.py", line 23, in sync
    self.sync_watched(episode, dry_run=dry_run)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/sync.py", line 64, in sync_watched
    m.mark_watched_trakt()
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/media.py", line 81, in mark_watched_trakt
    self.trakt_api.mark_watched(self.trakt, self.plex.seen_date)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/decorators/nocache.py", line 14, in inner
    return method(*args, **kwargs)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/decorators/rate_limit.py", line 23, in wrapper
    return fn(*args, **kwargs)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/decorators/time_limit.py", line 18, in wrapper
    return fn(*args, **kwargs)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/trakt_api.py", line 187, in mark_watched
    self.watched_shows.add(m.trakt, m.season, m.number)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/pytrakt_extensions.py", line 147, in add
    if season in self.shows[trakt_id]:
TypeError: argument of type 'ShowProgress' is not iterable

When there is one season to sync (S01E01 has been watched and synced before this, so it's normal that it is not synced here):

INFO: PlexTraktSync [3714fdd6: update trakt watched_shows during scan @2021-09-11 11:14:57]
INFO: Syncing with Plex imjuzcy and Trakt imjuzcy
Sync Movies: True
Sync Shows: True
INFO: Loaded Trakt lists in 2.1 seconds
Plex Server version: 1.24.2.4973-2b1b51db9, updated at: 2021-09-11 19:26:56
Server has 2 libraries: ['TestTV', 'TestTVHQ']
/home/ubuntu/PlexTraktSync/plex_trakt_sync/walker.py:122: TqdmExperimentalWarning: rich is experimental/alpha
  pb = self._progressbar(iterable, **kwargs)
INFO: Marking as watched in Trakt: <tmdb:578717:<Episode:330141:Sherlock-s01e02>>
INFO: Marking as watched in Trakt: <tmdb:578716:<Episode:330142:Sherlock-s01e03>>
Processing TestTV 100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3/3  [ 0:00:05 < 0:00:00 , 1 it/s ]
INFO: TestTV processed in 5.5 seconds
INFO: Marking as watched in Trakt: <tmdb:578717:<Episode:330259:Sherlock-s01e02>>
Processing TestTVHQ  50% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╺━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2/4  [ 0:00:04 < 0:00:04 , 1 it/s ]
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/__main__.py", line 16, in <module>
    cli()
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1646, in invoke
    super().invoke(ctx)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/cli.py", line 23, in cli
    sync()
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/commands/sync.py", line 131, in sync
    sync_all(walker=w, trakt=trakt, plex=plex, dry_run=dry_run)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/commands/sync.py", line 40, in sync_all
    runner.sync(walker, listutil, dry_run=dry_run)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/sync.py", line 23, in sync
    self.sync_watched(episode, dry_run=dry_run)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/sync.py", line 64, in sync_watched
    m.mark_watched_trakt()
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/media.py", line 81, in mark_watched_trakt
    self.trakt_api.mark_watched(self.trakt, self.plex.seen_date)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/decorators/nocache.py", line 14, in inner
    return method(*args, **kwargs)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/decorators/rate_limit.py", line 23, in wrapper
    return fn(*args, **kwargs)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/decorators/time_limit.py", line 18, in wrapper
    return fn(*args, **kwargs)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/trakt_api.py", line 187, in mark_watched
    self.watched_shows.add(m.trakt, m.season, m.number)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/pytrakt_extensions.py", line 147, in add
    if season in self.shows[trakt_id]:
TypeError: argument of type 'ShowProgress' is not iterable

When there is whole show to sync (S01E01 has been watched and synced before this, so it's normal that it is not synced here):

INFO: PlexTraktSync [3714fdd6: update trakt watched_shows during scan @2021-09-11 11:14:57]
INFO: Syncing with Plex imjuzcy and Trakt imjuzcy
Sync Movies: True
Sync Shows: True
INFO: Loaded Trakt lists in 2.6 seconds
Plex Server version: 1.24.2.4973-2b1b51db9, updated at: 2021-09-11 19:26:56
Server has 2 libraries: ['TestTV', 'TestTVHQ']
/home/ubuntu/PlexTraktSync/plex_trakt_sync/walker.py:122: TqdmExperimentalWarning: rich is experimental/alpha
  pb = self._progressbar(iterable, **kwargs)
INFO: Marking as watched in Trakt: <tmdb:1375781:<Episode:330110:Dark-s01e02>>
INFO: Marking as watched in Trakt: <tmdb:1375782:<Episode:330111:Dark-s01e03>>
INFO: Marking as watched in Trakt: <tmdb:1375783:<Episode:330112:Dark-s01e04>>
INFO: Marking as watched in Trakt: <tmdb:1375784:<Episode:330113:Dark-s01e05>>
INFO: Marking as watched in Trakt: <tmdb:1375785:<Episode:330114:Dark-s01e06>>
INFO: Marking as watched in Trakt: <tmdb:1375786:<Episode:330115:Dark-s01e07>>
INFO: Marking as watched in Trakt: <tmdb:1375787:<Episode:330116:Dark-s01e08>>
INFO: Marking as watched in Trakt: <tmdb:1375788:<Episode:330117:Dark-s01e09>>
INFO: Marking as watched in Trakt: <tmdb:1375789:<Episode:330118:Dark-s01e10>>
INFO: Marking as watched in Trakt: <tmdb:1793851:<Episode:330120:Dark-s02e01>>
INFO: Marking as watched in Trakt: <tmdb:1829343:<Episode:330121:Dark-s02e02>>
INFO: Marking as watched in Trakt: <tmdb:1829344:<Episode:330122:Dark-s02e03>>
INFO: Marking as watched in Trakt: <tmdb:1829345:<Episode:330123:Dark-s02e04>>
INFO: Marking as watched in Trakt: <tmdb:1829346:<Episode:330124:Dark-s02e05>>
INFO: Marking as watched in Trakt: <tmdb:1829347:<Episode:330125:Dark-s02e06>>
INFO: Marking as watched in Trakt: <tmdb:1829348:<Episode:330126:Dark-s02e07>>
INFO: Marking as watched in Trakt: <tmdb:1829349:<Episode:330127:Dark-s02e08>>
INFO: Marking as watched in Trakt: <tmdb:2284012:<Episode:330129:Dark-s03e01>>
INFO: Marking as watched in Trakt: <tmdb:2284013:<Episode:330130:Dark-s03e02>>
INFO: Marking as watched in Trakt: <tmdb:2284014:<Episode:330131:Dark-s03e03>>
INFO: Marking as watched in Trakt: <tmdb:2284015:<Episode:330132:Dark-s03e04>>
INFO: Marking as watched in Trakt: <tmdb:2284016:<Episode:330133:Dark-s03e05>>
INFO: Marking as watched in Trakt: <tmdb:2284017:<Episode:330134:Dark-s03e06>>
INFO: Marking as watched in Trakt: <tmdb:2284018:<Episode:330135:Dark-s03e07>>
INFO: Marking as watched in Trakt: <tmdb:2284019:<Episode:330136:Dark-s03e08>>
Processing TestTV 100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3/3  [ 0:00:29 < 0:00:00 , 1 it/s ]
INFO: TestTV processed in 29.2 seconds
INFO: Marking as watched in Trakt: <tmdb:1375781:<Episode:330194:Dark-s01e02>>
Processing TestTVHQ   0% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0/4  [ 0:00:00 < -:--:-- , ? it/s ]
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/__main__.py", line 16, in <module>
    cli()
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1646, in invoke
    super().invoke(ctx)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/cli.py", line 23, in cli
    sync()
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/commands/sync.py", line 131, in sync
    sync_all(walker=w, trakt=trakt, plex=plex, dry_run=dry_run)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/commands/sync.py", line 40, in sync_all
    runner.sync(walker, listutil, dry_run=dry_run)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/sync.py", line 23, in sync
    self.sync_watched(episode, dry_run=dry_run)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/sync.py", line 64, in sync_watched
    m.mark_watched_trakt()
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/media.py", line 81, in mark_watched_trakt
    self.trakt_api.mark_watched(self.trakt, self.plex.seen_date)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/decorators/nocache.py", line 14, in inner
    return method(*args, **kwargs)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/decorators/rate_limit.py", line 23, in wrapper
    return fn(*args, **kwargs)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/decorators/time_limit.py", line 18, in wrapper
    return fn(*args, **kwargs)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/trakt_api.py", line 187, in mark_watched
    self.watched_shows.add(m.trakt, m.season, m.number)
  File "/home/ubuntu/PlexTraktSync/plex_trakt_sync/pytrakt_extensions.py", line 147, in add
    if season in self.shows[trakt_id]:
TypeError: argument of type 'ShowProgress' is not iterable

End effect is the first synced episode is shown twice is trakt, because it is interrupted by the TypeError error.

@simonc56
Copy link
Collaborator

My bad, the line should be if season in self.shows[trakt_id].seasons: i fixed it, can you try again.

@imjuzcy
Copy link
Contributor Author

imjuzcy commented Sep 11, 2021

Error is not there anymore, but episodes/seasons/shows are still synced twice.

Full watched season sync:

INFO: PlexTraktSync [3714fdd6: update trakt watched_shows during scan @2021-09-11 11:14:57]
INFO: Syncing with Plex imjuzcy and Trakt imjuzcy
Sync Movies: True
Sync Shows: True
INFO: Loaded Trakt lists in 2.3 seconds
Plex Server version: 1.24.2.4973-2b1b51db9, updated at: 2021-09-11 19:26:56
Server has 2 libraries: ['TestTV', 'TestTVHQ']
/home/ubuntu/PlexTraktSync/plex_trakt_sync/walker.py:122: TqdmExperimentalWarning: rich is experimental/alpha
  pb = self._progressbar(iterable, **kwargs)
INFO: Marking as watched in Trakt: <tmdb:1203677:<Episode:330166:Stranger-Things-s01e02>>
INFO: Marking as watched in Trakt: <tmdb:1203679:<Episode:330168:Stranger-Things-s01e03>>
INFO: Marking as watched in Trakt: <tmdb:1203680:<Episode:330169:Stranger-Things-s01e04>>
INFO: Marking as watched in Trakt: <tmdb:1205904:<Episode:330170:Stranger-Things-s01e05>>
INFO: Marking as watched in Trakt: <tmdb:1205905:<Episode:330171:Stranger-Things-s01e06>>
INFO: Marking as watched in Trakt: <tmdb:1205906:<Episode:330172:Stranger-Things-s01e07>>
INFO: Marking as watched in Trakt: <tmdb:1205907:<Episode:330173:Stranger-Things-s01e08>>
INFO: Marking as watched in Trakt: <tmdb:1250983:<Episode:330175:Stranger-Things-s02e01>>
INFO: Marking as watched in Trakt: <tmdb:1250984:<Episode:330176:Stranger-Things-s02e02>>
INFO: Marking as watched in Trakt: <tmdb:1250985:<Episode:330177:Stranger-Things-s02e03>>
INFO: Marking as watched in Trakt: <tmdb:1250986:<Episode:330178:Stranger-Things-s02e04>>
INFO: Marking as watched in Trakt: <tmdb:1250987:<Episode:330179:Stranger-Things-s02e05>>
INFO: Marking as watched in Trakt: <tmdb:1250988:<Episode:330180:Stranger-Things-s02e06>>
INFO: Marking as watched in Trakt: <tmdb:1250989:<Episode:330181:Stranger-Things-s02e07>>
INFO: Marking as watched in Trakt: <tmdb:1250990:<Episode:330182:Stranger-Things-s02e08>>
INFO: Marking as watched in Trakt: <tmdb:1250991:<Episode:330183:Stranger-Things-s02e09>>
INFO: Marking as watched in Trakt: <tmdb:1657328:<Episode:330184:Stranger-Things-s03e01>>
INFO: Marking as watched in Trakt: <tmdb:1657329:<Episode:330185:Stranger-Things-s03e02>>
INFO: Marking as watched in Trakt: <tmdb:1657330:<Episode:330186:Stranger-Things-s03e03>>
INFO: Marking as watched in Trakt: <tmdb:1657331:<Episode:330187:Stranger-Things-s03e04>>
INFO: Marking as watched in Trakt: <tmdb:1657332:<Episode:330163:Stranger-Things-s03e05>>
INFO: Marking as watched in Trakt: <tmdb:1657333:<Episode:330188:Stranger-Things-s03e06>>
INFO: Marking as watched in Trakt: <tmdb:1657334:<Episode:330189:Stranger-Things-s03e07>>
INFO: Marking as watched in Trakt: <tmdb:1657335:<Episode:330190:Stranger-Things-s03e08>>
Processing TestTV 100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3/3  [ 0:00:27 < 0:00:00 , 0 it/s ]
INFO: TestTV processed in 27.9 seconds
INFO: Marking as watched in Trakt: <tmdb:1203677:<Episode:330284:Stranger-Things-s01e02>>
INFO: Marking as watched in Trakt: <tmdb:1203679:<Episode:330285:Stranger-Things-s01e03>>
INFO: Marking as watched in Trakt: <tmdb:1203680:<Episode:330287:Stranger-Things-s01e04>>
INFO: Marking as watched in Trakt: <tmdb:1205904:<Episode:330288:Stranger-Things-s01e05>>
INFO: Marking as watched in Trakt: <tmdb:1205905:<Episode:330289:Stranger-Things-s01e06>>
INFO: Marking as watched in Trakt: <tmdb:1205906:<Episode:330290:Stranger-Things-s01e07>>
INFO: Marking as watched in Trakt: <tmdb:1205907:<Episode:330291:Stranger-Things-s01e08>>
INFO: Marking as watched in Trakt: <tmdb:1250983:<Episode:330293:Stranger-Things-s02e01>>
INFO: Marking as watched in Trakt: <tmdb:1250984:<Episode:330294:Stranger-Things-s02e02>>
INFO: Marking as watched in Trakt: <tmdb:1250985:<Episode:330295:Stranger-Things-s02e03>>
INFO: Marking as watched in Trakt: <tmdb:1250986:<Episode:330296:Stranger-Things-s02e04>>
INFO: Marking as watched in Trakt: <tmdb:1250987:<Episode:330297:Stranger-Things-s02e05>>
INFO: Marking as watched in Trakt: <tmdb:1250988:<Episode:330298:Stranger-Things-s02e06>>
INFO: Marking as watched in Trakt: <tmdb:1250989:<Episode:330299:Stranger-Things-s02e07>>
INFO: Marking as watched in Trakt: <tmdb:1250990:<Episode:330300:Stranger-Things-s02e08>>
INFO: Marking as watched in Trakt: <tmdb:1250991:<Episode:330301:Stranger-Things-s02e09>>
INFO: Marking as watched in Trakt: <tmdb:1657328:<Episode:330302:Stranger-Things-s03e01>>
INFO: Marking as watched in Trakt: <tmdb:1657329:<Episode:330303:Stranger-Things-s03e02>>
INFO: Marking as watched in Trakt: <tmdb:1657330:<Episode:330304:Stranger-Things-s03e03>>
INFO: Marking as watched in Trakt: <tmdb:1657331:<Episode:330305:Stranger-Things-s03e04>>
INFO: Marking as watched in Trakt: <tmdb:1657332:<Episode:330281:Stranger-Things-s03e05>>
INFO: Marking as watched in Trakt: <tmdb:1657333:<Episode:330306:Stranger-Things-s03e06>>
INFO: Marking as watched in Trakt: <tmdb:1657334:<Episode:330307:Stranger-Things-s03e07>>
INFO: Marking as watched in Trakt: <tmdb:1657335:<Episode:330308:Stranger-Things-s03e08>>
Processing TestTVHQ 100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4/4  [ 0:00:29 < 0:00:00 , 0 it/s ]
INFO: TestTVHQ processed in 29.5 seconds
INFO: Updated plex watchlist in 0.0 seconds
INFO: Completed full sync in 1 min 0.6 seconds

@simonc56
Copy link
Collaborator

Unpack problem fixed.
Test again please.

@imjuzcy
Copy link
Contributor Author

imjuzcy commented Sep 11, 2021

It's still the same

@simonc56
Copy link
Collaborator

Ok I managed to reproduced your bug, fix it and successfully test the fix.
Is it ok now ?

@imjuzcy
Copy link
Contributor Author

imjuzcy commented Sep 12, 2021

Yes, it is working as intended now. No more double syncing.

@imjuzcy imjuzcy closed this as completed Sep 12, 2021
@simonc56 simonc56 self-assigned this Sep 12, 2021
Repository owner locked as resolved and limited conversation to collaborators Jan 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
3 participants