heymenn commited on
Commit
8f93b05
·
1 Parent(s): 1e83f3a

fix etsi connexion cookie expire

Browse files
Files changed (1) hide show
  1. classes.py +9 -2
classes.py CHANGED
@@ -47,6 +47,8 @@ class ETSIDocFinder:
47
  )
48
  if req.text == "Failed":
49
  return {"error": True, "session": session, "message": "Login failed ! Check your credentials"}
 
 
50
  return {"error": False, "session": session, "message": "Login successful"}
51
 
52
  def download_document(self, url: str) -> bytes:
@@ -58,7 +60,7 @@ class ETSIDocFinder:
58
  resp = self.session.get(url, verify=False, timeout=30, allow_redirects=True)
59
  # Detect auth redirect (portal login page returned instead of file)
60
  if resp.url and "LoginRedirection" in resp.url:
61
- self.connect()
62
  resp = self.session.get(url, verify=False, timeout=30, allow_redirects=True)
63
  return resp.content
64
 
@@ -71,7 +73,12 @@ class ETSIDocFinder:
71
  return main_tsg, workgroup, doc
72
 
73
  def find_workgroup_url(self, main_tsg, workgroup):
74
- response = self.session.get(f"{self.main_ftp_url}/{main_tsg}/05-CONTRIBUTIONS", verify=False)
 
 
 
 
 
75
  soup = BeautifulSoup(response.text, 'html.parser')
76
  for item in soup.find_all("tr"):
77
  link = item.find("a")
 
47
  )
48
  if req.text == "Failed":
49
  return {"error": True, "session": session, "message": "Login failed ! Check your credentials"}
50
+ # Always update self.session so reconnect and reauth actually take effect
51
+ self.session = session
52
  return {"error": False, "session": session, "message": "Login successful"}
53
 
54
  def download_document(self, url: str) -> bytes:
 
60
  resp = self.session.get(url, verify=False, timeout=30, allow_redirects=True)
61
  # Detect auth redirect (portal login page returned instead of file)
62
  if resp.url and "LoginRedirection" in resp.url:
63
+ self.connect() # connect() now updates self.session
64
  resp = self.session.get(url, verify=False, timeout=30, allow_redirects=True)
65
  return resp.content
66
 
 
73
  return main_tsg, workgroup, doc
74
 
75
  def find_workgroup_url(self, main_tsg, workgroup):
76
+ url = f"{self.main_ftp_url}/{main_tsg}/05-CONTRIBUTIONS"
77
+ response = self.session.get(url, verify=False, timeout=15)
78
+ # If docbox redirected to the portal login page, reauth and retry once
79
+ if "LoginRedirection" in response.url:
80
+ self.connect()
81
+ response = self.session.get(url, verify=False, timeout=15)
82
  soup = BeautifulSoup(response.text, 'html.parser')
83
  for item in soup.find_all("tr"):
84
  link = item.find("a")