Skip to content
This repository was archived by the owner on Dec 12, 2023. It is now read-only.

Commit ac9654d

Browse files
committed
LinkedInMessaging: remove from_pickle and add from_cookies
Pickling broke compatibility somewhere in the Python 3.11 series. It should not be used for storing the cookies. Signed-off-by: Sumner Evans <[email protected]>
1 parent c6475d3 commit ac9654d

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

linkedin_messaging/linkedin.py

+3-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import asyncio
22
import json
33
import logging
4-
import pickle
54
from collections import defaultdict
65
from datetime import datetime
76
from typing import Any, AsyncGenerator, Awaitable, Callable, Optional, TypeVar, Union, cast
@@ -111,19 +110,12 @@ def __init__(self):
111110
self.event_listeners = defaultdict(list)
112111

113112
@staticmethod
114-
def from_pickle(pickle_byte_str: bytes) -> "LinkedInMessaging":
113+
def from_cookies(li_at: str, jsessionid: str) -> "LinkedInMessaging":
115114
linkedin = LinkedInMessaging()
116-
assert isinstance(linkedin.session.cookie_jar, aiohttp.CookieJar)
117-
linkedin.session.cookie_jar._cookies = pickle.loads(pickle_byte_str)
118-
for c in linkedin.session.cookie_jar:
119-
if c.key == "JSESSIONID":
120-
linkedin.session.headers["csrf-token"] = c.value.strip('"')
115+
linkedin.session.cookie_jar.update_cookies({"li_at": li_at, "JSESSIONID": jsessionid})
116+
linkedin.session.headers["csrf-token"] = jsessionid
121117
return linkedin
122118

123-
def to_pickle(self) -> bytes:
124-
assert isinstance(self.session.cookie_jar, aiohttp.CookieJar)
125-
return pickle.dumps(self.session.cookie_jar._cookies, pickle.HIGHEST_PROTOCOL)
126-
127119
async def close(self):
128120
await self.session.close()
129121

0 commit comments

Comments
 (0)