mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-26 02:36:10 +00:00
Prevent harmless errors about bad dates from the server
This commit is contained in:
parent
f874951cf0
commit
1d02fccce6
1 changed files with 8 additions and 5 deletions
|
@ -478,12 +478,15 @@ def convert_to_local(date):
|
||||||
'''
|
'''
|
||||||
try:
|
try:
|
||||||
date = parser.parse(date) if isinstance(date, string_types) else date
|
date = parser.parse(date) if isinstance(date, string_types) else date
|
||||||
date = date.replace(tzinfo=tz.tzutc())
|
parsed_date = date.replace(tzinfo=tz.tzutc())
|
||||||
date = date.astimezone(tz.tzlocal())
|
local_date = parsed_date.astimezone(tz.tzlocal())
|
||||||
|
# Bad metadata defaults to date 1-1-1. Catch it and don't throw errors
|
||||||
return date.strftime('%Y-%m-%dT%H:%M:%S')
|
if local_date.year == 1:
|
||||||
|
return str(date)
|
||||||
|
else:
|
||||||
|
return local_date.strftime('%Y-%m-%dT%H:%M:%S')
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
LOG.exception(error)
|
LOG.exception('Item date: {} --- {}'.format(str(date), error))
|
||||||
|
|
||||||
return str(date)
|
return str(date)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue