GithubHelp home page GithubHelp logo

lorenzodifuccia / safaribooks Goto Github PK

View Code? Open in Web Editor NEW
4.5K 106.0 659.0 152 KB

Download and generate EPUB of your favorite books from O'Reilly Learning (aka Safari Books Online) library.

License: Do What The F*ck You Want To Public License

Python 100.00%
python epub calibre safaribooksonline safaribooks safari safari-books-online oreilly

safaribooks's Introduction

Hi there 👋

Just another IT geek guy. Working on security. Writing programs I need.

Buy Me a Coffee at ko-fi.com

Proud father of the following repo:

  • 📚 safaribooks: Download EPUB of your favorite books from O'Reilly library (yeah, the original one... 😬)
  • 🤖 RaspOne: Modular Telegram bot designed for Raspberry Pi server
    • External modules:
      • Italo: Find seats availability for your Italo train
  • 🐍 http.server: (Beautiful) replacement for the http.server Python3 module. Allows file upload, preview and much more.
  • 🕵️ WatchMyBack: An easy-to-use defense tool against "Shoulder Surfing" attacks, which allows you to immediately lock the screen of your computer if someone is behind you or if you move away from the computer without locking it.
  • Many others will come...

Others:

  • ✈️ FlyScanner: Find the best rate for your next flight consulting different providers

safaribooks's People

Contributors

avineshwar avatar dependabot[bot] avatar gad0lin avatar gudata avatar hehex9 avatar joeljunior05 avatar left-blank avatar lorenzodifuccia avatar maxromanovsky avatar nrenzoni avatar omalleyian avatar pawka avatar penleychan avatar regulskimichal avatar spacewander avatar sufyandaredevil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

safaribooks's Issues

Cannot download a book series because of using the same folder

When I'm trying to download a book series such as "You Don't know JS" , it's always using the same folder ./Books/You Don_t Know JS (KyleSimpson)/ for all books.
Then I received these message

[-] Downloading book images... (9 files)
[*] Some of the book contents were already downloaded.
    If you want to be sure that all the images will be downloaded,
    please delete the `<BOOK NAME>/OEBPS/*.xhtml` files and restart the program.
[*] File `default_cover.jpeg` already exists.
    If you want to download again all the images,
    please delete the `<BOOK NAME>/OEBPS/*.xhtml` and `<BOOK NAME>/OEBPS/Images/*` files and restart the program.
    [###########################################################################################################################################] 100%

Could you append the book id to the folder name to avoid it?

work with video

hi orenzo,
not sure how much is hard to implement
what adding support to dump videos too ;)
label feature request

"Login: no CSRF Token found in the page. Unable to continue the login. Try again..."

Command:

python3 safaribooks.py --cred "[email protected]:xxx" 9781786468949

Output:


       ____     ___         _
      / __/__ _/ _/__ _____(_)
     _\ \/ _ `/ _/ _ `/ __/ /
    /___/\_,_/_/ \_,_/_/ /_/
      / _ )___  ___  / /__ ___
     / _  / _ \/ _ \/  '_/(_-<
    /____/\___/\___/_/\_\/___/

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[-] Logging into Safari Books Online...
[#] Login: no CSRF Token found in the page. Unable to continue the login. Try again...
[+] Please delete all the `<BOOK NAME>/OEBPS/*.xhtml` files and restart the program.
[!] Aborting...

info_9781786468949.log

Generate to pdf

Hello Lorenzo,
First of all thank you for this great app!

Is it possible to add feature of loading books directly to pdf format?
It would be very helpful.

Out of session error

Hi,

The script does not seem to work anymore, probably some API things have changed?

The error I get from the script:

[-] Logging into Safari Books Online...
[*] Retrieving book info...
[#] API: Out-of-Session (Authentication credentials were not provided.).

Last Log entry (Some info made anonyous):

'
[02/Aug/2018 14:15:08] Last request done:
URL: https://www.safaribooksonline.com/api/v1/book/9780071744324/
DATA: None
OTHERS: {}

    401
    Server: nginx/1.10.3 (Ubuntu)
    Content-Type: application/json
    x-xss-protection: 1; mode=block
    Content-Language: en-US
    strict-transport-security: max-age=3600; includeSubDomains
    Allow: GET, HEAD, OPTIONS
    WWW-Authenticate: Bearer realm="api"
    ETag: "d5972c9c85159c7a7494e2554c26def1"
    x-content-type-options: nosniff
    X-Frame-Options: SAMEORIGIN
    Set-Cookie: api_key=; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/, logged_in=; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/, sessionid=xxxx Domain=.www.safaribooksonline.com; expires=Thu, 16-Aug-2018 12:15:10 GMT; Max-Age=1209600; Path=/; secure
    Accept-Ranges: bytes, bytes
    Content-Length: 58
    Date: Thu, 02 Aug 2018 12:15:08 GMT
    Via: 1.1 varnish
    Connection: keep-alive
    X-Client-IP: XXXX
    X-Served-By: cache-ams4138-AMS
    X-Cache: MISS
    X-Cache-Hits: 0
    X-Timer: S1533212108.238304,VS0,VE169
    Vary: Accept, Accept-Language, Authorization, Cookie

{"detail":"Authentication credentials were not provided."}
'

Started the script with --cred "credentials" (so credentials were provided)

Encoding Error

Unhandled Exception: 'charmap' codec can't encode character '\u03c0'
Unhandled Exception: 'charmap' codec can't encode character '\u2192'

Book ID : 0596101538

UnicodeEncodeError

UnicodeEncodeError: 'ascii' codec can't encode characters in position 6580-6581: ordinal not in range(128).

Character: \xa9

Running Python 3.6.5 :: Anaconda, Inc.

No images downloaded

Thanks for the good work! The code works, but all the images are missing in the book. Please advise how to address the problem. Thanks!

Infinite "Creating EPUB file..." + fill filesystem

Hello (me again)
once again, thank you for this script, it's really useful !
I'm using it to prepare some certifications at work and have a valid Safari account.

A) For some books it works perfectly ( 9781449342562 or the Python example you give)
B) For some, it seems to loop somewhere in the zipping process and create a X GB file and crashes because of space issue at one point,
for example 9780134466330 or 9780134030999

C) I tried debugging and issue seems to be here :
shutil.make_archive(zip_file, 'zip', self.BOOK_PATH)

D) I guess it's because of the title of these books which contains a whole lot of special character

E) I tried to workaround by zipping the "Ebook Path" folder and renaming to epub and it works :)
I imagine the solution / workaround could be to allow to generate the "epub" filename with "book id" instead of book_path

F) Also when opening an epub generated by this script, it contains :
folders :
META-INF
OEBPS

Files :
mimetype
.zip
which also contains empty folders META-INF and OEBPS + mimetype

So I'd guess not needed

Have a great day !

UnicodeEncodeError: 'ascii' codec can't encode character '\xa9' in position 50: ordinal not in range(128)

I am getting error during downloading book.
Python 3.5.3

[-] Logging into Safari Books Online...
[*] Retrieving book info...
[-] Title: Prometheus: Up & Running
[-] Authors: Brian Brazil
[-] Identifier: 9781492034131
[-] ISBN: 9781492034148
[-] Publishers: O'Reilly Media, Inc.
--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.5/logging/__init__.py", line 983, in emit
    stream.write(msg)
UnicodeEncodeError: 'ascii' codec can't encode character '\xa9' in position 50: ordinal not in range(128)
Call stack:
  File "safaribooks.py", line 1024, in <module>
    SafariBooks(args_parsed)
  File "safaribooks.py", line 292, in __init__
    self.display.book_info(self.book_info)
  File "safaribooks.py", line 135, in book_info
    self.info("{0}{1}{2}: {3}".format(self.SH_YELLOW, t[0], self.SH_DEFAULT, t[1]), True)
  File "safaribooks.py", line 67, in info
    self.log(message)
  File "safaribooks.py", line 61, in log
    self.logger.info(str(message))
Message: "\x1b[33mRights\x1b[0m: Copyright \xa9 O'Reilly Media, Inc."
Arguments: ()
[#] Unhandled Exception: 'ascii' codec can't encode character '\xa9' in position 239: ordinal not in range(128) (type: UnicodeEncodeError)
[+] Please delete all the `<BOOK NAME>/OEBPS/*.xhtml` files and restart the program.
[!] Aborting...
--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.5/logging/__init__.py", line 983, in emit
    stream.write(msg)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 6722-6723: ordinal not in range(128)
Call stack:
  File "safaribooks.py", line 95, in unhandled_exception
    self.exit("Unhandled Exception: %s (type: %s)" % (o, o.__class__.__name__))
  File "safaribooks.py", line 90, in exit
    self.save_last_request()
  File "safaribooks.py", line 100, in save_last_request
    .format(*self.last_request))
  File "safaribooks.py", line 61, in log
    self.logger.info(str(message))
Message: 'Last request done:\n\tURL: https://www.safaribooksonline.com/api/v1/book/9781492034131/\n\tDATA: None\n\tOTHERS: {}\n\n\t200\n\tServer: nginx/1.10.3 (Ubuntu)\n\tContent-Type: application/json\n\tAllow: GET, HEAD, OPTIONS\n\tx-xss-protection: 1; mode=block\n\tContent-Language: en-US\n\tx-content-type-options: nosniff\n\tX-Frame-Options: SAMEORIGIN\n\tstrict-transport-security: max-age=3600; includeSubDomains, max-age=31536000; includeSubdomains\n\tContent-Encoding: gzip\n\tCache-Control: s-maxage=31536000\n\tContent-Length: 1711\n\tAccept-Ranges: bytes\n\tDate: Thu, 24 May 2018 21:25:45 GMT\n\tVia: 1.1 varnish\n\tConnection: keep-alive\n\tX-Client-IP: 62.245.87.212\n\tX-Served-By: cache-hhn1541-HHN\n\tX-Cache: MISS\n\tX-Cache-Hits: 0\n\tX-Timer: S1527197145.328775,VS0,VE551\n\tVary: Accept-Encoding\n\n{"url":"https://www.safaribooksonline.com/api/v1/book/9781492034131/","natural_key":["9781492034131"],"authors":[{"name":"Brian Brazil"}],"subjects":[],"topics":[{"score":-0.692030336285675,"name":"Information Technology / Operations","slug":"information-technology-operations","uuid":"c363ab45-daa6-442e-b572-1a4467aceeb0","epub_identifier":"9781492034131"}],"publishers":[{"name":"O\'Reilly Media, Inc.","id":1,"slug":"oreilly-media-inc"}],"chapters":["https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/cover.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/toc01.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/titlepage01.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/copyright-page01.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/preface01.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/part01.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/ch01.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/ch02.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/part02.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/ch03.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/ch04.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/ch05.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/ch06.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/part03.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/ch07.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/ch08.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/ch09.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/ch10.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/ch11.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/ch12.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/part04.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/ch13.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/ch14.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/ch15.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/ch16.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/ch17.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/part05.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/ch18.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/ch19.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/part06.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/ch20.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/ix01.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/colophon01.html","https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/colophon02.html"],"cover":"https://www.safaribooksonline.com/library/cover/9781492034131/","chapter_list":"https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/","toc":"https://www.safaribooksonline.com/api/v1/book/9781492034131/toc/","flat_toc":"https://www.safaribooksonline.com/api/v1/book/9781492034131/flat-toc/","web_url":"https://www.safaribooksonline.com/library/view/prometheus-up/9781492034131/","last_chapter_read":{"url":"https://www.safaribooksonline.com/api/v1/book/9781492034131/chapter/ch09.html","title":"9. Containers and Kubernetes","web_url":"https://www.safaribooksonline.com/library/view/prometheus-up/9781492034131/ch09.html"},"academic_excluded":false,"opf_unique_identifier_type":"pub-identifier","has_mathml":false,"created_time":"2018-05-01T16:47:13.772384Z","last_modified_time":"2018-05-01T16:53:31.924780Z","identifier":"9781492034131","name":"book.epub","title":"Prometheus: Up & Running","format":"book","content_format":"book","source":"application/epub+zip","orderable_title":"Prometheus: Up & Running","has_stylesheets":true,"description":"<span><div><p>Get up to speed with Prometheus, the metrics-based monitoring system used by thousands of organizations in production. This practical guide provides application developers, sysadmins, and DevOps practitioners with a hands-on introduction to the important aspects of Prometheus, including infrastructure and application monitoring, dashboarding and alerting, direct code instrumentation, and metric collection from third-party systems with exporters.</p><p>This open source system has gained popularity over the past few years for good reason. With its simple yet powerful data model and query language, Prometheus does one thing and it does it well. Author and Prometheus core developer Brian Brazil guides you through Prometheus setup, the Node Exporter, and the Alertmanager, then guides you through its use in application and infrastructure monitoring.</p><ul><li>Know where and how much to apply instrumentation to your application code</li><li>Expose metrics through client libraries to make them available to Prometheus</li><li>Identify metrics with labels: unique key-value pairs associated with a time series</li><li>Get an introduction to Grafana, a popular tool for building dashboards</li><li>Learn how to use the node exporter to monitor your infrastructure</li><li>Use service discovery to provide different views of your machines and services</li><li>Use Prometheus with Kubernetes, and examine exporters you can use with containers</li><li>Convert data from other monitoring systems into the Prometheus format</li></ul></div></span>","isbn":"9781492034148","issued":"2018-07-15","language":"en","rights":"Copyright \xc2\xa9 O\'Reilly Media, Inc.","updated":"2018-05-01T16:40:44.367564Z","orderable_author":"Brazil, Brian","purchase_link":null,"publisher_resource_links":{"Errata Page":"http://oreilly.com/catalog/0636920147343/errata"},"is_free":false,"is_system_book":true,"is_active":true,"is_hidden":false,"virtual_pages":458,"duration_seconds":null,"pagecount":384}\n'
Arguments: ()

info_9781492033905.log  info_9781492034131.log
lukas@PRGN00008351A:~/git/safaribooks$ cat info_9781492034131.log
[24/May/2018 23:22:14] ** Welcome to SafariBooks! **
[24/May/2018 23:22:14] Logging into Safari Books Online...
[24/May/2018 23:22:20] Retrieving book info...
[24/May/2018 23:22:21] Title: Prometheus: Up & Running
[24/May/2018 23:22:21] Authors: Brian Brazil
[24/May/2018 23:22:21] Identifier: 9781492034131
[24/May/2018 23:22:21] ISBN: 9781492034148
[24/May/2018 23:22:21] Publishers: O'Reilly Media, Inc.
[24/May/2018 23:22:21]   File "safaribooks.py", line 1024, in <module>
    SafariBooks(args_parsed)
  File "safaribooks.py", line 292, in __init__
    self.display.book_info(self.book_info)
  File "safaribooks.py", line 135, in book_info
    self.info("{0}{1}{2}: {3}".format(self.SH_YELLOW, t[0], self.SH_DEFAULT, t[1]), True)
  File "safaribooks.py", line 70, in info
    self.out(output)
  File "safaribooks.py", line 64, in out
    sys.stdout.write("\r" + " " * self.columns + "\r" + put + "\n")

[24/May/2018 23:22:21] Unhandled Exception: 'ascii' codec can't encode character '\xa9' in position 122: ordinal not in range(128) (type: UnicodeEncodeError)
[24/May/2018 23:25:43] ** Welcome to SafariBooks! **
[24/May/2018 23:25:43] Logging into Safari Books Online...
[24/May/2018 23:25:45] Retrieving book info...
[24/May/2018 23:25:46] Title: Prometheus: Up & Running
[24/May/2018 23:25:46] Authors: Brian Brazil
[24/May/2018 23:25:46] Identifier: 9781492034131
[24/May/2018 23:25:46] ISBN: 9781492034148
[24/May/2018 23:25:46] Publishers: O'Reilly Media, Inc.
[24/May/2018 23:25:46]   File "safaribooks.py", line 1024, in <module>
    SafariBooks(args_parsed)
  File "safaribooks.py", line 292, in __init__
    self.display.book_info(self.book_info)
  File "safaribooks.py", line 135, in book_info
    self.info("{0}{1}{2}: {3}".format(self.SH_YELLOW, t[0], self.SH_DEFAULT, t[1]), True)
  File "safaribooks.py", line 70, in info
    self.out(output)
  File "safaribooks.py", line 64, in out
    sys.stdout.write("\r" + " " * self.columns + "\r" + put + "\n")

[24/May/2018 23:25:46] Unhandled Exception: 'ascii' codec can't encode character '\xa9' in position 239: ordinal not in range(128) (type: UnicodeEncodeError)

error on login

Login: no CSRF Token found in the page. Unable to continue the login. Try again...

JSONDecodeError

Why this happen?

[23/Aug/2018 22:00:33] ** Welcome to SafariBooks! **
[23/Aug/2018 22:00:33] Logging into Safari Books Online...
[23/Aug/2018 22:00:35] Retrieving book info...
[23/Aug/2018 22:00:37] Title: C++ Reactive Programming
[23/Aug/2018 22:00:37] Authors: Peter Abraham, Praseed Pai
[23/Aug/2018 22:00:37] Identifier: 9781788629775
[23/Aug/2018 22:00:37] ISBN: 9781788629775
[23/Aug/2018 22:00:37] Publishers: Packt Publishing
[23/Aug/2018 22:00:37] Rights: Copyright © 2018 Packt Publishing
[23/Aug/2018 22:00:37] Description: Learn how to implement the reactive programming paradigm with C++ and build asynchronous and concurrent applicationsAbout This BookEfficiently exploit concurrency and parallelism in your programsUse the Functional Reactive programming model to structure programsUnderstand reactive GUI programming to make your own applications using QtWho This Book Is ForIf you're a C++ developer interested in using reactive programming to build asynchronous and concurrent applications, you'll find this book extr...
[23/Aug/2018 22:00:37] Release Date: 2018-06-29
[23/Aug/2018 22:00:37] URL: https://www.safaribooksonline.com/library/view/c-reactive-programming/9781788629775/
[23/Aug/2018 22:00:37] Retrieving book chapters...
[23/Aug/2018 22:00:54] File "safaribooks.py", line 1023, in
SafariBooks(args_parsed)
File "safaribooks.py", line 295, in init
self.book_chapters = self.get_book_chapters()
File "safaribooks.py", line 509, in get_book_chapters
return result + (self.get_book_chapters(page + 1) if response["next"] else [])
File "safaribooks.py", line 509, in get_book_chapters
return result + (self.get_book_chapters(page + 1) if response["next"] else [])
File "safaribooks.py", line 509, in get_book_chapters
return result + (self.get_book_chapters(page + 1) if response["next"] else [])
[Previous line repeated 7 more times]
File "safaribooks.py", line 492, in get_book_chapters
response = response.json()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\models.py", line 896, in json
return complexjson.loads(self.text, **kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\json_init_.py", line 348, in loads
return _default_decoder.decode(s)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None

[23/Aug/2018 22:00:54] Unhandled Exception: Expecting value: line 2 column 1 (char 1) (type: JSONDecodeError)
[23/Aug/2018 22:00:54] Last request done:
URL: https://www.safaribooksonline.com/api/v1/book/9781788629775/chapter/?page=12

SSO support

Hi, is it somehow possible to use SSO instead on username & pwd? Thanks

Path too long in windows

[27/Mar/2018 16:08:38] Unhandled Exception: [WinError 3] The system can't find the directory properly: 'D:\books\safaribooks\Books\9781260116601.zip' -> 'D:\books\safaribooks\Books\CompTIA Cloud_ Certification Study Guide, Second Edition (Exam CV0-002), 2nd Edition (EricA.Vanderburg,ScottWilson)\CompTIA Cloud_ Certification Study Guide, Second Edition (Exam CV0-002), 2nd Edition (EricA.Vanderburg,ScottWilson).epub' (type: FileNotFoundError)

Argparse allow_abbrev problem

Probably I have old argparse in my ubuntu 14.04. But except this it works.

Traceback (most recent call last):
  File "safaribooks.py", line 965, in <module>
    allow_abbrev=False)
TypeError: __init__() got an unexpected keyword argument 'allow_abbrev'

Unhandled Exception: [WinError 267] Directory name invalid

[01/Mar/2018 17:38:49] ** Welcome to SafariBooks! **
[01/Mar/2018 17:38:49] Logging into Safari Books Online...
[01/Mar/2018 17:38:53] Retrieving book info...
[01/Mar/2018 17:38:55] Title: Revive: How to Transform Traditional Businesses into Digital Leaders
[01/Mar/2018 17:38:55] Authors: Brian Manning, Jason Albanese
[01/Mar/2018 17:38:55] Identifier: 9780134307626
[01/Mar/2018 17:38:55] ISBN: 9780134307626
[01/Mar/2018 17:38:55] Publishers: PH Professional Business
[01/Mar/2018 17:38:55] Description: GAME-CHANGING DIGITAL TRANSFORMATION:USE DIGITAL STRATEGIES, CHANNELS, AND PLATFORMS TO TRANSFORM ENTERPRISES TO COMPETE IN THE DIGITAL AGE Move from “reactive digital” to “transformative digital” Use digital capabilities to fundamentally change the way you lead, direct, and structure organizations and teams Stay focused on the “moving target” of digital best practices, and accelerate your progress towards digital maturity REVIVE will help you build a core business model for creating your own ...
[01/Mar/2018 17:38:55] Release Date: 2015-11-17
[01/Mar/2018 17:38:55] URL: https://www.safaribooksonline.com/library/view/revive-how-to/9780134307626/
[01/Mar/2018 17:38:55] Retrieving book chapters...
[01/Mar/2018 17:39:01] File "safaribooks.py", line 992, in
SafariBooks(args_parsed)
File "safaribooks.py", line 305, in init
self.create_dirs()
File "safaribooks.py", line 671, in create_dirs
os.makedirs(self.BOOK_PATH)
File "C:\apps\Python\Python36\lib\os.py", line 220, in makedirs
mkdir(name, mode)

[01/Mar/2018 17:39:01] Unhandled Exception: [WinError 267] Directory name invalid : 'D:\books\safaribooks\Books\Revive: How to Transform Traditional Businesses into Digital Leaders' (type: NotADirectoryError)
[01/Mar/2018 17:39:01] Last request done:
URL: https://www.safaribooksonline.com/api/v1/book/9780134307626/chapter/?page=3
DATA: None
OTHERS: {}

200
Server: nginx/1.10.3 (Ubuntu)
Content-Type: application/json
Content-Language: en-US
X-Frame-Options: SAMEORIGIN
x-content-type-options: nosniff
Allow: GET, HEAD, OPTIONS
strict-transport-security: max-age=3600; includeSubDomains, max-age=31536000; includeSubdomains
x-xss-protection: 1; mode=block
Content-Encoding: gzip
Cache-Control: s-maxage=1800
Content-Length: 770
Accept-Ranges: bytes
Date: Thu, 01 Mar 2018 09:39:01 GMT
Via: 1.1 varnish
Connection: keep-alive
X-Client-IP: 111.204.128.114
X-Served-By: cache-hnd18738-HND
X-Cache: MISS
X-Cache-Hits: 0
X-Timer: S1519897141.881305,VS0,VE569
Vary: Accept, Accept-Language, Authorization, Cookie

{"count":21,"next":null,"previous":"https://www.safaribooksonline.com/api/v1/book/9780134307626/chapter/?page=2","results":[{"archive":"https://www.safaribooksonline.com/api/v1/book/9780134307626/","content":"https://www.safaribooksonline.com/api/v1/book/9780134307626/chapter-content/index.html","url":"https://www.safaribooksonline.com/api/v1/book/9780134307626/chapter/index.html","natural_key":["9780134307626","index.html"],"full_path":"index.html","minutes_required":19.549999999999997,"next_chapter":{"title":"","web_url":""},"previous_chapter":{"url":"https://www.safaribooksonline.com/api/v1/book/9780134307626/chapter/epilogue.html","title":"Epilogue. Examples of Digital Trends Accelerating the Digital Revolution","web_url":"https://www.safaribooksonline.com/library/view/revive-how-to/9780134307626/epilogue.html"},"stylesheets":[{"full_path":"9780134307626.css","url":"https://www.safaribooksonline.com/library/css/revive-how-to/9780134307626/9780134307626.css","original_url":"https://www.safaribooksonline.com/library/view/revive-how-to/9780134307626/9780134307626.css"}],"images":[],"asset_base_url":"https://www.safaribooksonline.com/library/view/revive-how-to/9780134307626/","web_url":"https://www.safaribooksonline.com/library/view/revive-how-to/9780134307626/index.html","last_position":null,"videoclips":[],"publisher_scripts":"","publisher_script_files":[],"allow_scripts":false,"videoclip":null,"academic_excluded":false,"subjects":[{"name":"Business","description":""},{"name":"Business Communication","description":""}],"authors":[{"name":"Brian Manning"},{"name":"Jason Albanese"}],"cover":"https://www.safaribooksonline.com/library/cover/9780134307626/","book_title":"Revive: How to Transform Traditional Businesses into Digital Leaders","updated":"2017-03-07T17:29:38.821287Z","site_styles":["https://www.safaribooksonline.com/static/CACHE/css/b8d25f1a9a05.css"],"created_time":"2015-12-02T20:01:17.163719Z","last_modified_time":"2015-12-02T20:01:22.960804Z","filename":"index.html","path":"","epub_properties":null,"head_extra":null,"has_video":false,"title":"Index","description":"","virtual_pages":17}]}

Download Not Successful for a special book

[-] Release Date: 2018-06-27
[-] URL: https://www.safaribooksonline.com/library/view/mastering-machine-learning/9781788997409/
[*] Retrieving book chapters...
[#] HTTPSConnectionPool(host='www.safaribooksonline.com', port=443): Max retries exceeded with url: /api/v1/book/9781788997409/chapter/?page=19 (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0xb5d689ac>: Failed to establish a new connection: [Errno -2] Name or service not known',))
[#] API: unable to retrieve book chapters.
[+] Please delete all the <BOOK NAME>/OEBPS/*.xhtml files and restart the program.
[!] Aborting...

Book ID: 9781788997409

Contrasting log messages when Out of Session while EPUB creation in process

I got an Out of Session error during EPUB creation, after downloading all book contents, CSS and images. Re-running without deleting worked well for me, however I got contrasting log messages. See below.

The log says:

[-] Logging into Safari Books Online...                                                                                                        
[*] Retrieving book info...                                                                                                                    
[-] ...<all book info>        
[*] Retrieving book chapters...                                                                                                                
[*] Output directory:                                                                                                                          
    /Users/...
[-] Downloading book contents...                                                                                                
    [##########################################################################################################] 100%
[-] Downloading book CSSs...                                                                                                          
    [##########################################################################################################] 100%
[-] Downloading book images...                                                                                                     
    [##########################################################################################################] 100%
[-] Creating EPUB file...                                                                                                                      
[#] API: Out-of-Session (Authentication credentials were not provided.).                                                                       
Don't delete any files, just run again this program in order to complete the `.epub` creation!
[+] Please delete all the `<BOOK NAME>/OEBPS/*.xhtml` files and restart the program.                                                           
[!] Aborting...                                                                                                                                

Note the last lines of the log:

[#] API: Out-of-Session (Authentication credentials were not provided.).
Don't delete any files, just run again this program in order to complete the .epub creation!
[+] Please delete all the <BOOK NAME>/OEBPS/*.xhtml files and restart the program.

Re-running without deleting the files worked well for me.

problem install safaribooks

Hello,

When i want install safaribooks in python3

C:\safaribooks>pip3 install -r requirements.txt
Requirement already satisfied: lxml>=4.1.1 in c:\python\lib\site-packages (from -r requirements.txt (line 1)) (4.2.5)
Requirement already satisfied: requests>=2.20.0 in c:\python\lib\site-packages (from -r requirements.txt (line 2)) (2.20.1)
Requirement already satisfied: certifi>=2017.4.17 in c:\python\lib\site-packages (from requests>=2.20.0->-r requirements.txt (line 2)) (2018.11.29)
Requirement already satisfied: urllib3<1.25,>=1.21.1 in c:\python\lib\site-packages (from requests>=2.20.0->-r requirements.txt (line 2)) (1.24.1)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\python\lib\site-packages (from requests>=2.20.0->-r requirements.txt (line 2)) (3.0.4)
Requirement already satisfied: idna<2.8,>=2.5 in c:\python\lib\site-packages (from requests>=2.20.0->-r requirements.txt (line 2)) (2.7)

C:\safaribooks>pip list
Package Version


certifi 2018.11.29
chardet 3.0.4
idna 2.7
lxml 4.2.5
pip 18.1
requests 2.20.1
setuptools 40.6.2
urllib3 1.24.1
youtube-dl 2018.11.23

How solve it ?

Script is always downloading images

I don't know why but for all downloads, it's downloading images.

      / __/__ _/ _/__ _____(_)
     _\ \/ _ `/ _/ _ `/ __/ /
    /___/\_,_/_/ \_,_/_/ /_/
      / _ )___  ___  / /__ ___
     / _  / _ \/ _ \/  '_/(_-<
    /____/\___/\___/_/\_\/___/

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[-] Logging into Safari Books Online...
[*] Retrieving book info...
[-] Title: Computational Thinking - A beginner's guide to problem-solving and programming
[-] Authors: Karl Beecher
[-] Identifier: 9781780173641
[-] ISBN: 9781780173641
[-] Publishers: BCS Learning & Development Limited
[-] Rights: Copyright ©BCS Learning & Development Limited
[-] Description: Computational thinking (CT) is a timeless, transferable skill that enables you to think more clearly and logically, as well as a way to solve specific problems. With this book you'll learn to apply computational thinking in the context of software development to give you a head start on the road to becoming an experienced and effective programmer.  Beginning with the core ideas of computational thinking, with this book you'll build up an understanding of the practical problem-solving approach an...
[-] Release Date: 2017-08-31
[-] URL: https://www.safaribooksonline.com/library/view/computational-thinking-/9781780173641/
[*] Retrieving book chapters...
[*] Output directory:
    /Users/rigo.sarmiento/safaribooks/Books/Computational Thinking - A beginner_s guide to problem-solving and programming (9781780173641)
[-] Downloading book contents... (34 chapters)
    [###############################################################################################################################################################################################################] 100%
[-] Downloading book CSSs... (4 files)
    [###############################################################################################################################################################################################################] 100%
[-] Downloading book images... (343 files)
    [######################################################################-----------------------------------------------------------------------------------------------------------------------------------------]  34%

Here's my command:

python3 safaribooks.py --no-kindle --cred "account:password" <book> 

<module> Error

I Run your sample and get this Error :

Traceback (most recent call last):
File "safaribooks.py", line 12, in
from html import escape
ImportError: No module named html

Regards

Not working anymore

Tried to download and here's the error:

[-] Logging into Safari Books Online...
[*] Retrieving book info...
[#] API: book's not present in Safari Books Online.
The book identifier is the digits that you can find in the URL:
https://www.safaribooksonline.com/library/view/book-name/XXXXXXXXXXXXX/
[+] Please delete all the <BOOK NAME>/OEBPS/*.xhtml files and restart the program.
[!] Aborting...

error trying to retrieve this page / Exception: Expecting value

info_9781617292774.log
error trying to retrieve this page: kindle_split_016.html (Chapter 7. Shaping the relevance function)\n
info_9781782161363.log
error trying to retrieve this page: ch02s06.html (Summary)

info_9781783984923.log
Unhandled Exception: Expecting value: line 2 column 1 (char 1) (type: JSONDecodeError)'

info_9781783987023.log
error trying to retrieve this page: ch04s03.html (Built-in analyzers)
info_9781784391010.log
error trying to retrieve this page: ch03s08.html (Sorting your data)\n
info_9781784399641.log
error trying to retrieve this page: toc.html (Table of Contents)
info_9781786460011.log
b'Unhandled Exception: Expecting value: line 2 column 1 (char 1) (type: JSONDecodeError)'
info_9781786460189.log
b'Unhandled Exception: Expecting value: line 2 column 1 (char 1) (type: JSONDecodeError)'
info_9781787128453.log
error trying to retrieve this page: 051e3348-bdf0-47dc-b558-0f2be7fbb674.xhtml (Boolean)\n
info_9781787281868.log
b'Unhandled Exception: Expecting value: line 2 column 1 (char 1) (type: JSONDecodeError)'
info_9781787286849.log
error trying to retrieve this page: 75d192b4-d51a-48e9-b3f8-798eb58c3e35.xhtml (There's more...)\n
info_9781787288546.log
error trying to retrieve this page: ch13.html (3. Not Only Full Text Search)\n

info_9781788837385.log
error trying to retrieve this page: cdd9d5a0-5524-4b2a-b760-c8270f85cb94.xhtml (Production Solr setup)\n

Please let me know if you need log files. I may send them in a secure channel because they contain sensitive data.

conversion to kindle using Kindle Previewer fails

Warning(prcfile):W14028: Following file does not exist : ../fonts/fontawesome-webfont.eot?#iefix&v=4.4.0

Error(core):E1003: Unknown error in class String.

Error(parsing):E3013: More number of characters are hidden using display:none than allowed limit. Limit: 10000 in file: C:\Users\Codrut\AppData\Local\Temp\mbp_7E2_A_19_F_22_36_2BF_30E0_400C_1\OEBPS\toc01.xhtml line: 13

any idea how to resolve this? I don't want to install Calibre.

Thanks

resume download

There are books which are very large, especially mathematics books which contain lots of pictures, e.g. Advanced Engineering Mathematics 6th Edition (9781284105971). When downloading this book the download hangs, never finishes. I restarted the download many. many times after deleting the book. I think it should be useful to be able to resume downloading from where it left off.

Unhandled Exception

[-] Creating EPUB file...
[*] Done: bla bla bla).epub

If you like it, please * this project on GitHub to make it known:
    https://github.com/lorenzodifuccia/safaribooks
e don't forget to renew your Safari Books Online subscription:
    https://www.safaribooksonline.com/signup/

Unhandled Exception: [WinError 32] The process cannot access the file because it is being used by another process: 'D:\safaribooks-master\info_9781587141485.log' (type: PermissionError)
[27/Mar/2018 19:35:43] Last request done:

This message it is received after the book it's done

Cookies.json format

Hello, my safaribooksonline account is SSO handled by my company, thus I have NO password.
Could you post an example of the cookies.json format ? (with dummy values of course)

cannot import name escape

Hi

I get this error when running python2.7 safaribooks.py

Traceback (most recent call last):
File "safaribooks.py", line 12, in
from html import escape
ImportError: cannot import name escape

pip list | grep html
html 1.16
requests-html 0.2.2

What package am i missing?

Regards,
Kevin

Feature request for proper figure formatting during conversion with Calibre

Most of the books specify the size of the figures on the XHTML files. For instance:
<img src="Images/Ch4Fig15.png" alt="This is the caption" width="2356" height="578"/>
This create issues while converting the .epub file in .azw3 or .pdf, where the images gets distorted. The problem can be easily solved by eliminating width/height in the html statement:
<img src="Images/Ch4Fig15.png" alt="This is the caption"/>
It would be nice to have an option to strip those from the XHTML files automatically.

API: Out-of-Session (Authentication credentials were not provided.).

[13/Dec/2018 21:32:13] ** Welcome to SafariBooks! **
[13/Dec/2018 21:32:13] b'Logging into Safari Books Online...'
[13/Dec/2018 21:32:16] b'Retrieving book info...'
[13/Dec/2018 21:32:17] b'API: Out-of-Session test (Authentication credentials were not provided.).\n'
[13/Dec/2018 21:32:17] b'Last request done:\n\tURL: https://www.safaribooksonline.com/api/v1/book/9781260132359/\n\tDATA: None\n\tOTHERS: {}\n\n\t401\n\tServer: nginx/1.10.3 (Ubuntu)\n\tContent-Type: application/json\n\tx-xss-protection: 1; mode=block\n\tAllow: GET, HEAD, OPTIONS\n\tETag: "d5972c9c85159c7a7494e2554c26def1"\n\tContent-Language: en-US\n\tX-Frame-Options: SAMEORIGIN\n\tstrict-transport-security: max-age=3600; includeSubDomains\n\tWWW-Authenticate: Bearer realm="api"\n\tx-content-type-options: nosniff\n\tSet-Cookie: logged_in=; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/, sessionid=81rh7rek0s66jzqdoh2de0zmloafslo0; expires=Thu, 27-Dec-2018 13:32:16 GMT; Max-Age=1209600; Path=/; secure, api_key=; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/\n\tAccept-Ranges: bytes, bytes\n\tContent-Length: 58\n\tDate: Thu, 13 Dec 2018 13:32:16 GMT\n\tVia: 1.1 varnish\n\tConnection: keep-alive\n\tX-Client-IP: 123.112.251.2\n\tX-Served-By: cache-tyo19925-TYO\n\tX-Cache: MISS\n\tX-Cache-Hits: 0\n\tX-Timer: S1544707936.393940,VS0,VE482\n\tVary: Accept, Accept-Language, Authorization, Cookie, Origin\n\n{"detail":"Authentication credentials were not provided."}\n'

Not working on some books

python 3.7.0 for macOS
errors alway on ch02.html

Books URL:
https://www.safaribooksonline.com/library/view/learning-swift-3rd/9781491987568/
https://www.safaribooksonline.com/library/view/you-dont-know/9781491905241/

error info:
[-] URL: https://www.safaribooksonline.com/library/view/learning-swift-3rd/9781491987568/ [*] Retrieving book chapters... [*] Output directory: /safaribooks/Books/Learning Swift 3rd Edition (9781491987568) [-] Downloading book contents... (32 chapters) [#] Parser: book content's corrupted or not present: ch02.html (2. The Swift Programming Language) [+] Please delete all the /OEBPS/*.xhtml files and restart the program. [!] Aborting...

[-] URL: https://www.safaribooksonline.com/library/view/you-dont-know/9781491905241/ [*] Retrieving book chapters... [*] Output directory: /safaribooks/Books/You Don_t Know JS (9781491905241) [-] Downloading book contents... (17 chapters) [#] Parser: book content's corrupted or not present: ch02.html (2. Syntax) [+] Please delete all the /OEBPS/*.xhtml files and restart the program. [!] Aborting...

UnicodeEncodeError on logging events

Always throws error when downloading a new book:

--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.5/logging/__init__.py", line 983, in emit
    stream.write(msg)
UnicodeEncodeError: 'ascii' codec can't encode character '\xa9' in position 50: ordinal not in range(128)
Call stack:
  File "safaribooks.py", line 1023, in <module>
    SafariBooks(args_parsed)
  File "safaribooks.py", line 292, in __init__
    self.display.book_info(self.book_info)
  File "safaribooks.py", line 135, in book_info
    self.info("{0}{1}{2}: {3}".format(self.SH_YELLOW, t[0], self.SH_DEFAULT, t[1]), True)
  File "safaribooks.py", line 67, in info
    self.log(message)
  File "safaribooks.py", line 61, in log
    self.logger.info(str(message))
Message: '\x1b[33mRights\x1b[0m: Copyright \xa9 2018 Packt Publishing'

rendering is mess

titles over some texts, snippets of codes not rendered, completely mess

screenshot from 2018-12-02 20-17-48

9781491941294

unable to download

Traceback (most recent call last):
File "safaribooks.py", line 1023, in
SafariBooks(args_parsed)
File "safaribooks.py", line 269, in init
self.display = Display("info_%s.log" % escape(args.bookid))
File "safaribooks.py", line 38, in init
logs_handler = logging.FileHandler(filename=self.log_file)
File "C:\Users\Arshad\AppData\Local\Programs\Python\Python37-32\lib\logging_init_.py", line 1092, in init
StreamHandler.init(self, self.open())
File "C:\Users\Arshad\AppData\Local\Programs\Python\Python37-32\lib\logging_init
.py", line 1121, in _open
return open(self.baseFilename, self.mode, encoding=self.encoding)
OSError: [Errno 22] Invalid argument: 'C:\Users\Arshad\Downloads\Compressed\safaribooks\info_https:\www.safaribooksonline.com\library\view\gamification-with-moodle\9781782173076.log'

can't give the password

hi, i have an account in safari online books which was given by my employer so if i give my company credentials its not working. so how can i use my office credentials to download it?

downloaded content is not properly ordered?

Example book : sudo python3.6 safaribooks.py 9780134030999

It looks like it downloaded fine but i see many of the image files placed at the end of the book, which should be part of a chapter placed between text with explanation.

If the downloads are not in order then i am not sure how to put together images and content in order there are a lot of images with many chapters.

not working

hi lorenzo
does it work?

[hdu@bd sb]$ cat info_%1.log
[28/Apr/2018 11:34:45] ** Welcome to SafariBooks! **
[28/Apr/2018 11:34:45] Logging into Safari Books Online...
[28/Apr/2018 11:34:48] Retrieving book info...
[28/Apr/2018 11:34:48]   File "safaribooks.py", line 1005, in <module>
    SafariBooks(args_parsed)
  File "safaribooks.py", line 291, in __init__
    self.book_info = self.get_book_info()
  File "safaribooks.py", line 464, in get_book_info
    response = response.json()
  File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 892, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None

[28/Apr/2018 11:34:48] Unhandled Exception: Expecting value: line 1 column 1 (char 0) (type: JSONDecodeError)
[28/Apr/2018 11:34:48] Last request done:
        URL: https://www.safaribooksonline.com/api/v1/book/%1/
        DATA: None
        OTHERS: {}

        400
        Server: nginx/1.10.3 (Ubuntu)
        Content-Type: text/html
        Content-Length: 182
        Accept-Ranges: bytes
        Date: Sat, 28 Apr 2018 15:34:48 GMT
        Via: 1.1 varnish
        Connection: keep-alive
        X-Client-IP: 78.9.182.146
        X-Served-By: cache-ams4137-AMS
        X-Cache: MISS
        X-Cache-Hits: 0
        X-Timer: S1524929688.191481,VS0,VE163

<html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx/1.10.3 (Ubuntu)</center>
</body>
</html>


no csrf token found, can't login

It says:
No CSRF token found on the page, Please try login again
Have tried many times, on many different pages, same response.

[21/Jul/2018 22:10:29] ** Welcome to SafariBooks! **
[21/Jul/2018 22:10:29] Logging into Safari Books Online...
[21/Jul/2018 22:11:01] Login: no CSRF Token found in the page. Unable to continue the login. Try again...
info_9780134278308.log

allow_abbrev error

Hello

Whenever I try to run it, it shows the following error:

Traceback (most recent call last):
File "safaribooks.py", line 983, in
allow_abbrev=False)
TypeError: init() got an unexpected keyword argument 'allow_abbrev'

My python version: Python 3.4.3

Problem with CSS file

One of the CSS file (Style00.css) does not get downloaded correctly and gets saved as binary file (probably just corrupted). All the other ones are downloaded correctly. This creates problem when converting later with Calibre. Here is na abstract of my log.

The Style00.css correspond to the font file downloaded from google API (first one). If you type the URL in a browser, the file gets downloaded correctly (in text format).

...
[10/Jul/2018 12:22:52] Crawler: found a new CSS at https://fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,600,700,900,200italic,300italic,400italic,600italic,700italic,900italic
[10/Jul/2018 12:22:52] Crawler: found a new CSS at https://www.safaribooksonline.com/static/CACHE/css/da86975166c9.css
[10/Jul/2018 12:22:52] Crawler: found a new CSS at https://www.safaribooksonline.com/static/css/annotator.ef38b0457d7b.css
[10/Jul/2018 12:22:52] Crawler: found a new CSS at https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css
...

cookies.json' (type: FileNotFoundError)

Here is another error :

[-] Logging into Safari Books Online...
[*] Retrieving book info...
[#] Unhandled Exception: [WinError 2] The system cannot find the file specified: 'D:\safaribooks-master\cookies.json' (type: FileNotFoundError)

Nevermind, it's from my ip.It seems safari block somehow my ip.So they don't ban user but instead they block ip.

Fail to login when password has special chars

First, thank you for this, it's going to be extremely valuable to me (reading on an e-reader is so much more comfortable than on a tablet or a phone)

Now, my problem is my passwords are generated, and, as such, contain special chars.

Right now, two of them are giving me problems: : and $

As a workaround, I escaped $ with \, but I had to modify credentials parsing to change the configured separator into a character which does not appear in my password.

May I suggest adding a --sep option, defaulting to :, so that user can choose whatever char suits best ?

As for $, I think it's more of a shell related problem, and I can't see for now a solution to this (other than escaping it, that is). Do you have any idea how we could overcome this ?

I am not fluent in python, but I can probably submit a PR making this separator option change, what do you think ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.