Niansuh commited on
Commit
0ea73f2
·
verified ·
1 Parent(s): 4d2cc4f

Update api/validate.py

Browse files
Files changed (1) hide show
  1. api/validate.py +8 -5
api/validate.py CHANGED
@@ -3,6 +3,9 @@ import re
3
  import time
4
 
5
  from api.config import BASE_URL, headers
 
 
 
6
 
7
  # Cache variables
8
  cached_hid = None
@@ -15,7 +18,7 @@ def getHid(force_refresh=False):
15
 
16
  # Check if cache is valid and not forced to refresh
17
  if not force_refresh and cached_hid and (current_time - cache_time) < CACHE_DURATION:
18
- print("using cached_hid:", cached_hid)
19
  return cached_hid
20
 
21
  try:
@@ -43,17 +46,17 @@ def getHid(force_refresh=False):
43
 
44
  if h_match:
45
  h_value = h_match.group(1)
46
- print("Found h-value:", h_value)
47
  # Update cache
48
  cached_hid = h_value
49
  cache_time = current_time
50
  return h_value
51
  else:
52
- print("h-value not found in JS content")
53
  return None
54
  else:
55
- print("JS file path not found in HTML content")
56
  return None
57
  except requests.exceptions.RequestException as e:
58
- print(f"Error occurred: {e}")
59
  return None
 
3
  import time
4
 
5
  from api.config import BASE_URL, headers
6
+ from api.logger import setup_logger
7
+
8
+ logger = setup_logger(__name__)
9
 
10
  # Cache variables
11
  cached_hid = None
 
18
 
19
  # Check if cache is valid and not forced to refresh
20
  if not force_refresh and cached_hid and (current_time - cache_time) < CACHE_DURATION:
21
+ logger.info(f"Using cached_hid: {cached_hid}")
22
  return cached_hid
23
 
24
  try:
 
46
 
47
  if h_match:
48
  h_value = h_match.group(1)
49
+ logger.info(f"Found new h-value: {h_value}")
50
  # Update cache
51
  cached_hid = h_value
52
  cache_time = current_time
53
  return h_value
54
  else:
55
+ logger.error("h-value not found in JS content")
56
  return None
57
  else:
58
+ logger.error("JS file path not found in HTML content")
59
  return None
60
  except requests.exceptions.RequestException as e:
61
+ logger.error(f"Error occurred while fetching hid: {e}")
62
  return None