Fix to only use NamedTuple fields from TautulliStream (#156)
Fix to only use NamedTuple fields from TautulliStream
This commit is contained in:
commit
1f15d07330
1 changed files with 4 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
|
from operator import itemgetter
|
||||||
from requests import Session, Request
|
from requests import Session, Request
|
||||||
from geoip2.errors import AddressNotFoundError
|
from geoip2.errors import AddressNotFoundError
|
||||||
from datetime import datetime, timezone, date, timedelta
|
from datetime import datetime, timezone, date, timedelta
|
||||||
|
@ -40,8 +41,10 @@ class TautulliAPI(object):
|
||||||
if session.get('_cache_time'):
|
if session.get('_cache_time'):
|
||||||
del session['_cache_time']
|
del session['_cache_time']
|
||||||
|
|
||||||
|
fields = itemgetter(*TautulliStream._fields)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sessions = [TautulliStream(**session) for session in get['sessions']]
|
sessions = [TautulliStream(*fields(session)) for session in get['sessions']]
|
||||||
except TypeError as e:
|
except TypeError as e:
|
||||||
self.logger.error('TypeError has occurred : %s while creating TautulliStream structure', e)
|
self.logger.error('TypeError has occurred : %s while creating TautulliStream structure', e)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue