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-09-2011, 01:38 PM   #1
DTM
Intentionally Left Blank
DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.
 
DTM's Avatar
 
Posts: 172
Karma: 300106
Join Date: Feb 2006
Location: Royal Oak, MI, USA
Device: Nook STR
One Recipe, Multiple Feeds, Different Printer-Friendly Subs

Please help a newbie! I'm sure this must have been answered somewhere, but I can't find it.

I have a recipe that includes multiple feeds from a single source: it's a newspaper with a feed for "Headlines", another for "Editorials", and so forth. Getting the printer-friendly version for each feed is easy, you simply substitute "&template=printart" for a string in the url. But the string to replace is different for each feed. For one feed, all the articles have "/1478/rss", for another it's "/1016/rss05", etc.

I can get them to work for each feed individually, but how do I handle multiple substitutions within the same recipe?
DTM is offline   Reply With Quote
Old 02-09-2011, 05:01 PM   #2
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by DTM View Post
Please help a newbie! I'm sure this must have been answered somewhere, but I can't find it.

I have a recipe that includes multiple feeds from a single source: it's a newspaper with a feed for "Headlines", another for "Editorials", and so forth. Getting the printer-friendly version for each feed is easy, you simply substitute "&template=printart" for a string in the url. But the string to replace is different for each feed. For one feed, all the articles have "/1478/rss", for another it's "/1016/rss05", etc.

I can get them to work for each feed individually, but how do I handle multiple substitutions within the same recipe?
In your print_version add an if elif else chain to find which url to modify, and change it.
Starson17 is offline   Reply With Quote
Advert
Old 02-09-2011, 09:11 PM   #3
DTM
Intentionally Left Blank
DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.
 
DTM's Avatar
 
Posts: 172
Karma: 300106
Join Date: Feb 2006
Location: Royal Oak, MI, USA
Device: Nook STR
Thanks!

I thought that was the way to go, but couldn't get it working. After another look at it, I got the syntax right, and that did it!
DTM is offline   Reply With Quote
Old 02-10-2011, 09:57 AM   #4
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by DTM View Post
Thanks!

I thought that was the way to go, but couldn't get it working. After another look at it, I got the syntax right, and that did it!
That's great.
Starson17 is offline   Reply With Quote
Old 02-10-2011, 10:11 PM   #5
DTM
Intentionally Left Blank
DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.
 
DTM's Avatar
 
Posts: 172
Karma: 300106
Join Date: Feb 2006
Location: Royal Oak, MI, USA
Device: Nook STR
And great it is!

After getting past that problem, the next issue turned out to be that the printer-friendly page was laid out with tables, which make my Nook gag. After a refresher course in regular expressions--have not used those since SunriseXP, years ago--I got around that. A couple more minor clean-up items, and I'll be golden!

I'll probably then submit that to wherever these things get submitted. (In case anyone is interested, it's the Detroit News.)
DTM is offline   Reply With Quote
Advert
Old 02-11-2011, 10:17 AM   #6
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by DTM View Post
And great it is!

After getting past that problem, the next issue turned out to be that the printer-friendly page was laid out with tables, which make my Nook gag. After a refresher course in regular expressions--have not used those since SunriseXP, years ago--I got around that. A couple more minor clean-up items, and I'll be golden!

I'll probably then submit that to wherever these things get submitted. (In case anyone is interested, it's the Detroit News.)
You can submit here - just note that you think it is ready for inclusion as a builtin. As to tables, you can regex them out of existence, but there are also some automatic table and style removal options for recipes.
Starson17 is offline   Reply With Quote
Old 02-11-2011, 10:54 AM   #7
DTM
Intentionally Left Blank
DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.
 
DTM's Avatar
 
Posts: 172
Karma: 300106
Join Date: Feb 2006
Location: Royal Oak, MI, USA
Device: Nook STR
Quote:
Originally Posted by Starson17 View Post
...there are also some automatic table and style removal options for recipes.
That might be a better way to go. If they were to tweak their code, it might well break my regex. Where do I find that?
DTM is offline   Reply With Quote
Old 02-11-2011, 11:10 AM   #8
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by DTM View Post
That might be a better way to go. If they were to tweak their code, it might well break my regex. Where do I find that?
conversion_options¶
Recipe specific options to control the conversion of the downloaded content into an e-book. These will override any user or plugin specified values, so only use if absolutely necessary. For example:
Code:
    conversion_options = {
      'base_font_size'   : 16,
      'tags'             : 'mytag1,mytag2',
      'title'            : 'My Title',
      'linearize_tables' : True,
    }
no_stylesheets¶
Convenient flag to disable loading of stylesheets for websites that have overly complex stylesheets unsuitable for conversion to ebooks formats If True stylesheets are not downloaded and processed
Code:
no_stylesheets = True
remove_attributes¶
List of attributes to remove from all tags For example:
Code:
    remove_attributes = ['style', 'font']
API Reference
http://calibre-ebook.com/user_manual...ownloaded-html
Starson17 is offline   Reply With Quote
Old 02-11-2011, 11:25 AM   #9
DTM
Intentionally Left Blank
DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.DTM ought to be getting tired of karma fortunes by now.
 
DTM's Avatar
 
Posts: 172
Karma: 300106
Join Date: Feb 2006
Location: Royal Oak, MI, USA
Device: Nook STR
OK, I'm using "no_stylesheets", and have looked at "remove_attributes", but had no idea what "linearize_tables" meant. I'll give it a try this evening.
DTM is offline   Reply With Quote
Old 02-11-2011, 01:04 PM   #10
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by DTM View Post
had no idea what "linearize_tables" meant. I'll give it a try this evening.
It just removes the table, row and data tags so that the rows in the table are treated like lines (linearized) of text. You get all the data, and the advantages of automatic line breaks and reflow to fit a small screen, but you lose vertical alignment of different cells in the table.
Starson17 is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple Kindles, Multiple News Feeds filmprof Recipes 10 02-20-2012 10:38 AM
Displaying Multiple RSS Feeds in a Single Section? commandercup Recipes 5 03-01-2011 05:34 PM
Auto send diff feeds to multiple devices tutorial mean_gene Calibre 0 12-27-2010 02:26 PM
HP Starts Shipping iPad-Friendly Printer kjk Apple Devices 7 06-29-2010 04:19 PM
RSS feeds + combining multiple html into ebook? hapax legomenon Calibre 2 08-20-2008 02:32 PM


All times are GMT -4. The time now is 04:22 PM.


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