Register Guidelines E-Books Search Today's Posts Mark Forums Read

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

Notices

Reply
 
Thread Tools Search this Thread
Old 01-17-2011, 01:46 PM   #1
bcollier
Member
bcollier began at the beginning.
 
bcollier's Avatar
 
Posts: 22
Karma: 10
Join Date: Jan 2011
Device: Kindle DX
FIX: New York Times Recipe

I've updated the New York Times recipe to resolve the issue from my previous post of occasionally missing articles. The problem was in the postprocess_html function, when a minor formatting problem causes the whole article to not be included. I've included the updated procedure, recipe, and explanation below (this may be happening in other recipes as well).

The caption of one of the photos has a paragraph within a paragraph:


<p class="caption"><p><em>“There’s no doubt in my mind that the whole trial will be about did he know right from wrong.”</em><strong> CLARENCE DUPNIK</strong> Pima County sheriff</p> </p>

The postprocess procedure thinks there are two paragraphs, and the second paragraph is empty. Thus, the variable caption.contents[0] throws an index out of range error.

for caption in soup.findAll(True, {'class':'caption'}) :
if caption and caption.contents[0]:

The first fix was just to change caption.contents[0] to len(caption) > 0. The second fix is that I added TRY / EXCEPT blocks to every minor change this procedure makes so that in the event there are small inconsistencies that would cause an article to not be included, the errors are logged but the article is still included.
Attached Files
File Type: txt updated nytimes postprocess_html.txt (3.8 KB, 111 views)
File Type: zip nytimes_sub.zip (7.5 KB, 97 views)

Last edited by bcollier; 01-17-2011 at 01:52 PM.
bcollier is offline   Reply With Quote
Old 08-25-2011, 10:57 AM   #2
4diamis
sasa925
4diamis began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Aug 2011
Location: Israel
Device: kindle 2G
could you please explain briefly how to use this link?
4diamis is offline   Reply With Quote
 
Enthusiast
Old 08-25-2011, 11:31 AM   #3
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 4diamis View Post
could you please explain briefly how to use this link?
Download the zip file, extract the recipe, read the sticky post above for information on how to use a recipe file obtained here.
Starson17 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Updated New York Times recipe nickredding Recipes 2 11-20-2010 10:53 AM
New York Times recipe broken? gianfri Calibre 1 03-20-2010 09:52 AM
New York Times recipe madrone26 Calibre 4 04-02-2009 01:13 PM
New York Times on 505 Hamza Sony Reader 21 03-03-2008 12:55 PM
iLiad New York Times King Mook Mook iRex 0 12-30-2007 03:22 PM


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


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