mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
Integrates WebTorrent client-side seeding into the Cloudflare R2 upload path. - Adds `uploadFile` to `r2Service` for generic file uploads. - Updates `UploadModal` to offer an optional "Create torrent & seed" flow. - Generates magnet links and .torrent files in the browser after R2 upload. - Uploads the .torrent file to R2 and populates `xs` tag. - Populates `ws` (Web Seed) with the R2 public URL. - Adds UI progress indicators for hashing and torrent upload. - Enforces a 2GB file size limit for browser seeding to prevent crashes. - Adds a mandatory legal rights confirmation checkbox for R2 uploads.
55 lines
2.1 KiB
Python
55 lines
2.1 KiB
Python
|
|
from playwright.sync_api import sync_playwright
|
|
import os
|
|
|
|
def run():
|
|
# Construct absolute path to the local file
|
|
file_path = os.path.abspath('index.html')
|
|
url = f'file://{file_path}'
|
|
|
|
with sync_playwright() as p:
|
|
browser = p.chromium.launch(headless=True)
|
|
context = browser.new_context()
|
|
page = context.new_page()
|
|
|
|
# Navigate to the local index.html
|
|
print(f'Navigating to {url}')
|
|
page.goto(url)
|
|
|
|
# Wait for the upload modal to be part of the DOM (it's in the static HTML but hidden)
|
|
# We need to trigger it to open.
|
|
# The upload button has id='uploadButton'.
|
|
# However, checking ApplicationBootstrap logic, it might need JS initialization.
|
|
# Since we are running against static file://, module scripts might fail CORS or path resolution
|
|
# unless served via http.
|
|
# Let's try to serve it first.
|
|
|
|
# Actually, simpler: just check if the new elements exist in the DOM,
|
|
# even if the modal isn't visible, we can force it visible via JS for the screenshot.
|
|
|
|
# Wait for the modal container
|
|
page.wait_for_selector('#uploadModal', state='attached')
|
|
|
|
# Force modal visible for screenshot
|
|
page.evaluate("document.getElementById('uploadModal').classList.remove('hidden')")
|
|
|
|
# Switch to Cloudflare tab to see new UI
|
|
# The tab buttons have data-upload-mode='cloudflare'
|
|
# We can click it or just unhide the section manually if JS isn't running fully.
|
|
# Let's assume JS might fail on file://, so we do manual DOM manipulation to reveal the section.
|
|
|
|
# Hide custom section
|
|
page.evaluate("document.getElementById('customUploadSection').classList.add('hidden')")
|
|
|
|
# Show Cloudflare section
|
|
page.evaluate("document.getElementById('cloudflareUploadSection').classList.remove('hidden')")
|
|
|
|
# Take screenshot of the Cloudflare section
|
|
element = page.locator('#cloudflareUploadSection')
|
|
element.screenshot(path='verification/upload_modal_cloudflare.png')
|
|
|
|
browser.close()
|
|
|
|
if __name__ == '__main__':
|
|
run()
|