-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
85 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
.idea | ||
.vscode | ||
screenshots/*.png | ||
cookies/*.pkl | ||
*.pkl | ||
out/** | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
DEBUG=true | ||
IG_USERNAME="your_username_here" | ||
IG_PASSWORD="your_password_here" | ||
TV_TIME_USERID="your_userid_here" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import os | ||
from contextlib import contextmanager | ||
from pathlib import Path | ||
from typing import Any | ||
|
||
from dotenv import load_dotenv | ||
from playwright.sync_api import ( | ||
Browser, | ||
BrowserType, | ||
Page, | ||
Playwright, | ||
sync_playwright, | ||
) | ||
|
||
load_dotenv() | ||
|
||
PROJECT_ROOT = Path(__file__).resolve().parents[1] | ||
DEBUG: bool = os.environ.get("DEBUG", "false").lower() == "true" | ||
OPTS: dict[str, Any] = { | ||
"out_dir": PROJECT_ROOT / "out", | ||
"headless": True, | ||
"slow_mo": 0, | ||
} | ||
|
||
if DEBUG: | ||
# Set DEBUG = True to see the browser in action | ||
os.environ["PWDEBUG"] = "console" | ||
# os.environ["PWDEBUG"] = "1" | ||
OPTS["headless"] = False | ||
OPTS["slow_mo"] = 200 | ||
|
||
|
||
def get_input(fields: list[str]) -> list[str]: | ||
res = [] | ||
for field in fields: | ||
OPTS[field] = (OPTS[field] or input(f"Enter {field.upper()}: ")).strip() | ||
res.append(OPTS[field]) | ||
return res | ||
|
||
|
||
@contextmanager | ||
def run_playwright(browser_type: str, base_url: str | None = None) -> Page: | ||
""" | ||
browser: 'chromium', 'webkit' or 'firefox' | ||
""" | ||
play: Playwright = sync_playwright().start() | ||
browser: BrowserType = getattr(play, browser_type) | ||
window: Browser = browser.launch( | ||
headless=OPTS["headless"], slow_mo=OPTS["slow_mo"] | ||
) | ||
page: Page = window.new_page(base_url=base_url) | ||
|
||
try: | ||
yield page | ||
finally: | ||
window.close() | ||
play.stop() |
Empty file.