Skip to content

Commit

Permalink
Revert some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
CastagnaIT committed Sep 20, 2023
1 parent 2d3f262 commit 1f45752
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion resources/lib/services/nfsession/session/cookie.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _verify_session_cookies(self):
if not self.session.cookies:
return False
for cookie_name in LOGIN_COOKIES:
if cookie_name not in list(self.session.cookies.keys()):
if not any(cookie.name == cookie_name for cookie in list(self.session.cookies)):
LOG.error('The cookie "{}" do not exist, it is not possible to check the expiration',
cookie_name)
return False
Expand Down
12 changes: 3 additions & 9 deletions resources/lib/utils/cookies.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ def save(cookie_jar, log_output=True):
log_cookie(cookie_jar)
cookie_file = xbmcvfs.File(cookie_file_path(), 'wb')
try:
# Requests RequestsCookieJar it's a dict, for compatibility we convert it to the generic http.cookiejar
# For compatibility, we convert CookieJar object to our PickleableCookieJar
# to keep possibility to change in future Requests module with another one
jar = cookiejar_from_dict(cookie_jar)
cookie_file.write(bytearray(pickle.dumps(PickleableCookieJar.cast(jar))))
cookie_file.write(bytearray(pickle.dumps(PickleableCookieJar.cast(cookie_jar))))
except Exception as exc: # pylint: disable=broad-except
LOG.error('Failed to save cookies to file: {exc}', exc=exc)
finally:
Expand Down Expand Up @@ -84,12 +83,7 @@ def load():
# cookie_jar.clear(cookie.domain, cookie.path, cookie.name)
LOG.debug('Cookies loaded from file')
log_cookie(cookie_jar)
# Convert the generic http.cookiejar in to RequestsCookieJar of Request module
from requests.cookies import RequestsCookieJar
req_cookie_jar = RequestsCookieJar()
req_cookie_jar.update(cookie_jar)

return req_cookie_jar
return cookie_jar
except Exception as exc: # pylint: disable=broad-except
import traceback
LOG.error('Failed to load cookies from file: {exc}', exc=exc)
Expand Down

0 comments on commit 1f45752

Please sign in to comment.