Repository: thewh1teagle/rookie (language: rust)

Issue:
[Feature Request]: Windows cannot import Safari
### Describe the feature

I know Windows cannot read Safari browser cookies, but my project is cross platform. I want to display all browsers and let users choose the browser. If the corresponding browser does not support the platform, I hope to throw an exception, and then I can capture the exception and prompt the user, instead of being unable to import directly. Currently, the module throws an ImportError directly, which is not suitable for direct capture. Otherwise, it is impossible to determine whether it is a platform issue or if the module is not installed. It is recommended to throw a custom exception.


Discussion / hints:
Hey
I think that it's a Python convention and you should conditionally import different browsers functions per platform.

Just a suggestion, if the user attempts to import an object that is not supported by the platform, the module should directly throw a more appropriate error type EnvironmentError or OSError. Otherwise, the user needs to consult the module's source code to know the reason.
I have a similar need and what I settled on is doing something like this:
```python
try:
    browsers.append(rookiepy.safari)
except AttributeError:
    pass # Presumably on a platform that does not have Safari
```
> I have a similar need and what I settled on is doing something like this:
> 
> ```python
> try:
>     browsers.append(rookiepy.safari)
> except AttributeError:
>     pass # Presumably on a platform that does not have Safari
> ```

If the module does not consider throwing more friendly errors, the best solution is to judge the system type like the module, and then import the browser objects supported by the current system.
<img width=300 src="https://github.com/user-attachments/assets/08dcd979-58f1-49a6-b627-7dac01fda9ac">

The error looks to me completely normal. macOS doesn't have internet_explorer so it throws `ImportError`

Fix patch:
diff --git a/.gitignore b/.gitignore
index 0665ab4..2d27984 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
 target/
+venv/
 Cargo.lock
 __pycache__
 *.pyc
@@ -7,4 +8,4 @@ node_modules/
 *.exe
 *.bin
 *.dll
-impersonate.h
\ No newline at end of file
+impersonate.h
diff --git a/examples/python/multi_import.py b/examples/python/multi_import.py
new file mode 100644
index 0000000..ffc05fc
--- /dev/null
+++ b/examples/python/multi_import.py
@@ -0,0 +1,27 @@
+import platform
+from rookiepy import arc, brave, chromium, chrome, edge, firefox, librewolf, vivaldi
+
+# On all platforms
+browsers_fn = [arc, brave, chromium, chrome, edge, firefox, librewolf, vivaldi]
+
+# Linux
+if platform.system() == "Linux":
+    from rookiepy import cachy, opera
+
+    browsers_fn.append(cachy)
+
+# Windows
+elif platform.system() == "Windows":
+    from rookiepy import internet_explorer, opera, opera_gx
+
+    browsers_fn.extend([internet_explorer, opera, opera_gx])
+
+# macOS
+elif platform.system() == "Darwin":
+    from rookiepy import safari
+
+    browsers_fn.extend([safari])
+
+for fn in browsers_fn:
+    cookies = fn()
+    print(f"Found {len(cookies)} cookies!")


Test patch: