trakt / script.trakt

Trakt.tv movie and TV show scrobbler for Kodi
GNU General Public License v2.0
318 stars 149 forks source link

Errors while trying to sync #585

Open EusebiuOprinoiu opened 2 years ago

EusebiuOprinoiu commented 2 years ago

Hello!

I've been having sync issues with Trakt for a long time, but today I finally managed to identify the source of the problem. Maybe you can use my findings to fix the problem once and for all. For context, I'm using Kodi 19.3 ( 64bit Installer ) on Windows 11, but the issue appears on Windows 10 as well.

The problem seems to be caused by the Daylight Saving Time option from Windows Settings. Like most people, I let Windows manage time automatically via NTP, which controls the time, the timezone, and the daylight saving time. With everything on automatic, the errors from the log below appear every time I try to sync my library. If I adjust the time settings manually and disable the option "Adjust daylight saving time automatically", the issue goes away.

Settings that make the errors go away

Windows Settings

Kodi Log

2021-12-09 05:07:49.180 T:32248   ERROR <general>: trakt-sync
2021-12-09 05:07:49.180 T:32248   ERROR <general>: :

2021-12-09 05:07:49.180 T:32248   ERROR <general>: Traceback (most recent call last):

2021-12-09 05:07:49.180 T:32248   ERROR <general>:   File "C:\Program Files\Kodi\system\python\Lib\threading.py", line 932, in _bootstrap_inner

2021-12-09 05:07:49.181 T:32248   ERROR <general>:     
2021-12-09 05:07:49.181 T:32248   ERROR <general>: self.run()
2021-12-09 05:07:49.181 T:32248   ERROR <general>: 

2021-12-09 05:07:49.181 T:32248   ERROR <general>:   File "C:\Users\Eusebiu\AppData\Roaming\Kodi\addons\script.trakt\resources\lib\service.py", line 371, in run

2021-12-09 05:07:49.181 T:32248   ERROR <general>:     
2021-12-09 05:07:49.181 T:32248   ERROR <general>: sync.sync()
2021-12-09 05:07:49.181 T:32248   ERROR <general>: 

2021-12-09 05:07:49.181 T:32248   ERROR <general>:   File "C:\Users\Eusebiu\AppData\Roaming\Kodi\addons\script.trakt\resources\lib\sync.py", line 67, in sync

2021-12-09 05:07:49.181 T:32248   ERROR <general>:     
2021-12-09 05:07:49.182 T:32248   ERROR <general>: syncEpisodes.SyncEpisodes(self, progress)
2021-12-09 05:07:49.182 T:32248   ERROR <general>: 

2021-12-09 05:07:49.182 T:32248   ERROR <general>:   File "C:\Users\Eusebiu\AppData\Roaming\Kodi\addons\script.trakt\resources\lib\syncEpisodes.py", line 21, in __init__

2021-12-09 05:07:49.182 T:32248   ERROR <general>:     
2021-12-09 05:07:49.182 T:32248   ERROR <general>: kodiShowsCollected, kodiShowsWatched = self.__kodiLoadShows()
2021-12-09 05:07:49.182 T:32248   ERROR <general>: 

2021-12-09 05:07:49.182 T:32248   ERROR <general>:   File "C:\Users\Eusebiu\AppData\Roaming\Kodi\addons\script.trakt\resources\lib\syncEpisodes.py", line 141, in __kodiLoadShows

2021-12-09 05:07:49.182 T:32248   ERROR <general>:     
2021-12-09 05:07:49.182 T:32248   ERROR <general>: show['seasons'] = kodiUtilities.kodiRpcToTraktMediaObjects(data)
2021-12-09 05:07:49.182 T:32248   ERROR <general>: 

2021-12-09 05:07:49.182 T:32248   ERROR <general>:   File "C:\Users\Eusebiu\AppData\Roaming\Kodi\addons\script.trakt\resources\lib\kodiUtilities.py", line 230, in kodiRpcToTraktMediaObjects

2021-12-09 05:07:49.182 T:32248   ERROR <general>:     
2021-12-09 05:07:49.182 T:32248   ERROR <general>: episodeObject = kodiRpcToTraktMediaObject('episode', episode, mode)
2021-12-09 05:07:49.182 T:32248   ERROR <general>: 

2021-12-09 05:07:49.182 T:32248   ERROR <general>:   File "C:\Users\Eusebiu\AppData\Roaming\Kodi\addons\script.trakt\resources\lib\kodiUtilities.py", line 171, in kodiRpcToTraktMediaObject

2021-12-09 05:07:49.182 T:32248   ERROR <general>:     
2021-12-09 05:07:49.182 T:32248   ERROR <general>: episode['collected_at'] = utilities.convertDateTimeToUTC(
2021-12-09 05:07:49.182 T:32248   ERROR <general>: 

2021-12-09 05:07:49.182 T:32248   ERROR <general>:   File "C:\Users\Eusebiu\AppData\Roaming\Kodi\addons\script.trakt\resources\lib\utilities.py", line 194, in convertDateTimeToUTC

2021-12-09 05:07:49.183 T:32248   ERROR <general>:     
2021-12-09 05:07:49.183 T:32248   ERROR <general>: utc = local.astimezone(tzutc())
2021-12-09 05:07:49.183 T:32248   ERROR <general>: 

2021-12-09 05:07:49.183 T:32248   ERROR <general>:   File "C:\Users\Eusebiu\AppData\Roaming\Kodi\addons\script.module.dateutil\lib\dateutil\tz\tz.py", line 222, in utcoffset

2021-12-09 05:07:49.183 T:32248   ERROR <general>:     
2021-12-09 05:07:49.183 T:32248   ERROR <general>: if self._isdst(dt):
2021-12-09 05:07:49.183 T:32248   ERROR <general>: 

2021-12-09 05:07:49.183 T:32248   ERROR <general>:   File "C:\Users\Eusebiu\AppData\Roaming\Kodi\addons\script.module.dateutil\lib\dateutil\tz\tz.py", line 294, in _isdst

2021-12-09 05:07:49.183 T:32248   ERROR <general>:     
2021-12-09 05:07:49.183 T:32248   ERROR <general>: if self.is_ambiguous(dt):
2021-12-09 05:07:49.183 T:32248   ERROR <general>: 

2021-12-09 05:07:49.183 T:32248   ERROR <general>:   File "C:\Users\Eusebiu\AppData\Roaming\Kodi\addons\script.module.dateutil\lib\dateutil\tz\tz.py", line 256, in is_ambiguous

2021-12-09 05:07:49.184 T:32248   ERROR <general>:     
2021-12-09 05:07:49.184 T:32248   ERROR <general>: (naive_dst != self._naive_is_dst(dt - self._dst_saved)))
2021-12-09 05:07:49.184 T:32248   ERROR <general>: 

2021-12-09 05:07:49.184 T:32248   ERROR <general>:   File "C:\Users\Eusebiu\AppData\Roaming\Kodi\addons\script.module.dateutil\lib\dateutil\tz\tz.py", line 260, in _naive_is_dst

2021-12-09 05:07:49.184 T:32248   ERROR <general>:     
2021-12-09 05:07:49.184 T:32248   ERROR <general>: return time.localtime(timestamp + time.timezone).tm_isdst
2021-12-09 05:07:49.184 T:32248   ERROR <general>: 

2021-12-09 05:07:49.184 T:32248   ERROR <general>: OSError
2021-12-09 05:07:49.184 T:32248   ERROR <general>: : 
2021-12-09 05:07:49.184 T:32248   ERROR <general>: [Errno 22] Invalid argument
2021-12-09 05:07:49.184 T:32248   ERROR <general>: 
razzeee commented 2 years ago

That seems like a problem with dateutil on first glance https://github.com/dateutil/dateutil

razzeee commented 2 years ago

There is a newer version, available, but not sure if that will fix your problem https://github.com/dateutil/dateutil/releases/tag/2.8.2

EusebiuOprinoiu commented 2 years ago

Yes. The problem seems to be dateutil which is used as a dependency, and unfortunately, the latest version doesn't solve the issue. I thought about opening this ticket on their repository, but in the end, I opened it here because most errors were coming from the \addons\script.trakt\ folder. Should I open a ticket there as well, or should I leave that to you? (I'm guessing you have a better understanding of what is going on)

razzeee commented 2 years ago

You should be fine creating an issue on their repo.

And what you've pasted is one error. It drills down to the place of origin, which is in dateutil.

razzeee commented 2 years ago

Seems to be already tracked here https://github.com/dateutil/dateutil/issues/197

EusebiuOprinoiu commented 2 years ago

Thank you, Kolja! Based on what people say, it doesn't look like a fix will come anytime soon. Downgrading to dateutil 2.5.3 like some people suggest it's also not an option since it's not compatible with Phyton 3.

razzeee commented 2 years ago

Maybe https://github.com/trakt/script.trakt/issues/552#issuecomment-850908460 is something you can consider to do :/

EusebiuOprinoiu commented 2 years ago

Unfortunately, there is no Coordinated Universal Time for UTC+2. I tested with all other UTC+2 time zones available in Windows, and they all have this issue. But it's not the end of the world. I'll keep Daylight Saving Time disabled and manually adjust the time when the hour changes. (after all, it's only twice a year)

From what I can tell, the issue appears only when the timezone uses the Standard Time (because time.localtime() doesn't accept negative values in Windows) and goes away when the timezone switches to Daylight Saving Time. So in my country, the issues appear between October 30th and March 27th.

rantanlan commented 2 years ago

doesn't work for me, regardless of the timezone and the settings :/