forked from beeper/linkedin-messaging-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmark-conversation-as-read.py
More file actions
33 lines (24 loc) · 955 Bytes
/
Copy pathmark-conversation-as-read.py
File metadata and controls
33 lines (24 loc) · 955 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import asyncio
from pathlib import Path
from linkedin_messaging import ChallengeException, LinkedInMessaging
from linkedin_messaging.api_objects import URN
cookie_path = Path(__file__).parent.joinpath("cookies.pickle")
urn = URN("2-YWM2YTJmYjUtNTdjMS00ZjlmLTgwMDUtOWYxMmMxNjY4M2FlXzAxMg==")
async def main():
linkedin = LinkedInMessaging()
if cookie_path.exists():
with open(cookie_path, "rb") as cf:
linkedin = LinkedInMessaging.from_pickle(cf.read())
if not await linkedin.logged_in():
try:
await linkedin.login("EMAIL", "PASSWORD")
except ChallengeException:
await linkedin.enter_2fa(input("2fa code: "))
with open(cookie_path, "wb+") as cf:
cf.write(linkedin.to_pickle())
try:
print(await linkedin.mark_conversation_as_read(urn))
finally:
await linkedin.close()
loop = asyncio.get_event_loop()
loop.run_until_complete(main())