Cyberes / vitalsource2pdf

Ultra-high quality PDFs from VitalSource.
GNU Affero General Public License v3.0
69 stars 17 forks source link

Weird link is loaded after signing in #15

Open jackfurmanek opened 10 months ago

jackfurmanek commented 10 months ago

Hello. After running the initial command, signing in, and pressing ENTER, the first link that the page loads is this:

https://bookshelf.vitalsource.com/reader/books/%7Bargs.isbn%7D/pageid/%7Bpage_id%7D

Which I don't think is correct, unless I'm mistaken. Upon loading this link, the page stalls forever, endlessly showing five pulsing loading dots and nothing else. The command line also displays nothing. Upon closing the window, the program halts with these errors:

jackfurmanek@DESKTOP-PVRV3KP:/mnt/c/Users/jackf/Downloads/vitalsource2pdf-master/vitalsource2pdf-master$ ./vitalsource2pdf.py --isbn 9781478650898
Press ENTER once logged in...
Traceback (most recent call last):
  File "/mnt/c/Users/jackf/Downloads/vitalsource2pdf-master/vitalsource2pdf-master/./vitalsource2pdf.py", line 115, in <module>
    load_book_page(page_num)
  File "/mnt/c/Users/jackf/Downloads/vitalsource2pdf-master/vitalsource2pdf-master/./vitalsource2pdf.py", line 91, in load_book_page
    get_num_pages()  # Wait for the page to load
  File "/mnt/c/Users/jackf/Downloads/vitalsource2pdf-master/vitalsource2pdf-master/./vitalsource2pdf.py", line 75, in get_num_pages
    total = int(driver.execute_script('return document.getElementsByClassName("'+platform_identifiers['total_pages']+'")[0].innerHTML').strip().split('/')[-1].strip())
  File "/home/jackfurmanek/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 408, in execute_script
    return self.execute(command, {"script": script, "args": converted_args})["value"]
  File "/home/jackfurmanek/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 348, in execute
    self.error_handler.check_response(response)
  File "/home/jackfurmanek/.local/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
from unknown error: web view not found
  (Session info: chrome=120.0.6099.199)
Stacktrace:
#0 0x55eae1827f83 <unknown>
#1 0x55eae14e0cf7 <unknown>
#2 0x55eae14b4728 <unknown>
#3 0x55eae156169f <unknown>
#4 0x55eae1578719 <unknown>
#5 0x55eae1559e53 <unknown>
#6 0x55eae1521dd4 <unknown>
#7 0x55eae15231de <unknown>
#8 0x55eae17ec531 <unknown>
#9 0x55eae17f0455 <unknown>
#10 0x55eae17d8f55 <unknown>
#11 0x55eae17f10ef <unknown>
#12 0x55eae17bc99f <unknown>
#13 0x55eae1815008 <unknown>
#14 0x55eae18151d7 <unknown>
#15 0x55eae1827124 <unknown>
#16 0x7f107b4ceac3 <unknown>

Am I doing something wrong with using the script?

Thanks for the work you've put into this.

roklul commented 10 months ago

I have the same question

Altair11165 commented 9 months ago

Hello, I am facing the same issue, any help would be highly appreciated Thankx in advance

LaloRiojas commented 6 months ago

found the solution will make a pull requst soon. they forgot to make a string into a f'' string. simple fix. add f to line 90 of vitalsource2pdf.py after [home_url] + '' .

line 90 should look like
driver.get(platform_identifiers['home_url']+f'/reader/books/{args.isbn}/pageid/{page_id}') instead of driver.get(platform_identifiers['home_url']+'/reader/books/{args.isbn}/pageid/{page_id}')