hurlenko / orly Goto Github PK
View Code? Open in Web Editor NEWDownload O'Reilly books as EPUB.
License: MIT License
Download O'Reilly books as EPUB.
License: MIT License
I have an O'Reilly account via acm.org which seems to use a different auth mechanism (SSO). Please consider adding support for SSO.
thread 'main' panicked at src\epub\builder.rs:336:14:
Failed to encode image: Unsupported(UnsupportedError { format: Exact(Jpeg), kind: Color(Rgb16) })
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
ID: 9781492087151
Also can you add option to disable encoding of images?
Hi.
I noticed some visual issues with the downloaded books. No background-color for code blocks, squashed calloutlists, etc. Not to mention that styles in the downloaded book looks different from web site.
I found out that there is stylesheet that not mentioned in API response. I will use Fluent Python, 2nd Edition as an example. If you look at compiled page source, there will be two styleshees for the book:
<link rel="stylesheet" href="/files/public/epub-reader/override_v1.css" crossorigin="anonymous">
<link rel="stylesheet" href="/api/v2/epubs/urn:orm:book:9781492056348/files/epub.css" crossorigin="anonymous">
Second one comes from the API response, but first one override_v1.css
actually hard coded in .js
file. In the book page there is script file https://learning.oreilly.com/library/view/dist/main.6c3d155559e48f978143.js and there you can find this code:
...
injectStyles:
async e=>{var t;let{chapter:n,getReaderRef:r}=e;const o=r(),i=[`${window.location.origin}/files/public/epub-reader/override_v1.css`,...(null===(t=n.related_assets)||void 0===t?void 0:t.stylesheets)
...
injectStyles
styles function creates an array with first element hard coded ${window.location.origin}/files/public/epub-reader/override_v1.css
and the rest stylesheets from the API response.
I took this styleesheet and added it to already downloaded book. Removing any mention of #book-content
from it, since the book don't have this id. I removed this block:
#book-content {
font-family: Noto Serif,serif !important;
margin-bottom: 80px !important;
}
And used this regex (\s+|)#book-content(\s+|)
to remove any other mention.
Here are comparison shots from the Calibre viewer:
Left: without override_v1.css, Right: with override_v1.css. Notice background-color for inline code and code blocks. Also fixed squashed list elements.
Also I added this css rule for better aligning of calloutlists:
#sbo-rt-content dl.calloutlist dt
{
margin-bottom: 0 !important;
}
Left before adding css rule, right after.
Do you think that it possible to add this css improvements for downloaded books? It could be done by adding https://learning.oreilly.com/files/public/epub-reader/override_v1.css to every book, since O'Reilly is doing it anyway. Or to be save, the main\..*\.js
file from book page could be parsed to look for any hard coded css file.
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `0`,
right: `1`', src/epub/builder.rs:208:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Book: 9781789801217
orly --creds "<my-email>" "${O_PASSWORD}" 9781838648817
[2024-02-25 21:53:46][INFO] Checking if password login is possible
[2024-02-25 21:53:47][INFO] Logging into Safari Books Online...
Error: AuthenticationFailed("Login request failed, make sure your email and password are correct: HTTP status client error (403 Forbidden) for url (https://api.oreilly.com/api/v1/auth/login/)")
I thought I'd try the --cookie
setting, but I guess I don't understand what the "Browser Cookie" is.
(Also listed here https://www.oreilly.com/privacy-cookies.html)
My Chrome dev console network tab shows no request cookies with anything like that name, for the book page I am able to access.
I cleared my cookies for O'Reilly, logged back in, then was able to see a "BrowserCookie". But I still got an error.
Hello,
Could you please to take a look on below issue when I'm trying to download:
orly-0.1.6\src\epub\builder.rs:236:17:
assertion left == right
failed
left: 0
right: 1
stack backtrace:
0: 0x7ff7d2ae25c8 -
1: 0x7ff7d270adf9 -
2: 0x7ff7d2ad4c91 -
3: 0x7ff7d2ae3fa6 -
4: 0x7ff7d2ae389a -
5: 0x7ff7d2ae47a7 -
6: 0x7ff7d2ae41e7 -
7: 0x7ff7d2ae412f -
8: 0x7ff7d2ae4118 -
9: 0x7ff7d2c27a14 - locale_charset
10: 0x7ff7d2c27bf3 - locale_charset
11: 0x7ff7d2c292c4 - locale_charset
12: 0x7ff7d2a02d6a -
13: 0x7ff7d26aec72 -
14: 0x7ff7d26c9377 -
15: 0x7ff7d26c0cef -
16: 0x7ff7d2653af0 -
17: 0x7ff7d26cb53b -
18: 0x7ff7d2bf6dec - locale_charset
19: 0x7ffa3f20257d - BaseThreadInitThunk
20: 0x7ffa40b4af28 - RtlUserThreadStart
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.