Open PatientLightning opened 1 year ago
Ok, I have found a fix that works well for now. Here's a minimum example to show the difference from before and after;
Old and Busted throws "OSError: [Errno 22] Invalid argument" on windows platforms
from dateutil import tz, parser
from six import string_types
date = "1957-09-21 00:00:00+00:00"
date = parser.parse(date) if isinstance(date, string_types) else date
date = date.replace(tzinfo=tz.tzutc())
date = date.astimezone(tz.tzlocal()) #<-- this line throws an error
print(date.strftime('%Y-%m-%dT%H:%M:%S'))
New Hotness Runs without complaint
import datetime
import time
from dateutil import tz, parser
from six import string_types
date = "1957-09-21 00:00:00+00:00"
date = parser.parse(date) if isinstance(date, string_types) else date
date = date.replace(tzinfo=tz.tzutc())
local_utc_offset = -time.timezone
# ^^^ thanks to: jfs via https://stackoverflow.com/a/3168394
date = date + datetime.timedelta(seconds=local_utc_offset)
# ^^^ thanks to: Ignacio Vazquez-Abrams via https://stackoverflow.com/a/22082178
print(date.strftime('%Y-%m-%dT%H:%M:%S'))
I updated utils.py with the relevant bits and copied it over to my Xbox and I was able to resume the sync successfully without errors. Now the only thing I have to remember is that the dates and times for media should always be stored in UTC, so they will be displayed correctly in the local time zone.
I don't know how to turn this into a pull request yet, but I guess that's the next thing I'll figure out
Logged in to let you know that I too believe I have this issue. Have an Xbox Kodi install that is stalling on sync when it hit Bewitched (obviously made before 1970).
Would you be able to share the modified plugin so that I can test as well?
For sure,
I think I figured out how to add a pull request, so you can get the file from here: https://github.com/jellyfin/jellyfin-kodi/pull/756 Hopefully this will be approved for the next release so I don't have to copy over files again.
To install it for testing, I put the modified utils.py onto a USB stick and plugged it into the Xbox to copy it over the existing one in Kodi.
For sure,
I think I figured out how to add a pull request, so you can get the file from here: #756 Hopefully this will be approved for the next release so I don't have to copy over files again.
To install it for testing, I put the modified utils.py onto a USB stick and plugged it into the Xbox to copy it over the existing one in Kodi.
That did it. I was sitting at overnight with a sync (and not finishing). Replaced the util.py file in the helpers folder, cleared my DB and tried again. Finished with a 15 minute sync. Wife is again happy.
Thank you so much!
With #775 #776 #780 and now finally #785, I'm not able to reproduce this issue in tests (py3 only), even tho the underlying timezone function is unchanged.
The current test cases are as follows, and should cover most edge cases, including dates pre epoch: https://github.com/jellyfin/jellyfin-kodi/blob/e95e8d6a88d706f096a5a15b3d53b1fe1214fb2c/tests/test_helper_utils.py#L39-L75
If you are still seeing this issue with the master branch, I would like more logs from both of you, at a minimum the following sections:
$ cat ~/.kodi/temp/kodi.log | python -c 'import re,sys;print(re.match("\n?.*?-{71}.*?-{71}", sys.stdin.read(), flags=re.DOTALL)[0])'
2023-10-20 13:59:42.850 T:2074881 info <general>: -----------------------------------------------------------------------
2023-10-20 13:59:42.850 T:2074881 info <general>: Starting Kodi (20.2 (20.2.0) Git:20230630-5f418d0b13). Platform: Linux x86 64-bit
2023-10-20 13:59:42.850 T:2074881 info <general>: Using Release Kodi x64
2023-10-20 13:59:42.850 T:2074881 info <general>: Kodi compiled 2023-06-30 by GCC 11.3.0 for Linux x86 64-bit version 5.15.99 (331619)
2023-10-20 13:59:42.850 T:2074881 info <general>: Running on Linux Mint 21.2, kernel: Linux x86 64-bit version 5.15.0-84-generic
2023-10-20 13:59:42.851 T:2074881 info <general>: FFmpeg version/source: 4.4.1-Kodi
2023-10-20 13:59:42.851 T:2074881 info <general>: Host CPU: Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz, 8 cores available
2023-10-20 13:59:42.851 T:2074881 info <general>: special://xbmc/ is mapped to: /usr/share/kodi
2023-10-20 13:59:42.851 T:2074881 info <general>: special://xbmcbin/ is mapped to: /usr/lib/x86_64-linux-gnu/kodi
2023-10-20 13:59:42.851 T:2074881 info <general>: special://xbmcbinaddons/ is mapped to: /usr/lib/x86_64-linux-gnu/kodi/addons
2023-10-20 13:59:42.851 T:2074881 info <general>: special://masterprofile/ is mapped to: /home/oddstr13/.kodi/userdata
2023-10-20 13:59:42.851 T:2074881 info <general>: special://envhome/ is mapped to: /home/oddstr13
2023-10-20 13:59:42.851 T:2074881 info <general>: special://home/ is mapped to: /home/oddstr13/.kodi
2023-10-20 13:59:42.851 T:2074881 info <general>: special://temp/ is mapped to: /home/oddstr13/.kodi/temp
2023-10-20 13:59:42.851 T:2074881 info <general>: special://logpath/ is mapped to: /home/oddstr13/.kodi/temp
2023-10-20 13:59:42.851 T:2074881 info <general>: Webserver extra whitelist paths:
2023-10-20 13:59:42.851 T:2074881 info <general>: The executable running is: /usr/lib/x86_64-linux-gnu/kodi/kodi.bin
2023-10-20 13:59:42.851 T:2074881 info <general>: Local hostname: 1070L
2023-10-20 13:59:42.851 T:2074881 info <general>: Log File is located: /home/oddstr13/.kodi/temp/kodi.log
2023-10-20 13:59:42.851 T:2074881 info <general>: -----------------------------------------------------------------------
$ grep -Pi 'entrypoint/service.py:[0-9]{2} ' ~/.kodi/temp/kodi.log
2023-10-20 13:59:44.914 T:2074916 info <general>: JELLYFIN.jellyfin_kodi.entrypoint.service -> INFO::jellyfin_kodi/entrypoint/service.py:62 --->>>[ JELLYFIN ]
2023-10-20 13:59:44.915 T:2074916 info <general>: JELLYFIN.jellyfin_kodi.entrypoint.service -> INFO::jellyfin_kodi/entrypoint/service.py:63 Version: 0.7.5+py3
2023-10-20 13:59:44.916 T:2074916 info <general>: JELLYFIN.jellyfin_kodi.entrypoint.service -> INFO::jellyfin_kodi/entrypoint/service.py:64 KODI Version: 20.2 (20.2.0) Git:20230630-5f418d0b13
2023-10-20 13:59:44.917 T:2074916 info <general>: JELLYFIN.jellyfin_kodi.entrypoint.service -> INFO::jellyfin_kodi/entrypoint/service.py:65 Platform: Linux/RPi
2023-10-20 13:59:44.918 T:2074916 info <general>: JELLYFIN.jellyfin_kodi.entrypoint.service -> INFO::jellyfin_kodi/entrypoint/service.py:66 Python Version: 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0]
2023-10-20 13:59:44.921 T:2074916 info <general>: JELLYFIN.jellyfin_kodi.entrypoint.service -> INFO::jellyfin_kodi/entrypoint/service.py:67 Using dynamic paths: True
2023-10-20 13:59:44.921 T:2074916 info <general>: JELLYFIN.jellyfin_kodi.entrypoint.service -> INFO::jellyfin_kodi/entrypoint/service.py:68 Log Level: 2
I have (I think) the same issue on xbox series x. Using new clean kodi install with no addons except jellyfin for kodi.
Not sure if this link is relevant (its cpython) it seemed similar and affected windows only not linux https://github.com/python/cpython/issues/94414
My kodi log right after a (long) sync with jellyfin:
$ cat kodi.log | python -c 'import re,sys;print(re.match("\n?.*?-{71}.*?-{71}", sys.stdin.read(), flags=re.DOTALL)[0])'
2024-02-03 18:52:29.334 T:3220 info <general>: -----------------------------------------------------------------------
2024-02-03 18:52:29.334 T:3220 info <general>: Starting Kodi (20.3 (20.3.0) Git:20240110-6fb2bfc7ff). Platform: Windows NT x86 64-bit
2024-02-03 18:52:29.335 T:3220 info <general>: Using Release Kodi x64
2024-02-03 18:52:29.335 T:3220 info <general>: Kodi compiled 2024-01-10 by MSVC 193431937 for Windows NT x86 64-bit version 10.0 (0x0A000007)
2024-02-03 18:52:29.335 T:3220 info <general>: Running on Microsoft Xbox Series X with WINDOWS 10.0.25398.2923, kernel: WINDOWS x86 64-bit version 10.0.25398.2923
2024-02-03 18:52:29.336 T:3220 info <general>: FFmpeg version/source: 4.4.1-Kodi
2024-02-03 18:52:29.336 T:3220 info <general>: Host CPU: Unknown, 8 cores available
2024-02-03 18:52:29.336 T:3220 info <general>: System has 4.3 GB of RAM installed
2024-02-03 18:52:29.340 T:3220 info <general>: Desktop Resolution: 1920x1080 24Bit at 59.94Hz
2024-02-03 18:52:29.340 T:3220 info <general>: Running with restricted rights
2024-02-03 18:52:29.340 T:3220 info <general>: Aero is disabled
2024-02-03 18:52:29.342 T:3220 info <general>: Display is not HDR capable or cannot be detected
2024-02-03 18:52:29.343 T:3220 info <general>: special://xbmc/ is mapped to: S:\Program Files\WindowsApps\XBMCFoundation.Kodi_20.3.0.70_x64__4n2hpmxwrvr6p
2024-02-03 18:52:29.343 T:3220 info <general>: special://xbmcbin/ is mapped to: S:\Program Files\WindowsApps\XBMCFoundation.Kodi_20.3.0.70_x64__4n2hpmxwrvr6p
2024-02-03 18:52:29.343 T:3220 info <general>: special://xbmcbinaddons/ is mapped to: S:\Program Files\WindowsApps\XBMCFoundation.Kodi_20.3.0.70_x64__4n2hpmxwrvr6p/addons
2024-02-03 18:52:29.343 T:3220 info <general>: special://masterprofile/ is mapped to: Q:\Users\UserMgr0\AppData\Local\Packages\XBMCFoundation.Kodi_4n2hpmxwrvr6p\LocalState\userdata
2024-02-03 18:52:29.343 T:3220 info <general>: special://home/ is mapped to: Q:\Users\UserMgr0\AppData\Local\Packages\XBMCFoundation.Kodi_4n2hpmxwrvr6p\LocalState
2024-02-03 18:52:29.343 T:3220 info <general>: special://temp/ is mapped to: Q:\Users\UserMgr0\AppData\Local\Packages\XBMCFoundation.Kodi_4n2hpmxwrvr6p\LocalState\cache
2024-02-03 18:52:29.343 T:3220 info <general>: special://logpath/ is mapped to: Q:\Users\UserMgr0\AppData\Local\Packages\XBMCFoundation.Kodi_4n2hpmxwrvr6p\LocalState
2024-02-03 18:52:29.343 T:3220 info <general>: Webserver extra whitelist paths:
2024-02-03 18:52:29.343 T:3220 info <general>: The executable running is: S:\Program Files\WindowsApps\XBMCFoundation.Kodi_20.3.0.70_x64__4n2hpmxwrvr6p\kodi.exe
2024-02-03 18:52:29.344 T:3220 info <general>: Local hostname: XBOX
2024-02-03 18:52:29.344 T:3220 info <general>: Log File is located: Q:\Users\UserMgr0\AppData\Local\Packages\XBMCFoundation.Kodi_4n2hpmxwrvr6p\LocalState\kodi.log
2024-02-03 18:52:29.345 T:3220 info <general>: -----------------------------------------------------------------------
~ [0|1]> cat kodi.log | grep -i 'entrypoint'
2024-02-03 18:52:32.727 T:324 info <general>: JELLYFIN.jellyfin_kodi.entrypoint.service -> INFO::jellyfin_kodi\entrypoint\service.py:62 --->>>[ JELLYFIN ]
2024-02-03 18:52:32.728 T:324 info <general>: JELLYFIN.jellyfin_kodi.entrypoint.service -> INFO::jellyfin_kodi\entrypoint\service.py:63 Version: 0.7.11+py3
2024-02-03 18:52:32.730 T:324 info <general>: JELLYFIN.jellyfin_kodi.entrypoint.service -> INFO::jellyfin_kodi\entrypoint\service.py:64 KODI Version: 20.3 (20.3.0) Git:20240110-6fb2bfc7ff
2024-02-03 18:52:32.733 T:324 info <general>: JELLYFIN.jellyfin_kodi.entrypoint.service -> INFO::jellyfin_kodi\entrypoint\service.py:65 Platform: Windows
2024-02-03 18:52:32.735 T:324 info <general>: JELLYFIN.jellyfin_kodi.entrypoint.service -> INFO::jellyfin_kodi\entrypoint\service.py:66 Python Version: 3.8.15 (default, Oct 17 2022, 02:35:03) [MSC v.1929 64 bit (AMD64)]
2024-02-03 18:52:32.737 T:324 info <general>: JELLYFIN.jellyfin_kodi.entrypoint.service -> INFO::jellyfin_kodi\entrypoint\service.py:67 Using dynamic paths: True
2024-02-03 18:52:32.739 T:324 info <general>: JELLYFIN.jellyfin_kodi.entrypoint.service -> INFO::jellyfin_kodi\entrypoint\service.py:68 Log Level: 1
The relevant error as far as I can see is the same as in previous posts
2024-02-03 19:59:55.762 T:3264 info <general>: JELLYFIN.jellyfin_kodi.helper.utils -> ERROR::jellyfin_kodi\helper\utils.py:491 Item date: 1964-11-08 00:00:00+00:00 --- [Errno 22] Invalid argument
Traceback (most recent call last):
File "jellyfin_kodi\helper\utils.py", line 484, in convert_to_local
date = date.astimezone(tz.tzlocal())
File "Q:\Users\UserMgr0\AppData\Local\Packages\XBMCFoundation.Kodi_4n2hpmxwrvr6p\LocalState\addons\script.module.dateutil\lib\dateutil\tz\_common.py", line 144, in fromutc
return f(self, dt)
File "Q:\Users\UserMgr0\AppData\Local\Packages\XBMCFoundation.Kodi_4n2hpmxwrvr6p\LocalState\addons\script.module.dateutil\lib\dateutil\tz\_common.py", line 258, in fromutc
dt_wall = self._fromutc(dt)
File "Q:\Users\UserMgr0\AppData\Local\Packages\XBMCFoundation.Kodi_4n2hpmxwrvr6p\LocalState\addons\script.module.dateutil\lib\dateutil\tz\_common.py", line 222, in _fromutc
dtoff = dt.utcoffset()
File "Q:\Users\UserMgr0\AppData\Local\Packages\XBMCFoundation.Kodi_4n2hpmxwrvr6p\LocalState\addons\script.module.dateutil\lib\dateutil\tz\tz.py", line 222, in utcoffset
if self._isdst(dt):
File "Q:\Users\UserMgr0\AppData\Local\Packages\XBMCFoundation.Kodi_4n2hpmxwrvr6p\LocalState\addons\script.module.dateutil\lib\dateutil\tz\tz.py", line 291, in _isdst
dstval = self._naive_is_dst(dt)
File "Q:\Users\UserMgr0\AppData\Local\Packages\XBMCFoundation.Kodi_4n2hpmxwrvr6p\LocalState\addons\script.module.dateutil\lib\dateutil\tz\tz.py", line 260, in _naive_is_dst
return time.localtime(timestamp + time.timezone).tm_isdst
OSError: [Errno 22] Invalid argument
Full log is here up until the point kodi crashed at 80% sync https://paste.kodi.tv/eqoyevivuz
I've applied the work around PatientLightening suggested above and it seems fix the scanning error.
@staplebatteryhorse I pushed the release containing the mentioned fixes just as you where typing out this comment it seems, could you try again with the latest release (sorry, the release pipeline is just inconvenient enough that I end up putting it off :sweat_smile: )
PS: You seem to have swapped the username and password fields :wink:
@oddstr13 thanks, I have just tried with master and 0.7.12 release, the same issue is still happening.
log file here https://paste.kodi.tv/xogoreguco
Thanks for the updated logs!
Starting Kodi (20.3 (20.3.0) Git:20240110-6fb2bfc7ff). Platform: Windows NT x86 64-bit
Using Release Kodi x64
Kodi compiled 2024-01-10 by MSVC 193431937 for Windows NT x86 64-bit version 10.0 (0x0A000007)
Running on Microsoft Xbox Series X with WINDOWS 10.0.25398.2923, kernel: WINDOWS x86 64-bit version 10.0.25398.2923
ERROR::jellyfin_kodi\helper\utils.py:499
The dates in question; indicates trouble with negative (signed) unixtime values
Item date: 1967-09-29 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1969-09-13 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1969-09-13 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1969-09-20 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1969-09-27 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1969-10-04 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1969-10-11 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1969-10-18 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1969-10-25 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1969-11-01 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1969-11-08 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1969-11-15 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1969-11-22 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1969-11-29 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1969-12-06 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1969-12-13 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1969-12-20 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1966-09-08 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1967-01-05 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1967-01-12 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1967-01-19 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1967-01-26 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1967-02-02 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1967-02-09 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1967-02-16 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1967-02-23 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1967-03-02 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1967-03-09 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1967-03-23 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1967-03-30 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1967-04-06 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1967-04-13 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1966-09-08 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1966-09-15 00:00:00+00:00 --- [Errno 22] Invalid argument
Item date: 1966-09-22 00:00:00+00:00 --- [Errno 22] Invalid argument
This issue has now come back since the new update and the patched utils file only works on the previous build, had to revert again until fixed, please help. @PatientLightning if you have any idea how to make a new patch for the latest build please let me in on the secret as i am clueless
This issue has now come back since the new update and the patched utils file only works on the previous build, had to revert again until fixed, please help. @PatientLightning if you have any idea how to make a new patch for the latest build please let me in on the secret as i am clueless
Oh no, what is the new version you're using and what system? Still Xbox? I haven't turned mine on in a while, but I'll take a look when I can
Ok, I updated the helpter/utils.py file with the same approach as last time. My secret is to avoid using the function date.astimezone because it still returns an error on windows platforms for dates before 1970. (https://bugs.python.org/issue31327#msg304159)
You can grab a copy from my fork to test out. https://github.com/PatientLightning/jellyfin-kodi/blob/helper-utils-2024-07/jellyfin_kodi/helper/utils.py If you look at the commit diff you can see the few lines that I have substituted as a naïve workaround.
The real fix is to solve the problem upstream with date.astimezone in the python repo someday, but I hope this helps in the meantime.
@PatientLightning youre a hero! I will give it a test later tonight, yes still xbox, i have about 6 of them laying around just for kodi in different rooms, i did try to incorporate your additions and make a file myself before messeging you but ended up messing it up 5x so gave up, im obviously not built for writing code🤣 i hope they add your fix into the main releases soon as i get a whole house yelling at me to fix it everytime it updates🤦♂️
Describe the bug When syncing a tv show season or episode older than 1970, the sync process throws errors and slows to a crawl
To Reproduce
Expected behavior The sync shouldn't have errors for shows older than 1970
Logs Here's a relevant snippet from the log
System (please complete the following information):
Additional context I think this is caused by the issue referenced here: https://bugs.python.org/issue31327#msg304159 Where the localtime function returns an error on a windows platform if the date is prior to the epoch
Possibly similar to this other issue: https://github.com/jellyfin/jellyfin-kodi/issues/153
It looks like the sync doesn't hang forever, but it takes about 45 seconds to recover from the error before moving on to sync the next episode which would take hours to process.