-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscreenshot_tool.py
More file actions
66 lines (52 loc) · 1.96 KB
/
screenshot_tool.py
File metadata and controls
66 lines (52 loc) · 1.96 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
"""
Bubble Maps Screenshot Tool
---------------------------
This tool helps generate screenshots of Bubble Maps visualizations directly.
It's useful for testing and debugging the screenshot functionality.
Usage:
python screenshot_tool.py <token_address> <chain>
Example:
python screenshot_tool.py 0x1f9840a85d5af5bf1d1762f925bdaddc4201f984 eth
"""
import asyncio
import sys
import os
from utils.screenshot import ScreenshotGenerator
from utils.bubblemaps import BubblemapsAPI
async def main():
if len(sys.argv) < 3:
print("Usage: python screenshot_tool.py <token_address> <chain>")
return
address = sys.argv[1]
chain = sys.argv[2].lower()
# Initialize the APIs
screenshot_gen = ScreenshotGenerator()
bubblemaps = BubblemapsAPI()
# Check if the map is available
print(f"Checking if map is available for {address} on {chain}...")
map_available = await bubblemaps.check_map_availability(address, chain)
print(f"Map available: {map_available}")
# Get the URL
bubble_map_url = bubblemaps.get_bubble_map_url(address, chain)
iframe_url = None
if map_available:
iframe_url = bubblemaps.get_iframe_url(address, chain)
print(f"Bubble map URL: {bubble_map_url}")
print(f"iframe URL: {iframe_url}")
# Capture the screenshot
print(f"Attempting to capture screenshot...")
screenshot = await screenshot_gen.capture_bubble_map(bubble_map_url, iframe_url)
if screenshot:
# Save to a file
output_dir = "screenshots"
os.makedirs(output_dir, exist_ok=True)
output_file = f"{output_dir}/{chain}_{address}.png"
with open(output_file, 'wb') as f:
f.write(screenshot)
print(f"Screenshot saved to {output_file}")
print(f"File size: {len(screenshot) / 1024:.2f} KB")
else:
print("Failed to capture screenshot")
if __name__ == "__main__":
asyncio.run(main())