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

Wrong play time when an element is synced from trakt to plex #943

Closed CMBoii closed 2 years ago

CMBoii commented 2 years ago

Confirmation

The problem

When the app syncs the history from trakt to plex the play time displayed on plex won't be the real one, instead the time shown will be the script run time. Furthermore, the entry will be duplicated on plex.

Gi6t3X8 test

Error trace / logs

2022-06-18 20:06:05,358 INFO[PlexTraktSync]:PlexTraktSync [0.20.1]
2022-06-18 20:06:05,367 DEBUG[plexapi]:GET https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/
2022-06-18 20:06:05,370 DEBUG[requests_cache.cache_control]:Cache directives from request headers: {}
2022-06-18 20:06:05,371 DEBUG[urllib3.connectionpool]:Starting new HTTPS connection (1): 192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400
2022-06-18 20:06:05,399 DEBUG[urllib3.connectionpool]:https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400 "GET / HTTP/1.1" 200 2953
2022-06-18 20:06:05,400 DEBUG[requests_cache.session]:Pre-cache checks for response from https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/: {'disabled cache': True, 'disabled method': False, 'disabled status': False, 'disabled by filter': False, 'disabled by headers or expiration params': False}
2022-06-18 20:06:05,400 DEBUG[requests_cache.session]:Skipping cache write for URL: https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/
2022-06-18 20:06:05,412 DEBUG[plexapi]:GET https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/library
2022-06-18 20:06:05,414 DEBUG[requests_cache.cache_control]:Cache directives from request headers: {}
2022-06-18 20:06:05,416 DEBUG[urllib3.connectionpool]:https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400 "GET /library HTTP/1.1" 200 289
2022-06-18 20:06:05,417 DEBUG[requests_cache.session]:Pre-cache checks for response from https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/library: {'disabled cache': True, 'disabled method': False, 'disabled status': False, 'disabled by filter': False, 'disabled by headers or expiration params': False}
2022-06-18 20:06:05,417 DEBUG[requests_cache.session]:Skipping cache write for URL: https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/library
2022-06-18 20:06:05,417 DEBUG[plexapi]:GET https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/library/sections
2022-06-18 20:06:05,419 DEBUG[requests_cache.cache_control]:Cache directives from request headers: {}
2022-06-18 20:06:05,423 DEBUG[urllib3.connectionpool]:https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400 "GET /library/sections HTTP/1.1" 200 1187
2022-06-18 20:06:05,424 DEBUG[requests_cache.session]:Pre-cache checks for response from https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/library/sections: {'disabled cache': True, 'disabled method': False, 'disabled status': False, 'disabled by filter': False, 'disabled by headers or expiration params': False}
2022-06-18 20:06:05,424 DEBUG[requests_cache.session]:Skipping cache write for URL: https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/library/sections
2022-06-18 20:06:05,425 DEBUG[plexapi]:GET https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/library/metadata/3043
2022-06-18 20:06:05,427 DEBUG[requests_cache.cache_control]:Cache directives from request headers: {}
2022-06-18 20:06:05,458 DEBUG[urllib3.connectionpool]:https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400 "GET /library/metadata/3043 HTTP/1.1" 200 6014
2022-06-18 20:06:05,460 DEBUG[requests_cache.session]:Pre-cache checks for response from https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/library/metadata/3043: {'disabled cache': True, 'disabled method': False, 'disabled status': False, 'disabled by filter': False, 'disabled by headers or expiration params': False}
2022-06-18 20:06:05,460 DEBUG[requests_cache.session]:Skipping cache write for URL: https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/library/metadata/3043
2022-06-18 20:06:05,540 DEBUG[plexapi]:GET https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/library/metadata/3043
2022-06-18 20:06:05,542 DEBUG[requests_cache.cache_control]:Cache directives from request headers: {}
2022-06-18 20:06:05,573 DEBUG[urllib3.connectionpool]:https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400 "GET /library/metadata/3043 HTTP/1.1" 200 6014
2022-06-18 20:06:05,574 DEBUG[requests_cache.session]:Pre-cache checks for response from https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/library/metadata/3043: {'disabled cache': True, 'disabled method': False, 'disabled status': False, 'disabled by filter': False, 'disabled by headers or expiration params': False}
2022-06-18 20:06:05,574 DEBUG[requests_cache.session]:Skipping cache write for URL: https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/library/metadata/3043
2022-06-18 20:06:05,662 DEBUG[trakt.core]:get: https://api-v2launch.trakt.tv/users/me
2022-06-18 20:06:05,662 DEBUG[trakt.core]:headers: {'Content-Type': 'application/json', 'trakt-api-version': '2', 'trakt-api-key': 'redacted', 'Authorization': 'Bearer redacted'}
2022-06-18 20:06:05,662 DEBUG[trakt.core]:method, url :: get, https://api-v2launch.trakt.tv/users/me
2022-06-18 20:06:05,664 DEBUG[requests_cache.cache_keys]:Invalid JSON body:
Traceback (most recent call last):
  File "/volume1/homes/Alex_admin/.local/pipx/venvs/plextraktsync/lib/python3.8/site-packages/requests_cache/cache_keys.py", line 165, in normalize_json_body
    body = json.loads(decode(original_body))
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2022-06-18 20:06:05,665 DEBUG[requests_cache.cache_control]:Cache directives from request headers: {}
2022-06-18 20:06:05,666 DEBUG[urllib3.connectionpool]:Starting new HTTPS connection (1): api-v2launch.trakt.tv:443
2022-06-18 20:06:06,120 DEBUG[urllib3.connectionpool]:https://api-v2launch.trakt.tv:443 "GET /users/me HTTP/1.1" 200 None
2022-06-18 20:06:06,121 DEBUG[requests_cache.session]:Pre-cache checks for response from https://api-v2launch.trakt.tv/users/me: {'disabled cache': True, 'disabled method': False, 'disabled status': False, 'disabled by filter': False, 'disabled by headers or expiration params': False}
2022-06-18 20:06:06,122 DEBUG[requests_cache.session]:Skipping cache write for URL: https://api-v2launch.trakt.tv/users/me
2022-06-18 20:06:06,122 DEBUG[trakt.core]:RESPONSE [get] (https://api-v2launch.trakt.tv/users/me): <Response [200]>
2022-06-18 20:06:06,122 DEBUG[trakt.core]:get: https://api-v2launch.trakt.tv/users/boiisxu/watchlist/movies
2022-06-18 20:06:06,122 DEBUG[trakt.core]:headers: {'Content-Type': 'application/json', 'trakt-api-version': '2', 'trakt-api-key': 'redacted', 'Authorization': 'Bearer redacted'}
2022-06-18 20:06:06,122 DEBUG[trakt.core]:method, url :: get, https://api-v2launch.trakt.tv/users/boiisxu/watchlist/movies
2022-06-18 20:06:06,124 DEBUG[requests_cache.cache_keys]:Invalid JSON body:
Traceback (most recent call last):
  File "/volume1/homes/Alex_admin/.local/pipx/venvs/plextraktsync/lib/python3.8/site-packages/requests_cache/cache_keys.py", line 165, in normalize_json_body
    body = json.loads(decode(original_body))
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2022-06-18 20:06:06,124 DEBUG[requests_cache.cache_control]:Cache directives from request headers: {}
2022-06-18 20:06:06,252 DEBUG[urllib3.connectionpool]:https://api-v2launch.trakt.tv:443 "GET /users/boiisxu/watchlist/movies HTTP/1.1" 200 None
2022-06-18 20:06:06,253 DEBUG[requests_cache.session]:Pre-cache checks for response from https://api-v2launch.trakt.tv/users/boiisxu/watchlist/movies: {'disabled cache': True, 'disabled method': False, 'disabled status': False, 'disabled by filter': False, 'disabled by headers or expiration params': False}
2022-06-18 20:06:06,253 DEBUG[requests_cache.session]:Skipping cache write for URL: https://api-v2launch.trakt.tv/users/boiisxu/watchlist/movies
2022-06-18 20:06:06,253 DEBUG[trakt.core]:RESPONSE [get] (https://api-v2launch.trakt.tv/users/boiisxu/watchlist/movies): <Response [200]>
2022-06-18 20:06:06,253 INFO[PlexTraktSync]:Downloaded List Trakt Watchlist
2022-06-18 20:06:06,256 DEBUG[trakt.core]:get: https://api-v2launch.trakt.tv/users/likes/lists?limit=1000
2022-06-18 20:06:06,256 DEBUG[trakt.core]:headers: {'Content-Type': 'application/json', 'trakt-api-version': '2', 'trakt-api-key': 'redacted', 'Authorization': 'Bearer redacted'}
2022-06-18 20:06:06,256 DEBUG[trakt.core]:method, url :: get, https://api-v2launch.trakt.tv/users/likes/lists?limit=1000
2022-06-18 20:06:06,258 DEBUG[requests_cache.cache_keys]:Invalid JSON body:
Traceback (most recent call last):
  File "/volume1/homes/Alex_admin/.local/pipx/venvs/plextraktsync/lib/python3.8/site-packages/requests_cache/cache_keys.py", line 165, in normalize_json_body
    body = json.loads(decode(original_body))
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2022-06-18 20:06:06,258 DEBUG[requests_cache.cache_control]:Cache directives from request headers: {}
2022-06-18 20:06:06,396 DEBUG[urllib3.connectionpool]:https://api-v2launch.trakt.tv:443 "GET /users/likes/lists?limit=1000 HTTP/1.1" 200 None
2022-06-18 20:06:06,397 DEBUG[requests_cache.session]:Pre-cache checks for response from https://api-v2launch.trakt.tv/users/likes/lists?limit=1000: {'disabled cache': True, 'disabled method': False, 'disabled status': False, 'disabled by filter': False, 'disabled by headers or expiration params': False}
2022-06-18 20:06:06,397 DEBUG[requests_cache.session]:Skipping cache write for URL: https://api-v2launch.trakt.tv/users/likes/lists?limit=1000
2022-06-18 20:06:06,398 DEBUG[trakt.core]:RESPONSE [get] (https://api-v2launch.trakt.tv/users/likes/lists?limit=1000): <Response [200]>
2022-06-18 20:06:06,398 DEBUG[trakt.core]:get: https://api-v2launch.trakt.tv/users/donxy/lists/marvel-cinematic-universe
2022-06-18 20:06:06,398 DEBUG[trakt.core]:headers: {'Content-Type': 'application/json', 'trakt-api-version': '2', 'trakt-api-key': 'redacted', 'Authorization': 'Bearer redacted'}
2022-06-18 20:06:06,398 DEBUG[trakt.core]:method, url :: get, https://api-v2launch.trakt.tv/users/donxy/lists/marvel-cinematic-universe
2022-06-18 20:06:06,400 DEBUG[requests_cache.cache_keys]:Invalid JSON body:
Traceback (most recent call last):
  File "/volume1/homes/Alex_admin/.local/pipx/venvs/plextraktsync/lib/python3.8/site-packages/requests_cache/cache_keys.py", line 165, in normalize_json_body
    body = json.loads(decode(original_body))
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2022-06-18 20:06:06,400 DEBUG[requests_cache.cache_control]:Cache directives from request headers: {}
2022-06-18 20:06:06,403 DEBUG[trakt.core]:RESPONSE [get] (https://api-v2launch.trakt.tv/users/donxy/lists/marvel-cinematic-universe): request: GET https://api-v2launch.trakt.tv/users/donxy/lists/marvel-cinematic-universe, response: 200 (5.92 KiB), created: 2022-02-10 22:43:56 CET, expires: N/A (fresh)
2022-06-18 20:06:06,404 DEBUG[trakt.core]:get: https://api-v2launch.trakt.tv/users/donxy/lists/marvel-cinematic-universe/items
2022-06-18 20:06:06,404 DEBUG[trakt.core]:headers: {'Content-Type': 'application/json', 'trakt-api-version': '2', 'trakt-api-key': 'redacted', 'Authorization': 'Bearer redacted'}
2022-06-18 20:06:06,404 DEBUG[trakt.core]:method, url :: get, https://api-v2launch.trakt.tv/users/donxy/lists/marvel-cinematic-universe/items
2022-06-18 20:06:06,405 DEBUG[requests_cache.cache_keys]:Invalid JSON body:
Traceback (most recent call last):
  File "/volume1/homes/Alex_admin/.local/pipx/venvs/plextraktsync/lib/python3.8/site-packages/requests_cache/cache_keys.py", line 165, in normalize_json_body
    body = json.loads(decode(original_body))
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2022-06-18 20:06:06,406 DEBUG[requests_cache.cache_control]:Cache directives from request headers: {}
2022-06-18 20:06:06,406 DEBUG[trakt.core]:RESPONSE [get] (https://api-v2launch.trakt.tv/users/donxy/lists/marvel-cinematic-universe/items): request: GET https://api-v2launch.trakt.tv/users/donxy/lists/marvel-cinematic-universe/items, response: 200 (70.80 KiB), created: 2022-02-10 22:43:57 CET, expires: N/A (fresh)
2022-06-18 20:06:06,411 INFO[PlexTraktSync]:Downloaded List MARVEL Cinematic Universe
2022-06-18 20:06:06,422 DEBUG[trakt.core]:get: https://api-v2launch.trakt.tv/search/tmdb/122?type=movie
2022-06-18 20:06:06,422 DEBUG[trakt.core]:headers: {'Content-Type': 'application/json', 'trakt-api-version': '2', 'trakt-api-key': 'redacted', 'Authorization': 'Bearer redacted'}
2022-06-18 20:06:06,422 DEBUG[trakt.core]:method, url :: get, https://api-v2launch.trakt.tv/search/tmdb/122?type=movie
2022-06-18 20:06:06,424 DEBUG[requests_cache.cache_keys]:Invalid JSON body:
Traceback (most recent call last):
  File "/volume1/homes/Alex_admin/.local/pipx/venvs/plextraktsync/lib/python3.8/site-packages/requests_cache/cache_keys.py", line 165, in normalize_json_body
    body = json.loads(decode(original_body))
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2022-06-18 20:06:06,424 DEBUG[requests_cache.cache_control]:Cache directives from request headers: {}
2022-06-18 20:06:06,425 DEBUG[trakt.core]:RESPONSE [get] (https://api-v2launch.trakt.tv/search/tmdb/122?type=movie): request: GET https://api-v2launch.trakt.tv/search/tmdb/122?type=movie, response: 200 (217 bytes), created: 2022-02-10 22:48:56 CET, expires: N/A (fresh)
2022-06-18 20:06:06,425 DEBUG[trakt.core]:get: https://api-v2launch.trakt.tv/users/boiisxu/collection/movies?extended=metadata
2022-06-18 20:06:06,425 DEBUG[trakt.core]:headers: {'Content-Type': 'application/json', 'trakt-api-version': '2', 'trakt-api-key': 'redacted', 'Authorization': 'Bearer redacted'}
2022-06-18 20:06:06,425 DEBUG[trakt.core]:method, url :: get, https://api-v2launch.trakt.tv/users/boiisxu/collection/movies?extended=metadata
2022-06-18 20:06:06,426 DEBUG[requests_cache.cache_keys]:Invalid JSON body:
Traceback (most recent call last):
  File "/volume1/homes/Alex_admin/.local/pipx/venvs/plextraktsync/lib/python3.8/site-packages/requests_cache/cache_keys.py", line 165, in normalize_json_body
    body = json.loads(decode(original_body))
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2022-06-18 20:06:06,427 DEBUG[requests_cache.cache_control]:Cache directives from request headers: {}
2022-06-18 20:06:06,723 DEBUG[urllib3.connectionpool]:https://api-v2launch.trakt.tv:443 "GET /users/boiisxu/collection/movies?extended=metadata HTTP/1.1" 200 None
2022-06-18 20:06:06,816 DEBUG[requests_cache.session]:Pre-cache checks for response from https://api-v2launch.trakt.tv/users/boiisxu/collection/movies?extended=metadata: {'disabled cache': True, 'disabled method': False, 'disabled status': False, 'disabled by filter': False, 'disabled by headers or expiration params': False}
2022-06-18 20:06:06,817 DEBUG[requests_cache.session]:Skipping cache write for URL: https://api-v2launch.trakt.tv/users/boiisxu/collection/movies?extended=metadata
2022-06-18 20:06:06,817 DEBUG[trakt.core]:RESPONSE [get] (https://api-v2launch.trakt.tv/users/boiisxu/collection/movies?extended=metadata): <Response [200]>
2022-06-18 20:06:06,839 DEBUG[plexapi]:GET https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/library/sections/2/all?includeMeta=1&includeAdvanced=1&X-Plex-Container-Start=0&X-Plex-Container-Size=0
2022-06-18 20:06:06,847 DEBUG[requests_cache.cache_control]:Cache directives from request headers: {}
2022-06-18 20:06:06,864 DEBUG[urllib3.connectionpool]:https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400 "GET /library/sections/2/all?includeMeta=1&includeAdvanced=1&X-Plex-Container-Start=0&X-Plex-Container-Size=0 HTTP/1.1" 200 1476
2022-06-18 20:06:06,865 DEBUG[requests_cache.session]:Pre-cache checks for response from https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/library/sections/2/all?includeMeta=1&includeAdvanced=1&X-Plex-Container-Start=0&X-Plex-Container-Size=0: {'disabled cache': True, 'disabled method': False, 'disabled status': False, 'disabled by filter': False, 'disabled by headers or expiration params': False}
2022-06-18 20:06:06,865 DEBUG[requests_cache.session]:Skipping cache write for URL: https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/library/sections/2/all?includeMeta=1&includeAdvanced=1&X-Plex-Container-Start=0&X-Plex-Container-Size=0
2022-06-18 20:06:06,873 DEBUG[plexapi]:GET https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/library/sections/2/collections?includeMeta=1&includeAdvanced=1&X-Plex-Container-Start=0&X-Plex-Container-Size=0
2022-06-18 20:06:06,874 DEBUG[requests_cache.cache_control]:Cache directives from request headers: {}
2022-06-18 20:06:06,879 DEBUG[urllib3.connectionpool]:https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400 "GET /library/sections/2/collections?includeMeta=1&includeAdvanced=1&X-Plex-Container-Start=0&X-Plex-Container-Size=0 HTTP/1.1" 200 660
2022-06-18 20:06:06,880 DEBUG[requests_cache.session]:Pre-cache checks for response from https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/library/sections/2/collections?includeMeta=1&includeAdvanced=1&X-Plex-Container-Start=0&X-Plex-Container-Size=0: {'disabled cache': True, 'disabled method': False, 'disabled status': False, 'disabled by filter': False, 'disabled by headers or expiration params': False}
2022-06-18 20:06:06,880 DEBUG[requests_cache.session]:Skipping cache write for URL: https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/library/sections/2/collections?includeMeta=1&includeAdvanced=1&X-Plex-Container-Start=0&X-Plex-Container-Size=0
2022-06-18 20:06:06,882 DEBUG[plexapi]:GET https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/library/sections/2/all?includeGuids=1&push=1&userRating%3E%3E=-1&pop=1
2022-06-18 20:06:06,884 DEBUG[requests_cache.cache_control]:Cache directives from request headers: {}
2022-06-18 20:06:06,927 DEBUG[urllib3.connectionpool]:https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400 "GET /library/sections/2/all?includeGuids=1&push=1&userRating%3E%3E=-1&pop=1&X-Plex-Container-Start=0&X-Plex-Container-Size=100 HTTP/1.1" 200 15962
2022-06-18 20:06:06,928 DEBUG[requests_cache.session]:Pre-cache checks for response from https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/library/sections/2/all?includeGuids=1&push=1&userRating%3E%3E=-1&pop=1&X-Plex-Container-Start=0&X-Plex-Container-Size=100: {'disabled cache': True, 'disabled method': False, 'disabled status': False, 'disabled by filter': False, 'disabled by headers or expiration params': False}
2022-06-18 20:06:06,928 DEBUG[requests_cache.session]:Skipping cache write for URL: https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/library/sections/2/all?includeGuids=1&push=1&userRating%3E%3E=-1&pop=1&X-Plex-Container-Start=0&X-Plex-Container-Size=100
2022-06-18 20:06:07,267 DEBUG[trakt.core]:get: https://api-v2launch.trakt.tv/users/boiisxu/ratings/movies
2022-06-18 20:06:07,267 DEBUG[trakt.core]:headers: {'Content-Type': 'application/json', 'trakt-api-version': '2', 'trakt-api-key': 'redacted', 'Authorization': 'Bearer redacted'}
2022-06-18 20:06:07,267 DEBUG[trakt.core]:method, url :: get, https://api-v2launch.trakt.tv/users/boiisxu/ratings/movies
2022-06-18 20:06:07,269 DEBUG[requests_cache.cache_keys]:Invalid JSON body:
Traceback (most recent call last):
  File "/volume1/homes/Alex_admin/.local/pipx/venvs/plextraktsync/lib/python3.8/site-packages/requests_cache/cache_keys.py", line 165, in normalize_json_body
    body = json.loads(decode(original_body))
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2022-06-18 20:06:07,269 DEBUG[requests_cache.cache_control]:Cache directives from request headers: {}
2022-06-18 20:06:07,422 DEBUG[urllib3.connectionpool]:https://api-v2launch.trakt.tv:443 "GET /users/boiisxu/ratings/movies HTTP/1.1" 200 None
2022-06-18 20:06:07,423 DEBUG[requests_cache.session]:Pre-cache checks for response from https://api-v2launch.trakt.tv/users/boiisxu/ratings/movies: {'disabled cache': True, 'disabled method': False, 'disabled status': False, 'disabled by filter': False, 'disabled by headers or expiration params': False}
2022-06-18 20:06:07,423 DEBUG[requests_cache.session]:Skipping cache write for URL: https://api-v2launch.trakt.tv/users/boiisxu/ratings/movies
2022-06-18 20:06:07,423 DEBUG[trakt.core]:RESPONSE [get] (https://api-v2launch.trakt.tv/users/boiisxu/ratings/movies): <Response [200]>
2022-06-18 20:06:07,424 DEBUG[trakt.core]:get: https://api-v2launch.trakt.tv/users/boiisxu/watched/movies
2022-06-18 20:06:07,424 DEBUG[trakt.core]:headers: {'Content-Type': 'application/json', 'trakt-api-version': '2', 'trakt-api-key': 'redacted', 'Authorization': 'Bearer redacted'}
2022-06-18 20:06:07,430 DEBUG[trakt.core]:method, url :: get, https://api-v2launch.trakt.tv/users/boiisxu/watched/movies
2022-06-18 20:06:07,432 DEBUG[requests_cache.cache_keys]:Invalid JSON body:
Traceback (most recent call last):
  File "/volume1/homes/Alex_admin/.local/pipx/venvs/plextraktsync/lib/python3.8/site-packages/requests_cache/cache_keys.py", line 165, in normalize_json_body
    body = json.loads(decode(original_body))
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2022-06-18 20:06:07,433 DEBUG[requests_cache.cache_control]:Cache directives from request headers: {}
2022-06-18 20:06:07,598 DEBUG[urllib3.connectionpool]:https://api-v2launch.trakt.tv:443 "GET /users/boiisxu/watched/movies HTTP/1.1" 200 None
2022-06-18 20:06:07,599 DEBUG[requests_cache.session]:Pre-cache checks for response from https://api-v2launch.trakt.tv/users/boiisxu/watched/movies: {'disabled cache': True, 'disabled method': False, 'disabled status': False, 'disabled by filter': False, 'disabled by headers or expiration params': False}
2022-06-18 20:06:07,599 DEBUG[requests_cache.session]:Skipping cache write for URL: https://api-v2launch.trakt.tv/users/boiisxu/watched/movies
2022-06-18 20:06:07,599 DEBUG[trakt.core]:RESPONSE [get] (https://api-v2launch.trakt.tv/users/boiisxu/watched/movies): <Response [200]>
2022-06-18 20:06:07,601 INFO[PlexTraktSync]:Marking as watched in Plex: <tmdb:122:Movie:3043:El-señor-de-los-anil>
2022-06-18 20:06:07,609 DEBUG[plexapi]:GET https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/:/scrobble?key=3043&identifier=com.plexapp.plugins.library
2022-06-18 20:06:07,611 DEBUG[requests_cache.cache_control]:Cache directives from request headers: {}
2022-06-18 20:06:07,616 DEBUG[urllib3.connectionpool]:https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400 "GET /:/scrobble?key=3043&identifier=com.plexapp.plugins.library HTTP/1.1" 200 0
2022-06-18 20:06:07,617 DEBUG[requests_cache.session]:Pre-cache checks for response from https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/:/scrobble?key=3043&identifier=com.plexapp.plugins.library: {'disabled cache': True, 'disabled method': False, 'disabled status': False, 'disabled by filter': False, 'disabled by headers or expiration params': False}
2022-06-18 20:06:07,617 DEBUG[requests_cache.session]:Skipping cache write for URL: https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/:/scrobble?key=3043&identifier=com.plexapp.plugins.library
2022-06-18 20:06:07,617 DEBUG[trakt.core]:get: https://api-v2launch.trakt.tv/search/tmdb/122?type=movie
2022-06-18 20:06:07,617 DEBUG[trakt.core]:headers: {'Content-Type': 'application/json', 'trakt-api-version': '2', 'trakt-api-key': 'redacted', 'Authorization': 'Bearer redacted'}
2022-06-18 20:06:07,617 DEBUG[trakt.core]:method, url :: get, https://api-v2launch.trakt.tv/search/tmdb/122?type=movie
2022-06-18 20:06:07,619 DEBUG[requests_cache.cache_keys]:Invalid JSON body:
Traceback (most recent call last):
  File "/volume1/homes/Alex_admin/.local/pipx/venvs/plextraktsync/lib/python3.8/site-packages/requests_cache/cache_keys.py", line 165, in normalize_json_body
    body = json.loads(decode(original_body))
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2022-06-18 20:06:07,620 DEBUG[requests_cache.cache_control]:Cache directives from request headers: {}
2022-06-18 20:06:07,620 DEBUG[trakt.core]:RESPONSE [get] (https://api-v2launch.trakt.tv/search/tmdb/122?type=movie): request: GET https://api-v2launch.trakt.tv/search/tmdb/122?type=movie, response: 200 (217 bytes), created: 2022-02-10 22:48:56 CET, expires: N/A (fresh)
2022-06-18 20:06:07,621 INFO[PlexTraktSync]:Marking as watched in Plex: <tmdb:122:Movie:3043:El-señor-de-los-anil>
2022-06-18 20:06:07,628 DEBUG[plexapi]:GET https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/:/scrobble?key=3043&identifier=com.plexapp.plugins.library
2022-06-18 20:06:07,630 DEBUG[requests_cache.cache_control]:Cache directives from request headers: {}
2022-06-18 20:06:07,635 DEBUG[urllib3.connectionpool]:https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400 "GET /:/scrobble?key=3043&identifier=com.plexapp.plugins.library HTTP/1.1" 200 0
2022-06-18 20:06:07,636 DEBUG[requests_cache.session]:Pre-cache checks for response from https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/:/scrobble?key=3043&identifier=com.plexapp.plugins.library: {'disabled cache': True, 'disabled method': False, 'disabled status': False, 'disabled by filter': False, 'disabled by headers or expiration params': False}
2022-06-18 20:06:07,636 DEBUG[requests_cache.session]:Skipping cache write for URL: https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/:/scrobble?key=3043&identifier=com.plexapp.plugins.library
2022-06-18 20:06:07,644 DEBUG[PlexTraktSync]:Sleeping for 0.723 seconds
2022-06-18 20:06:08,368 DEBUG[PlexTraktSync]:Sleeping for 1.100 seconds
2022-06-18 20:06:09,469 DEBUG[plexapi]:GET https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/playlists?title=Trakt%20Watchlist
2022-06-18 20:06:09,471 DEBUG[requests_cache.cache_control]:Cache directives from request headers: {}
2022-06-18 20:06:09,475 DEBUG[urllib3.connectionpool]:https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400 "GET /playlists?title=Trakt%20Watchlist HTTP/1.1" 200 317
2022-06-18 20:06:09,476 DEBUG[requests_cache.session]:Pre-cache checks for response from https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/playlists?title=Trakt%20Watchlist: {'disabled cache': True, 'disabled method': False, 'disabled status': False, 'disabled by filter': False, 'disabled by headers or expiration params': False}
2022-06-18 20:06:09,476 DEBUG[requests_cache.session]:Skipping cache write for URL: https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/playlists?title=Trakt%20Watchlist
2022-06-18 20:06:09,477 DEBUG[plexapi]:DELETE https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/playlists/27416
2022-06-18 20:06:09,479 DEBUG[requests_cache.cache_control]:Cache directives from request headers: {}
2022-06-18 20:06:09,487 DEBUG[urllib3.connectionpool]:https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400 "DELETE /playlists/27416 HTTP/1.1" 204 0
2022-06-18 20:06:09,487 DEBUG[requests_cache.session]:Pre-cache checks for response from https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/playlists/27416: {'disabled cache': True, 'disabled method': True, 'disabled status': True, 'disabled by filter': False, 'disabled by headers or expiration params': False}
2022-06-18 20:06:09,487 DEBUG[requests_cache.session]:Skipping cache write for URL: https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/playlists/27416
2022-06-18 20:06:09,488 DEBUG[plexapi]:GET https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/playlists?title=MARVEL%20Cinematic%20Universe
2022-06-18 20:06:09,489 DEBUG[requests_cache.cache_control]:Cache directives from request headers: {}
2022-06-18 20:06:09,494 DEBUG[urllib3.connectionpool]:https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400 "GET /playlists?title=MARVEL%20Cinematic%20Universe HTTP/1.1" 200 329
2022-06-18 20:06:09,494 DEBUG[requests_cache.session]:Pre-cache checks for response from https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/playlists?title=MARVEL%20Cinematic%20Universe: {'disabled cache': True, 'disabled method': False, 'disabled status': False, 'disabled by filter': False, 'disabled by headers or expiration params': False}
2022-06-18 20:06:09,495 DEBUG[requests_cache.session]:Skipping cache write for URL: https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/playlists?title=MARVEL%20Cinematic%20Universe
2022-06-18 20:06:09,496 DEBUG[plexapi]:DELETE https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/playlists/27417
2022-06-18 20:06:09,497 DEBUG[requests_cache.cache_control]:Cache directives from request headers: {}
2022-06-18 20:06:09,748 DEBUG[urllib3.connectionpool]:https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400 "DELETE /playlists/27417 HTTP/1.1" 204 0
2022-06-18 20:06:09,749 DEBUG[requests_cache.session]:Pre-cache checks for response from https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/playlists/27417: {'disabled cache': True, 'disabled method': True, 'disabled status': True, 'disabled by filter': False, 'disabled by headers or expiration params': False}
2022-06-18 20:06:09,749 DEBUG[requests_cache.session]:Skipping cache write for URL: https://192-168-1-28.0d01cc753c304e63b2b2d9af54bb15cc.plex.direct:32400/playlists/27417
2022-06-18 20:06:09,750 INFO[PlexTraktSync]:Updated plex watchlist in 0.3 seconds
2022-06-18 20:06:09,752 DEBUG[PlexTraktSync]:Sleeping for 0.817 seconds
2022-06-18 20:06:10,570 INFO[PlexTraktSync]:Completed full sync in 4.9 seconds

Expected behavior

Play date on plex which matches the one stored on Trakt

Steps to reproduce the behavior

  1. Mark an item as unwatched on Plex.
  2. Run the script plextraktsync sync --id 3043H

Inspect of problematic items

Inspecting 3043: <tmdb:122:Movie:3043:El-señor-de-los-anil>
URL: https://app.plex.tv/desktop/#!/server/f720e976211d293339e6f413846aec9de634fce3/details?key=/library/metadata/3043
Media.Type: 'movie'
Media.Guid: 'plex://movie/5d7768248a7581001f12bc73'
Media.Guids: [<Guid:imdb://tt0167260>, <Guid:tmdb://122>, <Guid:tvdb://74>]
Audio: '7.1', 'Español (DTS-HD MA 7.1)'
Video: 'h264'
Subtitles:
  Subtitle 1: (Español) Castellano Forzados [Planos] (codec: srt, selected: True, transient: None)
  Subtitle 2: (Español) Castellano Forzados (PGS) (codec: pgs, selected: False, transient: None)
  Subtitle 3: (Español) Castellano Completos [Planos] (codec: srt, selected: False, transient: None)
  Subtitle 4: (Español) Castellano Completos (PGS) (codec: pgs, selected: False, transient: None)
  Subtitle 5: (English) Ingles Forzados [Planos] (codec: srt, selected: False, transient: None)
  Subtitle 6: (English) Ingles Forzados (PGS) (codec: pgs, selected: False, transient: None)
  Subtitle 7: (English) Ingles Completos [Planos] (codec: srt, selected: False, transient: None)
  Subtitle 8: (English) Ingles Completos (PGS) (codec: pgs, selected: False, transient: None)
  Subtitle 9: (Español) Comentarios del director y guionistas (codec: srt, selected: False, transient: None)
  Subtitle 10: (Español) Comentarios del director y guionistas (codec: pgs, selected: False, transient: None)
  Subtitle 11: (Español) Comentarios de los actores (codec: srt, selected: False, transient: None)
  Subtitle 12: (Español) Comentarios de los actores (codec: pgs, selected: False, transient: None)
  Subtitle 13: (Español) Comentarios de los diseñadores (codec: srt, selected: False, transient: None)
  Subtitle 14: (Español) Comentarios de los diseñadores (codec: pgs, selected: False, transient: None)
  Subtitle 15: (Español) Comentarios de los productores (codec: srt, selected: False, transient: None)
  Subtitle 16: (Español) Comentarios de los productores (codec: pgs, selected: False, transient: None)
Parts:
  Part 1: /volume1/data/merged/media/movies/The Lord of the Rings The Return of the King (2003)/The Lord of the Rings The Return of the King 
(2003) [Remux-1080p][8bit][DTS-HD MA 7.1].mkv
Guids:
  Guid: <PlexGuid:tmdb://122>, Id: 122, Provider: 'tmdb'
  Guid: <PlexGuid:tvdb://74>, Id: 74, Provider: 'tvdb'
  Guid: <PlexGuid:imdb://tt0167260>, Id: tt0167260, Provider: 'imdb'
Metadata: {'collected_at': '2021-02-09:T19:45:00.000Z', 'media_type': 'digital', 'resolution': 'hd_1080p', 'audio': 'dts', 'audio_channels': 
'7.1'}
Trakt: https://trakt.tv/movies/90
Plex Rating: None
Trakt Rating: None
Watched on Plex: True
Watched on Trakt: True
Plex play history:
- 2022-06-18 20:06:07 by redacted on redacted with PlexTraktSync
- 2022-06-18 20:06:07 by redacted on redacted with PlexTraktSync

Workarounds

No response

Install method

pipx (Recommended)

Version

0.20.1

Python Version

3.8.12

Operating System and Version

Synology DSM 7

simonc56 commented 2 years ago

I have read the README.md on the project homepage

Really ? Read Features again.

CMBoii commented 2 years ago

I have read the README.md on the project homepage

Really ? Read Features again.

Ok, I must admit that I read that part a bit quickly.

I'm sorry.