from RatS.base.base_site import Site
from RatS.utils import command_line


class Listal(Site):
    def __init__(self, args):
        login_form_selector = (
            "//*[contains(concat(' ', normalize-space(@class), ' '), ' login-popup ')]"
            "//form[contains(concat(' ', normalize-space(@class), ' '), ' login-form ')]"
        )
        self.LOGIN_USERNAME_SELECTOR = login_form_selector + "//input[@name='username']"
        self.LOGIN_PASSWORD_SELECTOR = login_form_selector + "//input[@name='password']"
        self.LOGIN_BUTTON_SELECTOR = (
            login_form_selector
            + "//button[contains(concat(' ', normalize-space(@class), ' '), ' submit ')]"
        )
        super(Listal, self).__init__(args)
        self.MY_RATINGS_URL = (
            f"https://{self.USERNAME}.listal.com/movies/all/1/?rating=1"
        )

    def _get_login_page_url(self):
        return "https://www.listal.com/login"

    def handle_request_blocked_by_website(self):
        if "stackpath" in self.browser.page_source:
            command_line.error("The request was blocked by the website.")
            self.browser_handler.kill()

@@ -30,16 +30,40 @@
 rt Site%0A
+import sys%0Aimport time%0A%0A
 from Rat
@@ -870,16 +870,294 @@
      )%0A%0A
+    def login(self):%0A        sys.stdout.write(f%22===== %7Bself.site_displayname%7D: performing login%22)%0A        sys.stdout.flush()%0A        self.open_url_with_521_retry(self.LOGIN_PAGE)%0A        time.sleep(1)%0A        self._insert_login_credentials()%0A        self._click_login_button()%0A%0A
     def 
@@ -1227,16 +1227,23 @@
 om/login
+-iframe
 %22%0A%0A    d

Handle Listal login form