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

Fix duplicate watched status in trakt (due to movie in multiple Plex libraries) #477

Merged
merged 1 commit into from
Sep 7, 2021

Conversation

simonc56
Copy link
Collaborator

@simonc56 simonc56 commented Sep 7, 2021

The idea of this PR :
The trakt watched_movies list used during sync is created when syncing the first movie of the first library.
It is later read to know the watched status of other movies, but it is memoized so not fetched from trakt server. Therefore, it can give a wrong not-watched status when a movie is scanned for the second time in the same sync session.

The idea is to update this list each time a movie is marked as watched in trakt.
With this list up-to-date, the script will know the correct watched status of a movie even if it has already been scanned in the same session.

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

fixes #476

@simonc56 simonc56 marked this pull request as draft September 7, 2021 11:22
@simonc56 simonc56 changed the title Fix duplicate watched status in trakt (due to movie in multiple library) Fix duplicate watched status in trakt (due to movie in multiple Plex libraries) Sep 7, 2021
@simonc56 simonc56 force-pushed the fix-excessive-trakt-watched-request branch from 5a252f4 to a3859fa Compare September 7, 2021 13:53
@simonc56 simonc56 force-pushed the fix-excessive-trakt-watched-request branch from a3859fa to 694bd79 Compare September 7, 2021 14:04
@simonc56 simonc56 marked this pull request as ready for review September 7, 2021 14:26
@simonc56 simonc56 force-pushed the fix-excessive-trakt-watched-request branch from 694bd79 to 5c2c690 Compare September 7, 2021 15:36
@simonc56 simonc56 force-pushed the fix-excessive-trakt-watched-request branch from 5c2c690 to 4b01dcb Compare September 7, 2021 16:07
@glensc
Copy link
Collaborator

glensc commented Sep 7, 2021

I'm not sure if I really should remove the memoize decorator.

read my response:

without it operates on a copy:

        print(type(trakt.watched_movies))
        print(3 in trakt.watched_movies)
        print(3000 in trakt.watched_movies)
        print(len(trakt.watched_movies))
        trakt.watched_movies.add(3)
        trakt.watched_movies.add(3000)
        print(3 in trakt.watched_movies)
        print(3000 in trakt.watched_movies)
        print(len(trakt.watched_movies))
<class 'set'>
True
False
859
True
False
859

compare with and without the decorator yourself.

@glensc
Copy link
Collaborator

glensc commented Sep 7, 2021

and please, try not to force push during the review. use git fixup commits instead. use issue status Draft to prevent accidental merges.

first it's difficult to see the new changes you make, if you overwrite everything each time, and github has troubles as well, as all line comments get hidden somewhere. the comments i left are no longer in context of the lines i commented.

I recommend using git fixup (a simple wrapper for git commit --fixup):

my typical flow is like this:

git add -p
git fixup HEAD # or git commit --fixup HEAD
git push

and when done with the review (or just too messy and want to clean up):

git fetch
git rebase -i origin/main
git push --force-with-lease

@simonc56
Copy link
Collaborator Author

simonc56 commented Sep 7, 2021

Ok thanks, i'll have to learn this.

@glensc
Copy link
Collaborator

glensc commented Sep 7, 2021

4b01dcb looks accurate now. lets wait for user feedback.

@glensc
Copy link
Collaborator

glensc commented Sep 7, 2021

Some of the discussion is on the commit:

that discussion is not reachable from pull request due force pushes. at least i can't find it.

@glensc glensc merged commit b14ca36 into Taxel:main Sep 7, 2021
@simonc56 simonc56 deleted the fix-excessive-trakt-watched-request branch September 12, 2021 13:10
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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Duplicate when multiple library with same movie/show
2 participants