Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Recipes

Notices

Reply
 
Thread Tools Search this Thread
Old 02-16-2011, 02:14 AM   #1
stickybuns
Evangelist
stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.
 
stickybuns's Avatar
 
Posts: 405
Karma: 479729
Join Date: Feb 2011
Device: Kindle 3, Kindle Paperwhite 2
Are recipes doable for a programming noob?

Are calibre recipes the sort of thing that someone with little or no programming background can grok, or does one need to spend a few hours/days/months/years studying Programming 101?

I enjoy learning new things, but I don't quite know where to start. Shoot, I'm not even sure what language calibre uses!


(I know that I'm probably posting in the wrong section, but I didn't know where else to put this... )
stickybuns is offline   Reply With Quote
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
Old 02-16-2011, 11:29 AM   #3
stickybuns
Evangelist
stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.
 
stickybuns's Avatar
 
Posts: 405
Karma: 479729
Join Date: Feb 2011
Device: Kindle 3, Kindle Paperwhite 2
Thank you, sorin... your post was very helpful.

Follow-up question: do recipes only work with .xml feeds? The blogs that I'd like to have feeds for all give .rdf files when I click their RSS links.
stickybuns is offline   Reply With Quote
Old 02-16-2011, 03:40 PM   #4
tolyluis
Enthusiast
tolyluis doesn't littertolyluis doesn't litter
 
Posts: 49
Karma: 196
Join Date: Jan 2011
Device: Kindle 3
.rdf files works fine at my (little) experience making recipes, look for a recipe in Calibre called "Blog de David Bravo", it's a example of a feed with .rdf format.
tolyluis is offline   Reply With Quote
Old 02-16-2011, 04:10 PM   #5
thearr
Member
thearr once ate a cherry pie in a record 7 seconds.thearr once ate a cherry pie in a record 7 seconds.thearr once ate a cherry pie in a record 7 seconds.thearr once ate a cherry pie in a record 7 seconds.thearr once ate a cherry pie in a record 7 seconds.thearr once ate a cherry pie in a record 7 seconds.thearr once ate a cherry pie in a record 7 seconds.thearr once ate a cherry pie in a record 7 seconds.thearr once ate a cherry pie in a record 7 seconds.thearr once ate a cherry pie in a record 7 seconds.thearr once ate a cherry pie in a record 7 seconds.
 
Posts: 22
Karma: 1756
Join Date: Jan 2011
Location: Moscow, RU
Device: Kindle3, iPhone4, iPad2
Quote:
Originally Posted by stickybuns View Post
Are calibre recipes the sort of thing that someone with little or no programming background can grok, or does one need to spend a few hours/days/months/years studying Programming 101?
Hi, I'm also have very little programming background, but I found out that python recipes are very easy to write. It took me less then one day to learn python basics, study BeautifulSoup and BasicNewsRecipes classes, and create a very short, but properly working recipe for my Kindle web bookmarks collection (site, recipe and fetched book)

All you need to do in order:
1. Install python. I used this portable all included version 2.6.1.
2. Study python basics. I'm reading Dive Into Python and highly recommend it. Chapters 2-8 are enough to start.
3. Read the introductory manual to news fetching here.
4. Study BeautifulSoup and BasicNewsRecipes documentation.

After this you can start coding your first recipe and will be satisfied with results.
thearr is offline   Reply With Quote
Old 02-16-2011, 05:19 PM   #6
stickybuns
Evangelist
stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.
 
stickybuns's Avatar
 
Posts: 405
Karma: 479729
Join Date: Feb 2011
Device: Kindle 3, Kindle Paperwhite 2
Thank you, tolyluis!

Do I need anything special to edit python, or can I just use a simple text editor to make my changes?

ETA: Oh, I managed to figure out how to use the "Basic Mode". I assume that the "Advanced Mode" will let me fine tune the style sheet? I definitely need to do something to limit the size of photographs (or eliminate them, I suppose).

Last edited by stickybuns; 02-16-2011 at 05:38 PM. Reason: Oh, hey, nifty!
stickybuns is offline   Reply With Quote
Old 02-17-2011, 04:16 AM   #7
JvdW
Zealot
JvdW doesn't litterJvdW doesn't litter
 
Posts: 115
Karma: 150
Join Date: Jul 2008
Location: Netherlands Veenendaal
Device: Palm T5, Sony PRS-505, Nook Color
Quote:
Originally Posted by stickybuns View Post
Thank you, tolyluis!

Do I need anything special to edit python, or can I just use a simple text editor to make my changes?
Python uses whitespace to start/end blocks so is sensitive to the difference between using spaces and tabs, watch out for that. Using Notepad is possible but using a Python aware editor is nicer, it will color keywords etc.

Start at http://www.phyton.org and read up on its documentation. Parsing webpages needs BeautifulSoup I think.

Regards,

Joop
JvdW is offline   Reply With Quote
Old 02-17-2011, 08:16 AM   #8
sorin
Connoisseur
sorin began at the beginning.
 
Posts: 73
Karma: 44
Join Date: Sep 2010
Device: kindle 3
Quote:
Originally Posted by JvdW View Post
Start at http://www.phyton.org and read up on its documentation. Parsing webpages needs BeautifulSoup I think.
I believe the url is http://www.python.org/
sorin is offline   Reply With Quote
Old 02-17-2011, 02:07 PM   #9
stickybuns
Evangelist
stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.stickybuns ought to be getting tired of karma fortunes by now.
 
stickybuns's Avatar
 
Posts: 405
Karma: 479729
Join Date: Feb 2011
Device: Kindle 3, Kindle Paperwhite 2
Thank you Thearr, JvdW, sorin, and tolyluis for all of your feedback and linkage. Looks like I'll be spending the weekend reading up on python
stickybuns is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Kindle DX and Programming books fulcrum Amazon Kindle 4 01-12-2010 04:30 PM
PRS-500 500 Programming MarzKrishna Sony Reader Dev Corner 1 12-17-2009 08:43 PM
Hacks Foreign language support - doable on 1.0? seajewel Amazon Kindle 31 03-09-2009 01:49 PM
For-free and priced ebooks doable? Moejoe Lounge 8 02-09-2009 10:20 AM
Advanced Linux Programming Alexander Turcic Deals and Resources (No Self-Promotion or Affiliate Links) 0 03-28-2003 01:20 PM


All times are GMT -4. The time now is 09:49 PM.


MobileRead.com is a privately owned, operated and funded community.