Merge pull request #1306 from croneter/fix-oserror
Fix OSError: Invalid argument when Plex returns an invalid timestamp
This commit is contained in:
commit
584bcdbaaf
1 changed files with 10 additions and 1 deletions
|
@ -1,8 +1,11 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from logging import getLogger
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from time import localtime, strftime
|
from time import localtime, strftime
|
||||||
|
|
||||||
|
LOG = getLogger('PLEX.timing')
|
||||||
|
|
||||||
EPOCH = datetime.utcfromtimestamp(0)
|
EPOCH = datetime.utcfromtimestamp(0)
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +31,13 @@ def unix_date_to_kodi(unix_kodi_time):
|
||||||
|
|
||||||
Output: Y-m-d h:m:s = 2009-04-05 23:16:04
|
Output: Y-m-d h:m:s = 2009-04-05 23:16:04
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
return strftime('%Y-%m-%d %H:%M:%S', localtime(float(unix_kodi_time)))
|
return strftime('%Y-%m-%d %H:%M:%S', localtime(float(unix_kodi_time)))
|
||||||
|
except Exception:
|
||||||
|
LOG.exception('Received an illegal timestamp from Plex: %s. '
|
||||||
|
'Using 1970-01-01 12:00:00',
|
||||||
|
unix_kodi_time)
|
||||||
|
return '1970-01-01 12:00:00'
|
||||||
|
|
||||||
|
|
||||||
def plex_date_to_kodi(plex_timestamp):
|
def plex_date_to_kodi(plex_timestamp):
|
||||||
|
|
Loading…
Reference in a new issue