what's wrong with that code:
def get_books_sel(pages_count=1):
    # Удаляем старую папку с обложками и создаем новую
    if os.path.exists(BOOKS_COVERS_PATH):
        shutil.rmtree(BOOKS_COVERS_PATH)
    os.mkdir(BOOKS_COVERS_PATH)

    # Загружаем авторов из CSV файла
    authors_df = pd.read_csv("authors.csv", delimiter=";")
    authors = authors_df.to_dict('records')
    books_counter = 0

    # Настройка Selenium
    options = Options()
    options.add_argument('--headless')  # Запуск в фоновом режиме
    options.add_argument('--no-sandbox')
    options.add_argument('--disable-dev-shm-usage')
    driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)

    for author in authors:
        books = []
        genres = []
        books_genres = []

        # Формируем URL для книг
        books_url = urljoin(LIVELIB_BASE_URL, f"/author/{author['Link'].split('/')[-1].split('-')[0]}/top/work/listview/biglist/~")

        for i in range(1, pages_count + 1):
            driver.get(books_url + str(i))
            time.sleep(2)  # Даем время для загрузки страницы

            names = driver.find_elements(By.CSS_SELECTOR, "ul#author-objects li")

            for index, name in enumerate(names):
                title = name.find_element(By.CSS_SELECTOR, "a.book-item__title").text
                print(title)

                # Получаем детальную информацию о книге
                book_detail_url = urljoin(LIVELIB_BASE_URL, name.find_element(By.CSS_SELECTOR, "a.book-item__title").get_attribute("href"))
                driver.get(book_detail_url)
                print(book_detail_url)
                time.sleep(2)

                annotation = driver.find_element(By.CSS_SELECTOR, "summary.bc-card__text-block-txt.ugc-content").text
                #print(annotation)

                # Получаем жанры
                genres_tags = driver.find_elements(By.CSS_SELECTOR, "a.bc-info__link.bc-info__link_type_category")
                for i, genre in enumerate(genres_tags):
                    genre_title = genre.text.replace("№2 в ", "").strip()
                    genre_id = next((gen["Id"] for gen in genres if gen['Title'] == genre_title), None)

                    if genre_id is None:
                        genres.append({"Id": len(genres), "Title": genre_title})
                        genre_id = len(genres) - 1

                    books_genres.append({"Book_id": books_counter, "Genre_id": genre_id})

                # Получение изображения
                labi_url = f"https://www.labirint.ru/search/{author['Author'].replace(' ', '%20')}%20{title.replace(' ', '%20')}/?stype=0"
                driver.get(labi_url)
                time.sleep(2)

                image = driver.find_element(By.CSS_SELECTOR, "div.product-card img")
                img_ratio = fuzz.WRatio(image.get_attribute("title"), f"{author['Author']} {title}")
                print(img_ratio)

                if img_ratio > 80:
                    img_path = os.path.join(BOOKS_COVERS_PATH, os.path.basename(image.get_attribute("data-src")) + ".webp")
                    with open(img_path, "wb") as f:
                        f.write(requests.get(image.get_attribute("data-src")).content)
                else:
                    img_path = os.path.join(BOOKS_COVERS_PATH, f"{books_counter}_{os.path.basename(name.find_element(By.CSS_SELECTOR, 'img').get_attribute('data-pagespeed-lazy-src'))}")
                    with open(img_path, "wb") as f:
                        f.write(requests.get(name.find_element(By.CSS_SELECTOR, "img").get_attribute('data-pagespeed-lazy-src')).content)

                books.append({
                    "Id": books_counter,
                    "Title": title,
                    "Avatar": img_path,
                })
                books_counter += 1
        df = pd.DataFrame(books)
        df.to_csv("books.csv", sep=';', encoding='utf-8', index=False)
        df.to_excel("books.xlsx")
        df = pd.DataFrame(genres)
        df.to_csv("genres.csv", sep=';', encoding='utf-8', index=False)
        df.to_excel("genres.xlsx")
        driver.quit()
        df = pd.DataFrame(books_genres)
        df.to_csv("books_genres.csv", sep=';', encoding='utf-8', index=False)
        df.to_excel("books_genres.xlsx")
        print(books)
        print(genres)
        print(books_genres)
        exit()