-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTesting.py
More file actions
42 lines (33 loc) · 1.4 KB
/
Copy pathTesting.py
File metadata and controls
42 lines (33 loc) · 1.4 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
from playwright.sync_api import sync_playwright
import keyboard
import time
def setup_and_capture():
with sync_playwright() as p:
# Launch browser
browser = p.chromium.launch(headless=False)
page = browser.new_page()
# Navigate to the URL
page.goto("https://vdo.ninja/?view=AgWSsA9y")
# 1. Handle the "Big Play Button"
# We check if it exists and click it to start the stream
play_button = page.locator("#bigPlayButton")
if play_button.is_visible():
play_button.click()
print("Play button clicked.")
# 2. Target the specific video element by ID
# Using the partial ID selector since the UUID might change per session
video_locator = page.locator("video[id^='videosource_']")
print("Ready. Press 's' to capture, 'q' to quit.")
count = 0
while True:
if keyboard.is_pressed('s'):
count += 1
# Captures only the video element frame
video_locator.screenshot(path=f"lego_piece_{count}.png")
print(f"Captured: lego_piece_{count}.png")
time.sleep(0.2) # Debounce to prevent multiple shots per press
if keyboard.is_pressed('q'):
break
browser.close()
if __name__ == "__main__":
setup_and_capture()