Skip to content

Instantly share code, notes, and snippets.

@boozec
Created April 10, 2024 07:40
Show Gist options
  • Save boozec/9fe4d92d89b86527abda0cc996d0cea2 to your computer and use it in GitHub Desktop.
Save boozec/9fe4d92d89b86527abda0cc996d0cea2 to your computer and use it in GitHub Desktop.
Import movie list on Letterbox
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Firefox()
driver.get("https://letterboxd.com/sign-in/")
driver.find_element(By.CSS_SELECTOR, "input#signin-username").send_keys("username")
driver.find_element(By.CSS_SELECTOR, "input#signin-password").send_keys("password")
driver.find_element(By.CSS_SELECTOR, 'input[value="Sign in"]').click()
films = [
"Kung Fu Panda"
]
sleep(15)
driver.find_element(By.CSS_SELECTOR, ".fc-cta-consent p.fc-button-label").click()
sleep(2)
for film in films:
try:
driver.get("https://letterboxd.com/search/{}/".format(film))
sleep(1)
driver.find_element(By.CSS_SELECTOR, "h2.headline-2 a").click()
sleep(2)
w = driver.find_element(By.CSS_SELECTOR, "span.action.-watch")
if w.text == "Watched":
print(f"SKIP: {film} already watched")
else:
w.click()
print(f"ADD: {film}")
except:
print(f"ERROR: {film}")
with open("errors.txt", "a") as f:
f.write(film)
f.write("\n")
driver.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment