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

Method detect_browser_paths

tools/browser_launcher.py:45–102  ·  view source on GitHub ↗

Detect available browser paths in system Returns list of browser paths sorted by priority

(self)

Source from the content-addressed store, hash-verified

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",
92 "/usr/bin/microsoft-edge-stable",
93 "/usr/bin/microsoft-edge-beta",
94 "/usr/bin/microsoft-edge-dev",
95 ]
96
97 # Check if path exists and is executable
98 for path in possible_paths:
99 if os.path.isfile(path) and os.access(path, os.X_OK):
100 paths.append(path)
101
102 return paths

Callers 1

_get_browser_pathMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected