76 lines
2.4 KiB
Python
76 lines
2.4 KiB
Python
import glob
|
|||
|
|
import json
|
||
|
|
import os
|
||
|
|
import time
|
||
|
|
|
||
|
|
from selenium import webdriver
|
||
|
|
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
|
||
|
|
from selenium.webdriver.firefox.options import Options
|
||
|
|
|
||
|
|
|
||
|
|
def get_firefox_profile():
|
||
|
|
appdata = os.environ.get("APPDATA")
|
||
|
|
profile_roots = [
|
||
|
|
os.path.expanduser("~/Library/Application Support/Firefox/Profiles"),
|
||
|
|
os.path.expanduser("~/.mozilla/firefox"),
|
||
|
|
]
|
||
|
|
if appdata:
|
||
|
|
profile_roots.insert(0, os.path.join(appdata, "Mozilla", "Firefox", "Profiles"))
|
||
|
|
|
||
|
|
profiles = []
|
||
|
|
for profile_dir in profile_roots:
|
||
|
|
profiles.extend(glob.glob(os.path.join(profile_dir, "*.default-release")))
|
||
|
|
profiles.extend(glob.glob(os.path.join(profile_dir, "*.default")))
|
||
|
|
return profiles[0] if profiles else None
|
||
|
|
|
||
|
|
|
||
|
|
profile_path = get_firefox_profile()
|
||
|
|
if not profile_path:
|
||
|
|
raise SystemExit("Firefox profile not found.")
|
||
|
|
|
||
|
|
profile = FirefoxProfile(profile_path)
|
||
|
|
options = Options()
|
||
|
|
options.profile = profile
|
||
|
|
|
||
|
|
driver = webdriver.Firefox(options=options)
|
||
|
|
try:
|
||
|
|
driver.get("https://watch.lifetimemovieclub.com")
|
||
|
|
print("Log into Lifetime Movie Club in the Firefox window.")
|
||
|
|
print("(Also be logged into History Vault, Crime Central, play.history.com, play.mylifetime.com and discoveryplus.com in Firefox.)")
|
||
|
|
print("Once logged in, come back here and press Enter.")
|
||
|
|
input()
|
||
|
|
|
||
|
|
cookies = driver.get_cookies()
|
||
|
|
|
||
|
|
print("Grabbing History Vault cookies...")
|
||
|
|
driver.get("https://watch.historyvault.com")
|
||
|
|
time.sleep(4)
|
||
|
|
cookies.extend(driver.get_cookies())
|
||
|
|
|
||
|
|
print("Grabbing A&E Crime Central cookies...")
|
||
|
|
driver.get("https://watch.aecrimecentral.com")
|
||
|
|
time.sleep(4)
|
||
|
|
cookies.extend(driver.get_cookies())
|
||
|
|
|
||
|
|
print("Grabbing History (play.history.com) cookies...")
|
||
|
|
driver.get("https://play.history.com")
|
||
|
|
time.sleep(4)
|
||
|
|
cookies.extend(driver.get_cookies())
|
||
|
|
|
||
|
|
print("Grabbing Lifetime (play.mylifetime.com) cookies...")
|
||
|
|
driver.get("https://play.mylifetime.com")
|
||
|
|
time.sleep(4)
|
||
|
|
cookies.extend(driver.get_cookies())
|
||
|
|
|
||
|
|
print("Grabbing Discovery+ cookies...")
|
||
|
|
driver.get("https://www.discoveryplus.com")
|
||
|
|
time.sleep(4)
|
||
|
|
cookies.extend(driver.get_cookies())
|
||
|
|
|
||
|
|
cookie_file = os.path.expanduser("~/.aetn_cookies.json")
|
||
|
|
with open(cookie_file, "w") as f:
|
||
|
|
json.dump(cookies, f, indent=2)
|
||
|
|
print(f"Saved {len(cookies)} cookies to {cookie_file}")
|
||
|
|
finally:
|
||
|
|
driver.quit()
|