-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_availability.py
More file actions
57 lines (43 loc) · 2.12 KB
/
Copy pathcheck_availability.py
File metadata and controls
57 lines (43 loc) · 2.12 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
import asyncio
import gspread
from oauth2client.service_account import ServiceAccountCredentials
from playwright.async_api import async_playwright
# Google Sheets setup
SCOPE = ["https://spreadsheets.google.com/feeds", "https://www.googleapis.com/auth/drive"]
CREDS = ServiceAccountCredentials.from_json_keyfile_name("your_credentials.json", SCOPE)
gc = gspread.authorize(CREDS)
SHEET_NAME = "Google Sheet Streaming Checker"
WORKSHEET_NAME = "Tubi"
sheet = gc.open(SHEET_NAME).worksheet(WORKSHEET_NAME)
# Load data
data = sheet.get_all_records()
START_ROW = 2 # Adjust if you have headers
async def check_movie_availability(playwright):
browser = await playwright.chromium.launch(headless=False) # Show browser for visual verification
context = await browser.new_context()
page = await context.new_page()
for i, row in enumerate(data, start=START_ROW):
link = row['Tubi Link'] if 'Tubi Link' in row else row['Link']
country = row['Country'] if 'Country' in row else row.get('D', 'Unknown')
if not link or "tubitv.com" not in link:
sheet.update_cell(i + 1, 5, "Invalid or Missing Link")
continue
try:
await page.goto(f"http://scraperapi.com?api_key=5da6a435c89f56b1ef3f4541d2c6d9bc&url={link}", timeout=60000)
await page.wait_for_timeout(5000) # Let page load
# UI-based checks
has_video_player = await page.locator("video").is_visible()
has_controls = await page.locator("video[controls]").count() > 0
is_playable = await page.locator("button:has-text('Play'), button:has-text('Watch Now')").count() > 0
if has_video_player or has_controls or is_playable:
result = "✅ Available"
else:
result = "❌ Not Playable"
sheet.update_cell(i + 1, 5, result) # Column E for result
except Exception as e:
sheet.update_cell(i + 1, 5, f"Error: {str(e)[:30]}")
await browser.close()
async def main():
async with async_playwright() as playwright:
await check_movie_availability(playwright)
asyncio.run(main())