All Projects → lorenzodifuccia → Safaribooks

lorenzodifuccia / Safaribooks

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

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Safaribooks

calibre-kindle-comics
A calibre plugin that converts your comics into a readable format for kindle.
Stars: ✭ 32 (-99%)
Mutual labels:  epub, calibre
ebook-converter
Commandline tool for converting between several e-books formats, based on Calibre project.
Stars: ✭ 21 (-99.35%)
Mutual labels:  epub, calibre
safari-training-react
Code examples and exercises for Safari LiveTraining course.
Stars: ✭ 12 (-99.63%)
Mutual labels:  safari, oreilly
Calibre Web
📚 Web app for browsing, reading and downloading eBooks stored in a Calibre database
Stars: ✭ 5,616 (+75.06%)
Mutual labels:  epub, calibre
acsm-calibre-plugin
Calibre plugin for ACSM->EPUB and ACSM->PDF conversion.
Stars: ✭ 118 (-96.32%)
Mutual labels:  epub, calibre
Calibre
The official source code repository for the calibre ebook manager
Stars: ✭ 11,221 (+249.78%)
Mutual labels:  epub, calibre
Manifold
Transforming scholarly publications into living digital works.
Stars: ✭ 163 (-94.92%)
Mutual labels:  epub
Pandoc Markdown Book Template
A template for creating epub books from markdown using pandoc.
Stars: ✭ 191 (-94.05%)
Mutual labels:  epub
Webpages To Ebook
Create an EPUB from a list of URLs. Standing on the shoulders of Wget, Readability and Pandoc.
Stars: ✭ 155 (-95.17%)
Mutual labels:  epub
Dart Epub
Epub Reader and Writer for Dart
Stars: ✭ 146 (-95.45%)
Mutual labels:  epub
Eplee
Sweet, simple epub reader
Stars: ✭ 227 (-92.92%)
Mutual labels:  epub
Comicbook
epub comic generator | nhentai.net | e-hentai.org | wnacg.org
Stars: ✭ 222 (-93.08%)
Mutual labels:  epub
Blitz
An eBook Framework (CSS + template)
Stars: ✭ 179 (-94.42%)
Mutual labels:  epub
Folioreader Android
A Java ePub reader and parser framework for Android.
Stars: ✭ 2,025 (-36.88%)
Mutual labels:  epub
Folioreaderkit
📚 A Swift ePub reader and parser framework for iOS.
Stars: ✭ 2,382 (-25.75%)
Mutual labels:  epub
Epubviewer
ePub viewer with dictionary, themes, search, offline support, and more
Stars: ✭ 156 (-95.14%)
Mutual labels:  epub
Remotedebug Ios Webkit Adapter
Debug Safari and WebViews on iOS from tools like VS Code and Chrome DevTools
Stars: ✭ 2,563 (-20.11%)
Mutual labels:  safari
Lazy
Kule Lazy4 / CSS Framework
Stars: ✭ 147 (-95.42%)
Mutual labels:  safari
Ultratabsaver
The open source Tab Manager Extension for Safari.
Stars: ✭ 178 (-94.45%)
Mutual labels:  safari
Bookdown
Authoring Books and Technical Documents with R Markdown
Stars: ✭ 2,768 (-13.72%)
Mutual labels:  epub

SafariBooks

Download and generate EPUB of your favorite books from Safari Books Online library.
I'm not responsible for the use of this program, this is only for personal and educational purpose.
Before any usage please read the O'Reilly's Terms of Service.

Overview:

Requirements & Setup:

First of all, it requires python3 and pip3 or pipenv to be installed.

$ git clone https://github.com/lorenzodifuccia/safaribooks.git
Cloning into 'safaribooks'...

$ cd safaribooks/
$ pip3 install -r requirements.txt

OR

$ pipenv install && pipenv shell

The program depends of only two Python 3 modules:

lxml>=4.1.1
requests>=2.20.0

Usage:

It's really simple to use, just choose a book from the library and replace in the following command:

  • X-es with its ID,
  • email:password with your own.
$ python3 safaribooks.py --cred "[email protected]:password01" XXXXXXXXXXXXX

The ID is the digits that you find in the URL of the book description page:
https://www.safaribooksonline.com/library/view/book-name/XXXXXXXXXXXXX/
Like: https://www.safaribooksonline.com/library/view/test-driven-development-with/9781491958698/

Program options:

$ python3 safaribooks.py --help
usage: safaribooks.py [--cred <EMAIL:PASS> | --login] [--no-cookies]
                      [--kindle] [--preserve-log] [--help]
                      <BOOK ID>

Download and generate an EPUB of your favorite books from Safari Books Online.

positional arguments:
  <BOOK ID>            Book digits ID that you want to download. You can find
                       it in the URL (X-es):
                       `https://learning.oreilly.com/library/view/book-
                       name/XXXXXXXXXXXXX/`

optional arguments:
  --cred <EMAIL:PASS>  Credentials used to perform the auth login on Safari
                       Books Online. Es. ` --cred
                       "[email protected]:password01" `.
  --login              Prompt for credentials used to perform the auth login
                       on Safari Books Online.
  --no-cookies         Prevent your session data to be saved into
                       `cookies.json` file.
  --kindle             Add some CSS rules that block overflow on `table` and
                       `pre` elements. Use this option if you're going to
                       export the EPUB to E-Readers like Amazon Kindle.
  --preserve-log       Leave the `info_XXXXXXXXXXXXX.log` file even if there
                       isn't any error.
  --help               Show this help message.

The first time you use the program, you'll have to specify your Safari Books Online account credentials (look here for special character).
The next times you'll download a book, before session expires, you can omit the credential, because the program save your session cookies in a file called cookies.json.
For SSO, please use the sso_cookies.py program in order to create the cookies.json file from the SSO cookies retrieved by your browser session (please follow these steps).

Pay attention if you use a shared PC, because everyone that has access to your files can steal your session. If you don't want to cache the cookies, just use the --no-cookies option and provide all time your credential through the --cred option or the more safe --login one: this will prompt you for credential during the script execution.

You can configure proxies by setting on your system the environment variable HTTPS_PROXY or using the USE_PROXY directive into the script.

Calibre EPUB conversion

Important: since the script only download HTML pages and create a raw EPUB, many of the CSS and XML/HTML directives are wrong for an E-Reader. To ensure best quality of the output, I suggest you to always convert the EPUB obtained by the script to standard-EPUB with Calibre. You can also use the command-line version of Calibre with ebook-convert, e.g.:

$ ebook-convert "XXXX/safaribooks/Books/Test-Driven Development with Python 2nd Edition (9781491958698)/9781491958698.epub" "XXXX/safaribooks/Books/Test-Driven Development with Python 2nd Edition (9781491958698)/9781491958698_CLEAR.epub"

After the execution, you can read the 9781491958698_CLEAR.epub in every E-Reader and delete all other files.

The program offers also an option to ensure best compatibilities for who wants to export the EPUB to E-Readers like Amazon Kindle: --kindle, it blocks overflow on table and pre elements (see example).
In this case, I suggest you to convert the EPUB to AZW3 with Calibre or to MOBI, remember in this case to select Ignore margins in the conversion options:

Calibre IgnoreMargins

Examples:

  • Download Test-Driven Development with Python, 2nd Edition:

    $ python3 safaribooks.py --cred "[email protected]:MyPassword1!" 9781491958698
    
           ____     ___         _ 
          / __/__ _/ _/__ _____(_)
         _\ \/ _ `/ _/ _ `/ __/ / 
        /___/\_,_/_/ \_,_/_/ /_/  
          / _ )___  ___  / /__ ___
         / _  / _ \/ _ \/  '_/(_-<
        /____/\___/\___/_/\_\/___/
    
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    [-] Logging into Safari Books Online...
    [*] Retrieving book info... 
    [-] Title: Test-Driven Development with Python, 2nd Edition                     
    [-] Authors: Harry J.W. Percival                                                
    [-] Identifier: 9781491958698                                                   
    [-] ISBN: 9781491958704                                                         
    [-] Publishers: O'Reilly Media, Inc.                                            
    [-] Rights: Copyright © O'Reilly Media, Inc.                                    
    [-] Description: By taking you through the development of a real web application 
    from beginning to end, the second edition of this hands-on guide demonstrates the 
    practical advantages of test-driven development (TDD) with Python. You’ll learn 
    how to write and run tests before building each part of your app, and then develop
    the minimum amount of code required to pass those tests. The result? Clean code
    that works.In the process, you’ll learn the basics of Django, Selenium, Git, 
    jQuery, and Mock, along with curre...
    [-] Release Date: 2017-08-18
    [-] URL: https://learning.oreilly.com/library/view/test-driven-development-with/9781491958698/
    [*] Retrieving book chapters...                                                 
    [*] Output directory:                                                           
        /XXXX/safaribooks/Books/Test-Driven Development with Python 2nd Edition (9781491958698)
    [-] Downloading book contents... (53 chapters)                                  
        [#####################################################################] 100%
    [-] Downloading book CSSs... (2 files)                                          
        [#####################################################################] 100%
    [-] Downloading book images... (142 files)                                      
        [#####################################################################] 100%
    [-] Creating EPUB file...                                                       
    [*] Done: /XXXX/safaribooks/Books/Test-Driven Development with Python 2nd Edition 
    (9781491958698)/9781491958698.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://learning.oreilly.com
    
    [!] Bye!!

    The result will be (opening the EPUB file with Calibre):

    Book Appearance

  • Use or not the --kindle option:

    $ python3 safaribooks.py --kindle 9781491958698

    On the right, the book created with --kindle option, on the left without (default):

    NoKindle Option


Thanks!!

For any kind of problem, please don't hesitate to open an issue here on GitHub.

Lorenzo Di Fuccia

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].