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.62k stars 106 forks source link

Episode ratings are pulled from Trakt despite being present in Plex #778

Closed agneevX closed 1 year ago

agneevX commented 2 years ago

The problem

When running sync, there are INFO logs printing info that episodes are being updated with ratings... but these ratings already exist

Sync Shows: [<Show:58636:Big-Sky-(2020)>]
INFO: Rating <tmdb:3076775:<Episode:79750:Big-Sky-(2020)-s02e01>> with 8 on Plex
INFO: Rating <tmdb:3204871:<Episode:79785:Big-Sky-(2020)-s02e02>> with 8 on Plex
INFO: Rating <tmdb:3245050:<Episode:79954:Big-Sky-(2020)-s02e03>> with 8 on Plex
INFO: Rating <tmdb:3253622:<Episode:80265:Big-Sky-(2020)-s02e04>> with 8 on Plex
INFO: Rating <tmdb:3297277:<Episode:80856:Big-Sky-(2020)-s02e05>> with 8 on Plex
INFO: Rating <tmdb:3329566:<Episode:81022:Big-Sky-(2020)-s02e06>> with 8 on Plex
INFO: Rating <tmdb:3335734:<Episode:95723:Big-Sky-(2020)-s02e07>> with 8 on Plex
INFO: Rating <tmdb:3350389:<Episode:95912:Big-Sky-(2020)-s02e08>> with 7 on Plex

Error trace

No response

Expected behavior

Only ratings that have changed in Trakt or that are not present in Plex should be pulled and the relevant info should appear in logs

Steps to reproduce the behavior

  1. Pull ghcr.io/taxel/plextraktsync
  2. Run sync

Inspect of problematic items

No response

Workarounds

The last version I was using before this is v0.18.4 and I do not recall this being an issue then.

Install method

docker-compose

Version

0.18.16

Python Version

3.10.0

Operating System and Version

Ubuntu 20.04

glensc commented 2 years ago

Workarounds

The last version I was using before this is v0.18.4 and I do not recall this being an issue then.

so, downgrade there and test!

glensc commented 2 years ago

also, test if cache removal helps.

also test if --show='Big-Sky-(2020)' helps (afaik that uses different query, so different cache)

agneevX commented 2 years ago

so, downgrade there and test!

Ok, using :0.18.5, there's no such logs.

agneevX commented 2 years ago

Seems this started in v0.18.8 as its present in all versions after that and in no versions before that

glensc commented 2 years ago

Seems this started in v0.18.8 as its present in all versions after that and in no versions before that

So it's 0.18.7...0.18.8 (not 0.18.8...0.18.9):

can you bisect more, i.e which merge commit could be at fault?

agneevX commented 2 years ago

It could be 32a07c110fc55ea436a040f302d6bc27c1146942 as this only seems to affect TV Shows.

glensc commented 2 years ago

perhaps you can check to exact commit then (https://github.com/Taxel/PlexTraktSync/commit/32a07c110fc55ea436a040f302d6bc27c1146942 is merge commit)

stevietv commented 2 years ago

I don't think its an v0.18.8 issue, I'm running this on v0.18.5 tag and also getting the same repeated attempts ti import a rating that already exists:

2022-02-09 08:02:01,977 INFO[PlexTraktSync]:PlexTraktSync [0.18.x: 82807d49: Bump plexapi from 4.9.0 to 4.9.1 (#753) @2022-01-26 09:22:09]
2022-02-09 08:02:03,564 WARNING[PlexTraktSync]:<Movie:11687:Spring-Awakening-Off>: Skipping guid local://11687 because provider local has no external Id
2022-02-09 08:02:03,588 INFO[PlexTraktSync]:Movies processed in 0.9 seconds
2022-02-09 08:02:12,317 WARNING[PlexTraktSync]:Retry using search for specific Plex Episode
2022-02-09 08:02:18,832 INFO[PlexTraktSync]:Rating <tmdb:2043632:<Episode:853:Archer-(2009)-s11e01>> with 8 on Plex
2022-02-09 08:02:18,847 INFO[PlexTraktSync]:Rating <tmdb:2368650:<Episode:854:Archer-(2009)-s11e02>> with 9 on Plex
2022-02-09 08:02:18,861 INFO[PlexTraktSync]:Rating <tmdb:2430041:<Episode:855:Archer-(2009)-s11e03>> with 9 on Plex
2022-02-09 08:02:18,873 INFO[PlexTraktSync]:Rating <tmdb:2430042:<Episode:856:Archer-(2009)-s11e04>> with 9 on Plex
2022-02-09 08:02:18,888 INFO[PlexTraktSync]:Rating <tmdb:2430043:<Episode:857:Archer-(2009)-s11e05>> with 10 on Plex
2022-02-09 08:02:18,916 INFO[PlexTraktSync]:Rating <tmdb:2442038:<Episode:859:Archer-(2009)-s11e07>> with 6 on Plex
2022-02-09 08:02:18,933 INFO[PlexTraktSync]:Rating <tmdb:2449567:<Episode:860:Archer-(2009)-s11e08>> with 7 on Plex
2022-02-09 08:02:31,844 INFO[PlexTraktSync]:Rating <tmdb:975415:<Episode:1360:Bob's-Burgers-s04e21>> with 10 on Plex
2022-02-09 08:02:31,858 INFO[PlexTraktSync]:Rating <tmdb:975542:<Episode:1361:Bob's-Burgers-s04e22>> with 10 on Plex
2022-02-09 08:02:32,447 INFO[PlexTraktSync]:Rating <tmdb:1295764:<Episode:1418:Bob's-Burgers-s07e14>> with 7 on Plex
2022-02-09 08:02:32,463 INFO[PlexTraktSync]:Rating <tmdb:1298680:<Episode:1419:Bob's-Burgers-s07e15>> with 7 on Plex
2022-02-09 08:02:32,475 INFO[PlexTraktSync]:Rating <tmdb:1295765:<Episode:1420:Bob's-Burgers-s07e16>> with 9 on Plex
2022-02-09 08:02:32,582 INFO[PlexTraktSync]:Rating <tmdb:1382061:<Episode:1432:Bob's-Burgers-s08e04>> with 8 on Plex
2022-02-09 08:02:32,668 INFO[PlexTraktSync]:Rating <tmdb:1463622:<Episode:1440:Bob's-Burgers-s08e12>> with 7 on Plex
2022-02-09 08:02:32,692 INFO[PlexTraktSync]:Rating <tmdb:1469102:<Episode:1442:Bob's-Burgers-s08e14>> with 8 on Plex
2022-02-09 08:02:32,727 INFO[PlexTraktSync]:Rating <tmdb:1483820:<Episode:1445:Bob's-Burgers-s08e17>> with 8 on Plex

Its happening for only a few shows, and from each show only a few episodes. Let me know if theres anything I can do to assist in debugging.

glensc commented 2 years ago

I asked, did not see anyone tested that:

when testing without cache, keep around the existing cache to be able to test more with debugging. enabling debug log and looking at that debug log can help to see what requests are made that are cached while they shouldn't. and also with cache subcommand can read the cache content

stevietv commented 2 years ago

I've tried by renaming trakt_cache.sqlite to trakt_cache.sqlite.bak and having it regenerate the cache. After two runs its still the same issue.

Running python3 - m plextraktsync --show='Archer-(2009)' gives an error: no such option: --show - am I using the right syntax here?

here are the entries in my debug log for the first episode on that list:

2022-02-09 09:28:28,436 DEBUG[plexapi]:Reloading Episode 'The Orpheus Gambit' for attr 'guids'
2022-02-09 09:28:28,436 DEBUG[plexapi]:GET https://192-168-90-248.e7e5c4ea7e914bb6a322f1e3454287d7.plex.direct:32400/library/metadata/853?checkFiles=1&includeAllConcerts=1&includeBandwidths=1&includeChapters=1&includeChildren=1&includeConcerts=1&includeExternalMedia=1&includeExtras=1&includeFields=thumbBlurHash%2CartBlurHash&includeGeolocation=1&includeLoudnessRamps=1&includeMarkers=1&includeOnDeck=1&includePopularLeaves=1&includePreferences=1&includeRelated=1&includeRelatedCount=1&includeReviews=1&includeStations=1
2022-02-09 09:28:28,446 DEBUG[urllib3.connectionpool]:https://192-168-90-248.e7e5c4ea7e914bb6a322f1e3454287d7.plex.direct:32400/ "GET /library/metadata/853?checkFiles=1&includeAllConcerts=1&includeBandwidths=1&includeChapters=1&includeChildren=1&includeConcerts=1&includeExternalMedia=1&includeExtras=1&includeFields=thumbBlurHash%2CartBlurHash&includeGeolocation=1&includeLoudnessRamps=1&includeMarkers=1&includeOnDeck=1&includePopularLeaves=1&includePreferences=1&includeRelated=1&includeRelatedCount=1&includeReviews=1&includeStations=1 HTTP/1.1" 200 1724
2022-02-09 09:28:28,447 DEBUG[requests_cache.session]:Pre-cache checks for response from https://192-168-90-248.e7e5c4ea7e914bb6a322f1e3454287d7.plex.direct:32400/library/metadata/853?checkFiles=1&includeAllConcerts=1&includeBandwidths=1&includeChapters=1&includeChildren=1&includeConcerts=1&includeExternalMedia=1&includeExtras=1&includeFields=thumbBlurHash%2CartBlurHash&includeGeolocation=1&includeLoudnessRamps=1&includeMarkers=1&includeOnDeck=1&includePopularLeaves=1&includePreferences=1&includeRelated=1&includeRelatedCount=1&includeReviews=1&includeStations=1: {'disabled cache': True, 'disabled method': False, 'disabled status': False, 'disabled by filter': False, 'disabled by headers or expiration params': False}
2022-02-09 09:28:28,447 DEBUG[requests_cache.session]:Skipping cache write for URL: https://192-168-90-248.e7e5c4ea7e914bb6a322f1e3454287d7.plex.direct:32400/library/metadata/853?checkFiles=1&includeAllConcerts=1&includeBandwidths=1&includeChapters=1&includeChildren=1&includeConcerts=1&includeExternalMedia=1&includeExtras=1&includeFields=thumbBlurHash%2CartBlurHash&includeGeolocation=1&includeLoudnessRamps=1&includeMarkers=1&includeOnDeck=1&includePopularLeaves=1&includePreferences=1&includeRelated=1&includeRelatedCount=1&includeReviews=1&includeStations=1
2022-02-09 09:28:28,449 INFO[PlexTraktSync]:Rating <tmdb:2043632:episode:853:Archer-(2009)-s11e01> with 8 on Plex
2022-02-09 09:28:28,452 DEBUG[plexapi]:PUT https://192-168-90-248.e7e5c4ea7e914bb6a322f1e3454287d7.plex.direct:32400/:/rate?key=853&identifier=com.plexapp.plugins.library&rating=8
2022-02-09 09:28:28,455 DEBUG[urllib3.connectionpool]:https://192-168-90-248.e7e5c4ea7e914bb6a322f1e3454287d7.plex.direct:32400/ "PUT /:/rate?key=853&identifier=com.plexapp.plugins.library&rating=8 HTTP/1.1" 200 0
2022-02-09 09:28:28,455 DEBUG[requests_cache.session]:Pre-cache checks for response from https://192-168-90-248.e7e5c4ea7e914bb6a322f1e3454287d7.plex.direct:32400/:/rate?key=853&identifier=com.plexapp.plugins.library&rating=8: {'disabled cache': True, 'disabled method': True, 'disabled status': False, 'disabled by filter': False, 'disabled by headers or expiration params': False}
2022-02-09 09:28:28,455 DEBUG[requests_cache.session]:Skipping cache write for URL: https://192-168-90-248.e7e5c4ea7e914bb6a322f1e3454287d7.plex.direct:32400/:/rate?key=853&identifier=com.plexapp.plugins.library&rating=8
glensc commented 2 years ago

plextraktsync sync --show is the usage. see plextraktsync --help, plextraktsync sync --help

glensc commented 2 years ago

2022-02-09 09:28:28,436 DEBUG[plexapi]:Reloading Episode 'The Orpheus Gambit' for attr 'guids' seems to be the culprit. now look with cache subcommand do you have cache entry with that episode id, probably 853. check with inspect subcommand (plextraktsync inspect 853) is it the right thing

glensc commented 2 years ago

Fixed with https://github.com/Taxel/PlexTraktSync/pull/793 and https://github.com/Taxel/PlexTraktSync/pull/794 in 0.18.20

stevietv commented 2 years ago

Thanks for taking a look into this. I've pulled 0.18.20 and I still got the same episodes trying to be rated again. I've deleted my cache and ran python3 -m plextraktsync sync --show='Archer (2009)' and get the same info lines every time its ran. plextraktsync inspect 853 returns:

PlexTraktSync [0.18.x: a183bcf2: Merge pull request #794 from glensc/778-no-cache-trakt-ratings @2022-02-09 12:56:29]

Inspecting 853: <tmdb:2043632:<Episode:853:Archer-(2009)-s11e01>>
URL: https://app.plex.tv/desktop/#!/server/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/details?key=/library/metadata/853
Media.Type: episode
Media.Guid: 'plex://episode/5f1e7c375b5fa3003dae9571'
Media.Guids: [<Guid:imdb://tt10692628>, <Guid:tmdb://2043632>, <Guid:tvdb://7859203>]
Audio: 'None', 'Unknown (AAC Stereo)'
Video: 'h264'
Parts:
  Part 1: /data/tv/Archer (2009)/Season 11/Archer (2009) - S11E01 - The Orpheus Gambit [SDTV x264].mkv
Guids:
  Guid: tmdb://2043632, Id: 2043632, Provider: tmdb
  Guid: tvdb://7859203, Id: 7859203, Provider: tvdb
  Guid: imdb://tt10692628, Id: tt10692628, Provider: imdb
Metadata: {'collected_at': '2020-09-17:T02:00:00.000Z', 'media_type': 'digital', 'resolution': 'sd_480p', 'audio': 'aac', 'audio_channels': '2.0'}
WARNING: <Episode:853:Archer-(2009)-s11e01>: Skipping guid tmdb://2043632 Trakt errors: Forbidden - invalid API key or unapproved app
WARNING: <Episode:853:Archer-(2009)-s11e01>: Skipping guid tvdb://7859203 Trakt errors: Forbidden - invalid API key or unapproved app
WARNING: <Episode:853:Archer-(2009)-s11e01>: Skipping guid imdb://tt10692628 Trakt errors: Forbidden - invalid API key or unapproved app
glensc commented 2 years ago

What's with the "Forbidden - invalid API key or unapproved app"?

glensc commented 2 years ago

And cache results for 853?

stevietv commented 2 years ago

What's with the "Forbidden - invalid API key or unapproved app"?

that seems to appear on every inspect I do, no matter the episode id

And cache results for 853?

whats the command for specific episode cache?

python3 -m plextraktsync cache

Cache status:
Total rows: 2 responses, 0 redirects

URLs:
-   1. request: GET https://api.trakt.tv/search/tmdb/10283?type=show, response: 200 (167 bytes), created: 2022-02-09 17:38:17 CET, expires: N/A (fresh)
-   2. request: GET https://192-168-90-248.e7e5c4ea7e914bb6a322f1e3454287d7.plex.direct:32400/library/metadata/864, response: 200 (1.12 KiB), created: 2022-02-09 17:38:17 CET, expires: N/A (fresh)
stevietv commented 2 years ago

What's with the "Forbidden - invalid API key or unapproved app"?

that seems to appear on every inspect I do, no matter the episode id

FYI, this is gone with a requirements update, however the original problem of episode ratings remains.

stevietv commented 2 years ago

is there anything I can do to further help debug this issue? I still have continued the same ratings showing in the log as if they are being pulled:

PlexTraktSync$ python3 -m plextraktsync sync --show='Archer (2009)'
Sync Shows: [<Show:733:Archer-(2009)>]
INFO: Rating <tmdb:2043632:<Episode:853:Archer-(2009)-s11e01>> with 8 on Plex
INFO: Rating <tmdb:2368650:<Episode:854:Archer-(2009)-s11e02>> with 9 on Plex
INFO: Rating <tmdb:2430041:<Episode:855:Archer-(2009)-s11e03>> with 9 on Plex
INFO: Rating <tmdb:2430042:<Episode:856:Archer-(2009)-s11e04>> with 9 on Plex
INFO: Rating <tmdb:2430043:<Episode:857:Archer-(2009)-s11e05>> with 10 on Plex
INFO: Rating <tmdb:2442038:<Episode:859:Archer-(2009)-s11e07>> with 6 on Plex
INFO: Rating <tmdb:2449567:<Episode:860:Archer-(2009)-s11e08>> with 7 on Plex
python3 -m plextraktsync inspect 853

Inspecting 853: <tmdb:2043632:<Episode:853:Archer-(2009)-s11e01>>
URL: https://app.plex.tv/desktop/#!/server/xxxxxxxxxxxxxxxxxxxxxxxxxxx/details?key=/library/metadata/853
Media.Type: episode
Media.Guid: 'plex://episode/5f1e7c375b5fa3003dae9571'
Media.Guids: [<Guid:imdb://tt10692628>, <Guid:tmdb://2043632>, <Guid:tvdb://7859203>]
Audio: 'None', 'Unknown (AAC Stereo)'
Video: 'h264'
Parts:
  Part 1: /data/tv/Archer (2009)/Season 11/Archer (2009) - S11E01 - The Orpheus Gambit [SDTV x264].mkv
Guids:
  Guid: tmdb://2043632, Id: 2043632, Provider: tmdb
  Guid: tvdb://7859203, Id: 7859203, Provider: tvdb
  Guid: imdb://tt10692628, Id: tt10692628, Provider: imdb
Metadata: {'collected_at': '2020-09-17:T02:00:00.000Z', 'media_type': 'digital', 'resolution': 'sd_480p', 'audio': 'aac', 'audio_channels': '2.0'}
Trakt: https://trakt.tv/episodes/4350993
Plex Rating: 8
Trakt Rating: 8
Watched on Plex: True
Watched on Trakt: True
Plex play history:
- 2021-08-28 01:42:54 by stevietv on shutterbug with PlexTraktSync
glensc commented 2 years ago
  1. your recent note does not include the version detail.
  2. you need to enable and look debug logs. and see cache URLs and maybe cached URL contents. sorry, I won't say what you need to be looking for, this been repeated over so many times in here and in some other issues, I'm not personally interested in investing my time here anymore. maybe someone else wishes. so worth posting details for them.