vbnotebook
This commit is contained in:
3
.idea/.gitignore
generated
vendored
Normal file
3
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
10
.idea/Torrents.iml
generated
Normal file
10
.idea/Torrents.iml
generated
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="jdk" jdkName="Python 3.12 (Torrents)" jdkType="Python SDK" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/Torrents.iml" filepath="$PROJECT_DIR$/.idea/Torrents.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
56
10 LoginOnce.py
Normal file
56
10 LoginOnce.py
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
from playwright.sync_api import sync_playwright
|
||||||
|
|
||||||
|
COOKIE_FILE = Path("sktorrent_cookies.json")
|
||||||
|
LOGIN_URL = "https://sktorrent.eu/torrent/torrents_v2.php?active=0"
|
||||||
|
|
||||||
|
|
||||||
|
def save_login_cookies(context):
|
||||||
|
"""Save only uid + pass cookies."""
|
||||||
|
cookies = context.cookies()
|
||||||
|
login_cookies = [
|
||||||
|
c for c in cookies
|
||||||
|
if c["domain"] == "sktorrent.eu" and c["name"] in ("uid", "pass")
|
||||||
|
]
|
||||||
|
|
||||||
|
with open(COOKIE_FILE, "w") as f:
|
||||||
|
json.dump(login_cookies, f, indent=2)
|
||||||
|
|
||||||
|
print("✅ Login cookies saved to", COOKIE_FILE)
|
||||||
|
|
||||||
|
|
||||||
|
def load_cookies(context):
|
||||||
|
"""Load saved cookies if available."""
|
||||||
|
if COOKIE_FILE.exists():
|
||||||
|
with open(COOKIE_FILE, "r") as f:
|
||||||
|
cookies = json.load(f)
|
||||||
|
context.add_cookies(cookies)
|
||||||
|
print("🔄 Loaded saved cookies.")
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
with sync_playwright() as p:
|
||||||
|
browser = p.chromium.launch(headless=False)
|
||||||
|
context = browser.new_context()
|
||||||
|
cookies_loaded = load_cookies(context)
|
||||||
|
|
||||||
|
page = context.new_page()
|
||||||
|
page.goto(LOGIN_URL)
|
||||||
|
|
||||||
|
# Check if we are already logged in
|
||||||
|
if page.locator('input[name="uid"]').count() == 0:
|
||||||
|
print("✅ Already logged in using cookies!")
|
||||||
|
else:
|
||||||
|
print("\n➡️ Please log in manually in the opened browser.")
|
||||||
|
print("➡️ Once logged in and you see your account page, press ENTER here.\n")
|
||||||
|
input("Press ENTER when finished... ")
|
||||||
|
|
||||||
|
save_login_cookies(context)
|
||||||
|
|
||||||
|
print("🎉 Done!")
|
||||||
|
page.wait_for_timeout(3000)
|
||||||
36
20 Loginwithsavedcookies.py
Normal file
36
20 Loginwithsavedcookies.py
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
from playwright.sync_api import sync_playwright
|
||||||
|
|
||||||
|
COOKIE_FILE = Path("sktorrent_cookies.json")
|
||||||
|
LOGIN_URL = "https://sktorrent.eu/torrent/torrents_v2.php?active=0"
|
||||||
|
|
||||||
|
with sync_playwright() as p:
|
||||||
|
browser = p.chromium.launch(headless=False)
|
||||||
|
context = browser.new_context()
|
||||||
|
|
||||||
|
# Load saved cookies
|
||||||
|
if COOKIE_FILE.exists():
|
||||||
|
with open(COOKIE_FILE, "r") as f:
|
||||||
|
cookies = json.load(f)
|
||||||
|
context.add_cookies(cookies)
|
||||||
|
print("🔄 Loaded cookies.")
|
||||||
|
else:
|
||||||
|
print("❌ Cookie file not found. Run the manual login script first.")
|
||||||
|
exit()
|
||||||
|
|
||||||
|
page = context.new_page()
|
||||||
|
page.goto(LOGIN_URL)
|
||||||
|
|
||||||
|
page.wait_for_load_state("networkidle")
|
||||||
|
|
||||||
|
# Check if login form is visible
|
||||||
|
if page.locator('input[name="uid"]').count() == 0:
|
||||||
|
print("✅ Already logged in using cookies!")
|
||||||
|
else:
|
||||||
|
print("❌ Cookies invalid or expired. Please re-login manually to refresh cookies.")
|
||||||
|
|
||||||
|
page.wait_for_timeout(3000)
|
||||||
171
30 OpenTextListing.py
Normal file
171
30 OpenTextListing.py
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
from playwright.sync_api import sync_playwright
|
||||||
|
|
||||||
|
# =============================================================
|
||||||
|
# CONFIGURATION
|
||||||
|
# =============================================================
|
||||||
|
|
||||||
|
COOKIE_FILE = Path("sktorrent_cookies.json")
|
||||||
|
URL = "https://sktorrent.eu/torrent/torrents.php?active=0"
|
||||||
|
|
||||||
|
|
||||||
|
def load_cookies(context):
|
||||||
|
"""Load saved cookies if available."""
|
||||||
|
if COOKIE_FILE.exists():
|
||||||
|
with open(COOKIE_FILE, "r") as f:
|
||||||
|
cookies = json.load(f)
|
||||||
|
context.add_cookies(cookies)
|
||||||
|
print("🔄 Loaded login cookies.")
|
||||||
|
return True
|
||||||
|
print("❌ Cookie file not found. Run manual login first.")
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
# =============================================================
|
||||||
|
# MAIN CODE
|
||||||
|
# =============================================================
|
||||||
|
|
||||||
|
with sync_playwright() as p:
|
||||||
|
|
||||||
|
# 1️⃣ Launch browser
|
||||||
|
browser = p.chromium.launch(
|
||||||
|
headless=False,
|
||||||
|
args=[
|
||||||
|
"--disable-popup-blocking",
|
||||||
|
"--disable-background-networking",
|
||||||
|
"--disable-notifications",
|
||||||
|
"--no-default-browser-check",
|
||||||
|
"--no-first-run",
|
||||||
|
"--noerrdialogs",
|
||||||
|
"--disable-dev-shm-usage",
|
||||||
|
"--disable-features=IsolateOrigins,site-per-process",
|
||||||
|
"--no-sandbox",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
# 2️⃣ Create context before any pages exist
|
||||||
|
context = browser.new_context()
|
||||||
|
|
||||||
|
# 3️⃣ Block ALL third-party requests (ads, JS, popups, tracking)
|
||||||
|
def block_third_party(route, request):
|
||||||
|
url = request.url.lower()
|
||||||
|
if "sktorrent.eu" in url:
|
||||||
|
route.continue_()
|
||||||
|
else:
|
||||||
|
print(f"🚫 Blocked third-party request: {url}")
|
||||||
|
route.abort()
|
||||||
|
|
||||||
|
context.route("**/*", block_third_party)
|
||||||
|
|
||||||
|
# 4️⃣ Block ANY popup windows except the first page
|
||||||
|
pages = []
|
||||||
|
|
||||||
|
def on_new_page(new_page):
|
||||||
|
pages.append(new_page)
|
||||||
|
if len(pages) == 1:
|
||||||
|
print("➡️ Main page created.")
|
||||||
|
else:
|
||||||
|
print("⚠️ Popup blocked (auto-closed).")
|
||||||
|
new_page.close()
|
||||||
|
|
||||||
|
context.on("page", on_new_page)
|
||||||
|
|
||||||
|
# 5️⃣ Disable all popup JS functions (window.open, window.close, opener.close)
|
||||||
|
context.add_init_script("""
|
||||||
|
window.open = () => { console.log("Blocked window.open"); return null; };
|
||||||
|
window.close = () => { console.log("Blocked window.close"); };
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (window.opener) {
|
||||||
|
window.opener.close = () => { console.log("Blocked opener.close"); };
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
// Block <a target="_blank">
|
||||||
|
document.addEventListener('click', function(e) {
|
||||||
|
const el = e.target.closest('a[target="_blank"]');
|
||||||
|
if (el) {
|
||||||
|
e.preventDefault();
|
||||||
|
console.log("Blocked target=_blank");
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
// Block middle-click opening a new tab
|
||||||
|
document.addEventListener('auxclick', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
}, true);
|
||||||
|
""")
|
||||||
|
|
||||||
|
# 6️⃣ Create the FIRST page (main page)
|
||||||
|
page = context.new_page()
|
||||||
|
pages.append(page)
|
||||||
|
|
||||||
|
# 7️⃣ Load cookies (login)
|
||||||
|
load_cookies(context)
|
||||||
|
|
||||||
|
# 8️⃣ Navigate
|
||||||
|
print("🌍 Opening page...")
|
||||||
|
page.goto(URL)
|
||||||
|
|
||||||
|
# Do NOT use networkidle on ad-heavy sites
|
||||||
|
page.wait_for_load_state("domcontentloaded")
|
||||||
|
page.wait_for_selector("table tr", timeout=15000)
|
||||||
|
# Remove popup/overlay elements created by SKTorrent
|
||||||
|
page.evaluate("""
|
||||||
|
const selectors = [
|
||||||
|
'#lightbox', '.lightbox', '#popup', '.popup',
|
||||||
|
'.overlay', '#overlay', '.modal', '#modal',
|
||||||
|
'div[style*="fixed"]', 'div[style*="position: fixed"]',
|
||||||
|
'table[style*="position: fixed"]',
|
||||||
|
'iframe', 'frame'
|
||||||
|
];
|
||||||
|
|
||||||
|
selectors.forEach(sel => {
|
||||||
|
document.querySelectorAll(sel).forEach(el => {
|
||||||
|
console.log("Removing popup element:", sel);
|
||||||
|
el.remove();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Remove onclick handlers that trigger popups
|
||||||
|
document.querySelectorAll('*').forEach(el => {
|
||||||
|
el.onclick = null;
|
||||||
|
el.onauxclick = null;
|
||||||
|
el.oncontextmenu = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Remove timers that trigger delayed popups
|
||||||
|
window.setTimeout = () => {};
|
||||||
|
window.setInterval = () => {};
|
||||||
|
""")
|
||||||
|
|
||||||
|
print("✔ Page loaded, extracting table rows...")
|
||||||
|
|
||||||
|
# 9️⃣ Extract all rows
|
||||||
|
rows = page.locator("table tr").all()
|
||||||
|
print(f"📄 Total rows found (including header): {len(rows)}")
|
||||||
|
|
||||||
|
# 🔟 Extract SECOND ROW only (your request)
|
||||||
|
if len(rows) > 1:
|
||||||
|
row = rows[1] # 0 = header, 1 = first data row
|
||||||
|
tds = row.locator("td")
|
||||||
|
|
||||||
|
name = tds.nth(1).inner_text().strip()
|
||||||
|
size = tds.nth(2).inner_text().strip()
|
||||||
|
seeders = tds.nth(3).inner_text().strip()
|
||||||
|
leechers = tds.nth(4).inner_text().strip()
|
||||||
|
|
||||||
|
print("\n========= SECOND ROW =========")
|
||||||
|
print(f"Name: {name}")
|
||||||
|
print(f"Size: {size}")
|
||||||
|
print(f"Seeders: {seeders}")
|
||||||
|
print(f"Leechers: {leechers}")
|
||||||
|
print("==============================\n")
|
||||||
|
else:
|
||||||
|
print("❌ No data rows found!")
|
||||||
|
|
||||||
|
page.wait_for_timeout(5000)
|
||||||
Reference in New Issue
Block a user