MCPcopy Create free account
hub / github.com/NanmiCoder/MediaCrawler / BrowserLauncher

Class BrowserLauncher

tools/browser_launcher.py:34–291  ·  view source on GitHub ↗

Browser launcher for detecting and launching user's Chrome/Edge browser Supports Windows and macOS systems

Source from the content-addressed store, hash-verified

32
33
34class BrowserLauncher:
35 """
36 Browser launcher for detecting and launching user's Chrome/Edge browser
37 Supports Windows and macOS systems
38 """
39
40 def __init__(self):
41 self.system = platform.system()
42 self.browser_process = None
43 self.debug_port = None
44
45 def detect_browser_paths(self) -> List[str]:
46 """
47 Detect available browser paths in system
48 Returns list of browser paths sorted by priority
49 """
50 paths = []
51
52 if self.system == "Windows":
53 # Common Chrome/Edge installation paths on Windows
54 possible_paths = [
55 # Chrome paths
56 os.path.expandvars(r"%PROGRAMFILES%\Google\Chrome\Application\chrome.exe"),
57 os.path.expandvars(r"%PROGRAMFILES(X86)%\Google\Chrome\Application\chrome.exe"),
58 os.path.expandvars(r"%LOCALAPPDATA%\Google\Chrome\Application\chrome.exe"),
59 # Edge paths
60 os.path.expandvars(r"%PROGRAMFILES%\Microsoft\Edge\Application\msedge.exe"),
61 os.path.expandvars(r"%PROGRAMFILES(X86)%\Microsoft\Edge\Application\msedge.exe"),
62 # Chrome Beta/Dev/Canary
63 os.path.expandvars(r"%LOCALAPPDATA%\Google\Chrome Beta\Application\chrome.exe"),
64 os.path.expandvars(r"%LOCALAPPDATA%\Google\Chrome Dev\Application\chrome.exe"),
65 os.path.expandvars(r"%LOCALAPPDATA%\Google\Chrome SxS\Application\chrome.exe"),
66 ]
67 elif self.system == "Darwin": # macOS
68 # Common Chrome/Edge installation paths on macOS
69 possible_paths = [
70 # Chrome paths
71 "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
72 "/Applications/Google Chrome Beta.app/Contents/MacOS/Google Chrome Beta",
73 "/Applications/Google Chrome Dev.app/Contents/MacOS/Google Chrome Dev",
74 "/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary",
75 # Edge paths
76 "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge",
77 "/Applications/Microsoft Edge Beta.app/Contents/MacOS/Microsoft Edge Beta",
78 "/Applications/Microsoft Edge Dev.app/Contents/MacOS/Microsoft Edge Dev",
79 "/Applications/Microsoft Edge Canary.app/Contents/MacOS/Microsoft Edge Canary",
80 ]
81 else:
82 # Linux and other systems
83 possible_paths = [
84 "/usr/bin/google-chrome",
85 "/usr/bin/google-chrome-stable",
86 "/usr/bin/google-chrome-beta",
87 "/usr/bin/google-chrome-unstable",
88 "/usr/bin/chromium-browser",
89 "/usr/bin/chromium",
90 "/snap/bin/chromium",
91 "/usr/bin/microsoft-edge",

Callers 1

__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected