Skip to content

Commit

Permalink
Merge pull request #310 from KevinBytesTheDust/dev_chrome129
Browse files Browse the repository at this point in the history
chrome 129 blank window fixed, auto-adapted user-agent, youtube pause…
  • Loading branch information
KevinBytesTheDust authored Oct 5, 2024
2 parents 90a4562 + 652d147 commit a1dbbbf
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
dest: ${{env.output_filename}}.zip

- name: Upload zipped artifact ${{ matrix.os }}
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: ${{env.output_filename}}
path: ${{env.output_filename}}.zip
2 changes: 1 addition & 1 deletion .github/workflows/build_release_draft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
dest: ${{env.output_filename}}.zip

- name: Upload zipped artifact ${{ matrix.os }}
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: ${{env.output_filename}}
path: ${{env.output_filename}}.zip
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Get exclusive Feature Previews as a [:gem: Supporter & Feature Tester](https://b
- CPU load and bandwidth can get heavy. Channels with 160p work best.
- Tested on Windows 10 with headless ~100, headful ~30. Linux and macOS is experimental.

The Crude Viewer Amplifier (CVAmp) is a small GUI tool that spawns muted Google Chrome instances via [Playwright](https://github.com/microsoft/playwright-python), each with a different user-agent and HTTP proxy connection. Each instance navigates to the streaming channel and selects the lowest possible resolution.
The Crude Viewer Amplifier (CVAmp) is a small GUI tool that spawns muted Google Chrome instances via [Playwright](https://github.com/microsoft/playwright-python), each with a different HTTP proxy connection. Each instance navigates to the streaming channel and selects the lowest possible resolution.

Read the comprehensive [wiki](https://github.com/KevinBytesTheDust/cvamp/wiki) for a [detailed tutorial](https://github.com/KevinBytesTheDust/cvamp/wiki/Detailed-Tutorial), [usage tips](https://github.com/KevinBytesTheDust/cvamp/wiki/Advanced-features-and-controls) and [troubleshooting steps](https://github.com/KevinBytesTheDust/cvamp/wiki/Troubleshooting).

Expand Down
11 changes: 11 additions & 0 deletions cvamp/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ def __init__(self, parent, manager, *args, **kwargs):
self.manager = manager
self.headless = tk.BooleanVar(value=manager.get_headless())
self.auto_restart = tk.BooleanVar(value=manager.get_auto_restart())
self.block_video_checkbox_value = tk.BooleanVar(value=False)

global system_default_color
system_default_color = self.cget("bg")
Expand Down Expand Up @@ -251,6 +252,16 @@ def __init__(self, parent, manager, *args, **kwargs):
)
auto_restart_checkbox.place(x=255, y=94)

block_video_checkbox = ttk.Checkbutton(
self,
text="low cpu",
onvalue=True,
offvalue=False,
variable=self.block_video_checkbox_value,
state=tk.DISABLED,
)
block_video_checkbox.place(x=344, y=94)

# right
instances_text = tk.Label(self, text="Instances", borderwidth=2)
instances_text.place(x=455, y=10)
Expand Down
28 changes: 21 additions & 7 deletions cvamp/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,26 +124,40 @@ def save_screenshot(self):
self.page.screenshot(path=filename)

def spawn_page(self, restart=False):
proxy_dict = self.proxy_dict
CHROMIUM_ARGS = [
"--window-position={},{}".format(self.location_info["x"], self.location_info["y"]),
"--no-sandbox",
"--disable-setuid-sandbox",
"--no-first-run",
"--disable-blink-features=AutomationControlled",
"--mute-audio",
"--webrtc-ip-handling-policy=disable_non_proxied_udp",
"--force-webrtc-ip-handling-policy",
]

if self.headless:
CHROMIUM_ARGS.append("--headless=old")

self.status = utils.InstanceStatus.RESTARTING if restart else utils.InstanceStatus.STARTING
proxy_dict = self.proxy_dict

if not proxy_dict:
proxy_dict = None

self.status = utils.InstanceStatus.RESTARTING if restart else utils.InstanceStatus.STARTING

self.playwright = sync_playwright().start()

self.browser = self.playwright.chromium.launch(
proxy=proxy_dict,
headless=self.headless,
channel="chrome",
args=[
"--window-position={},{}".format(self.location_info["x"], self.location_info["y"]),
"--mute-audio",
],
headless=False,
args=CHROMIUM_ARGS,
)

major_version = self.browser.version.split(".")[0]
self.context = self.browser.new_context(
viewport={"width": 800, "height": 600},
user_agent=f"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{major_version}.0.0.0 Safari/537.36",
proxy=proxy_dict,
)

Expand Down
5 changes: 3 additions & 2 deletions cvamp/sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,11 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def todo_every_loop(self):
self.page.keyboard.press("l")
if self.page.query_selector('div.html5-video-player:not(.playing-mode)'):
self.page.keyboard.press("Space")

try:
self.page.click("button.ytp-skip-ad-button", timeout=100)
self.page.click("button.ytp-ad-skip-button-modern", timeout=100)
except:
pass

Expand Down
28 changes: 14 additions & 14 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion proxy/user-agents.txt

This file was deleted.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[tool.poetry]
name = "cvamp"
version = "0.7.1"
version = "0.7.2"
description = "Viewer Amplifier bot with playwright. Spawns low-resolution muted Chrome instances with proxy & user-agent. Requires HTTP proxies."
authors = ["KevinBytesTheDust <[email protected]>"]

[tool.poetry.dependencies]
python = "^3.11.0, <3.12"
playwright = "^1.22.0"
playwright = "1.43.0"
psutil = "^5.9.0"
toml = "^0.10.2"
sv-ttk = "^0.1"
Expand Down

0 comments on commit a1dbbbf

Please sign in to comment.