View Single Post
Old 02-16-2011, 03:28 AM   #2
sorin
Connoisseur
sorin began at the beginning.
 
Posts: 73
Karma: 44
Join Date: Sep 2010
Device: kindle 3
Recipes are made in pyton language but you don't need to know much to create one.

First try to check some recipes examples.
To do that open Calibre and press the arrow near Fetch news -> Add custom news source-> Customize buildin recipe and select ScienceDaily[en] by Darko Miletic - this is a clean and easy to understand recipe.

Copy ScienceDaily template in a file, rename it, set extension .recipe then change:

keep_only_tags – represents what html tags will appear in subscription.
keep_only_tags = [ dict(name='h1', attrs={'class':'story'}) - ScienceDaily recipe take content from tag h1 with css class named story

remove_tags_after - where parsing operation have to stop
remove_tags_after = dict(name='div', attrs={'id':'citationbox'}) - parsing operation stop after tag div with id=citationbox


remove_tags
– what html tags will be removed from elements parsed using
keep_only_tags
remove_tags = [dict(name='div', attrs={'id':'citationbox'} - will remove tag div with id=citationbox

feeds – your rss list
feeds = [(u"ScienceDaily", u'http://www.sciencedaily.com/newsfeed.xml')]

You have to change class name, title, description and cover_url.

Copy your recipe in folder where Calibre is installed and run this in command prompt:
C:\Program Files\Calibre2>ebook-convert YourRecipe.recipe D:\temp –test -vv
Check index.html from D:\temp.

To inspect a html file i recommend firebug plugin and firefox

You can find a recipe tutorial at calibre-ebook

Last edited by sorin; 02-16-2011 at 05:05 AM.
sorin is offline   Reply With Quote