forked from sotolko/csgo-market-sniper
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathextension.py
43 lines (32 loc) · 1.67 KB
/
extension.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from pathlib import Path
from typing import Optional
import requests
def download_csgofloat_extension() -> Optional[str]:
"""
Downloads the CSGOFloat Market Checker extension if it doesn't already exist in the resources directory.
Returns:
str: The full path of the extension if the download was successful, otherwise None.
"""
# The URL to download the CSGOFloat Market Checker extension
extension_url = "https://clients2.google.com/service/update2/crx?response=redirect&prodversion=49.0&acceptformat=crx3&x=id%3Djjicbefpemnphinccgikpdaagjebbnhg%26installsource%3Dondemand%26uc"
# The path to save the extension locally
extension_path = Path("resources/CSGOFloat.crx")
# Create the resources directory if it doesn't exist
extension_path.parent.mkdir(parents=True, exist_ok=True)
# Check if the extension file already exists
if not extension_path.exists():
print("CSGOFloat Market Checker extension not found. Downloading...")
# Download the extension
response = requests.get(extension_url)
# Check if the download was successful
if response.status_code == 200:
# Save the downloaded content as a .crx file
with open(extension_path, "wb") as f:
f.write(response.content)
print("CSGOFloat Market Checker extension has been successfully downloaded.")
else:
# Print an error message and return None if the download failed
print("Error occurred while downloading the CSGOFloat Market Checker extension.")
return None
# Return the full path of the extension
return str(extension_path.resolve())