setanta / ebookmaker Goto Github PK
View Code? Open in Web Editor NEWPython script that builds epub files from common HTML and a JSON book description.
Python script that builds epub files from common HTML and a JSON book description.
Hi!
This project should be explicitly licensed under a preferably FLOSS licence, see https://www.mail-archive.com/[email protected]/msg04541.html .
Update: see my comment below about rebookmaker.
This issue affects users with more than 9 text files.
# Expand wild cards.
if item['type'] == 'text' and '*' in item['source']:
files = sorted(glob(item['source']))
The simple sorted function sort the filenames with the wildcard as strings, which in the case where the filenames are 'file1, file2,... , file10' the sorted list ends up as 'file1, file10, file2, ..., file9'.
To fix this I used the natsort package, but I leave it up to the author to choose his prefered method to naturally sort filenames.
from natsort import natsorted
# Expand wild cards.
if item['type'] == 'text' and '*' in item['source']:
files = natsorted(glob(item['source']))
I think I'd like to use ebookmaker for something like the iliada recipe, except I'm not sure what it actually does because iliadaemportugues.blogspot.com.br/2009/01/ is now 404. I'm having trouble figuring out what the JSON file needs to look like, and I was hoping that recipe might help me figure it out.
Are there any other recipes that still work that might be substituted? ebookmaker looks pretty great if I knew what to put in the JSON.
Hi,
ebookmaker parses the HTML using regular expresions which is error prone and unreliable:
An example for this is:
contents = f.read()
regex = re.compile('<h(\d+)(?:\s+id=\"(.*)\")?>(.*)</h\d>',
re.IGNORECASE|re.MULTILINE|re.UNICODE)
results = regex.findall(contents)
Can you use a parser such as BeautifulSoup instead?
Regards,
-- Shlomi Fish
SInce both lower and upper case characters are accepted as html tags, I think a more general solution to
def collectImagesFromEBookContents(self, htmlFile):
with open(htmlFile, encoding='utf-8', mode='r') as f:
soup = BeautifulSoup(f.read())
return [img.src for img in soup.body.findAll('img') if img.has_attr('src')]
would be better. In my case, I hardcoded capitals to have my ebook created, but I think that it can be easily fixed ;-)
Kudos for all your work
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.