Skip to content

Fix of all errors#76

Open
The-R34per wants to merge 2 commits intoHunxByts:mainfrom
The-R34per:main
Open

Fix of all errors#76
The-R34per wants to merge 2 commits intoHunxByts:mainfrom
The-R34per:main

Conversation

@The-R34per
Copy link
Copy Markdown

  1. The "Exit on Option 1" Bug
  • What was fixed: Wrapped the main() function logic in a while True: loop and updated execute_option.
  • Why: Previously, the script executed an option and then reached the end of the main() function, causing it to close. The loop ensures that after a task is finished, the program jumps back to the menu instead of exiting the terminal.
  1. SSL Handshake Failure (TikTok/Social Media Error)
  • What was fixed: Added a User-Agent header to the requests.get call and wrapped the request in a try/except block.
  • Why: High-security sites like TikTok block "headless" scripts that don't look like a real browser. Adding a User-Agent mimics a legitimate user (Chrome on Windows). The try/except prevents a single connection error from crashing the entire program.
  1. Request Timeouts
  • What was fixed: Added timeout=5 to the requests.get parameters.
  • Why: Without a timeout, if a website is down or extremely slow, your script would "hang" indefinitely. Now, if a site doesn't respond in 5 seconds, the script skips it and moves to the next one.
  1. Key Discovery: Safe Dictionary Access (.get)
  • What was fixed: Changed ip_data["timezone"]["current_time"] to ip_data["timezone"].get("current_time", "N/A").
  • Why: This prevents a "KeyError" crash. If the API doesn't return a "current_time" for a specific IP, the old code would crash the script. Using .get() tells Python: "Try to find the time; if it's not there, just use 'N/A' instead of breaking."

1. The "Exit on Option 1" Bug
What was fixed: Wrapped the main() function logic in a while True: loop and updated execute_option.

Why: Previously, the script executed an option and then reached the end of the main() function, causing it to close. The loop ensures that after a task is finished, the program jumps back to the menu instead of exiting the terminal.


2. SSL Handshake Failure (TikTok/Social Media Error)
What was fixed: Added a User-Agent header to the requests.get call and wrapped the request in a try/except block.

Why: High-security sites like TikTok block "headless" scripts that don't look like a real browser. Adding a User-Agent mimics a legitimate user (Chrome on Windows). The try/except prevents a single connection error from crashing the entire program.


3. Request Timeouts
What was fixed: Added timeout=5 to the requests.get parameters.

Why: Without a timeout, if a website is down or extremely slow, your script would "hang" indefinitely. Now, if a site doesn't respond in 5 seconds, the script skips it and moves to the next one.

4. Key Discovery: Safe Dictionary Access (.get)
What was fixed: Changed ip_data["timezone"]["current_time"] to ip_data["timezone"].get("current_time", "N/A").

Why: This prevents a "KeyError" crash. If the API doesn't return a "current_time" for a specific IP, the old code would crash the script. Using .get() tells Python: "Try to find the time; if it's not there, just use 'N/A' instead of breaking."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant