summaryrefslogtreecommitdiffstats
path: root/g4f/utils.py
diff options
context:
space:
mode:
authorTekky <98614666+xtekky@users.noreply.github.com>2023-08-17 14:50:35 +0200
committerGitHub <noreply@github.com>2023-08-17 14:50:35 +0200
commite8066c1df55c429a72e0770ee0e30a0ffc03f019 (patch)
treec8bc44917ea03909cf586140f984ff0814bc30ea /g4f/utils.py
parent~ | small fixes & new pypi version | v-0.0.1.9 (diff)
parentrefactor: refactor provider (diff)
downloadgpt4free-e8066c1df55c429a72e0770ee0e30a0ffc03f019.tar
gpt4free-e8066c1df55c429a72e0770ee0e30a0ffc03f019.tar.gz
gpt4free-e8066c1df55c429a72e0770ee0e30a0ffc03f019.tar.bz2
gpt4free-e8066c1df55c429a72e0770ee0e30a0ffc03f019.tar.lz
gpt4free-e8066c1df55c429a72e0770ee0e30a0ffc03f019.tar.xz
gpt4free-e8066c1df55c429a72e0770ee0e30a0ffc03f019.tar.zst
gpt4free-e8066c1df55c429a72e0770ee0e30a0ffc03f019.zip
Diffstat (limited to 'g4f/utils.py')
-rw-r--r--g4f/utils.py49
1 files changed, 0 insertions, 49 deletions
diff --git a/g4f/utils.py b/g4f/utils.py
deleted file mode 100644
index d5ab41c7..00000000
--- a/g4f/utils.py
+++ /dev/null
@@ -1,49 +0,0 @@
-import browser_cookie3
-
-
-class Utils:
- browsers = [
- browser_cookie3.chrome, # 62.74% market share
- browser_cookie3.safari, # 24.12% market share
- browser_cookie3.firefox, # 4.56% market share
- browser_cookie3.edge, # 2.85% market share
- browser_cookie3.opera, # 1.69% market share
- browser_cookie3.brave, # 0.96% market share
- browser_cookie3.opera_gx, # 0.64% market share
- browser_cookie3.vivaldi, # 0.32% market share
- ]
-
- def get_cookies(domain: str, setName: str = None, setBrowser: str = False) -> dict:
- cookies = {}
-
- if setBrowser != False:
- for browser in Utils.browsers:
- if browser.__name__ == setBrowser:
- try:
- for c in browser(domain_name=domain):
- if c.name not in cookies:
- cookies = cookies | {c.name: c.value}
-
- except Exception as e:
- pass
-
- else:
- for browser in Utils.browsers:
- try:
- for c in browser(domain_name=domain):
- if c.name not in cookies:
- cookies = cookies | {c.name: c.value}
-
- except Exception as e:
- pass
-
- if setName:
- try:
- return {setName: cookies[setName]}
-
- except ValueError:
- print(f'Error: could not find {setName} cookie in any browser.')
- exit(1)
-
- else:
- return cookies