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 03-11-2011, 01:02 PM   #1
TonyDeWonderful
Junior Member
TonyDeWonderful began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Mar 2011
Device: Kindle 3
Calibre rss recipe -- <em> tag in article titles?

This is my first time posting and I'm fairly new to writing recipes. I'm having a problem with a recipe that I'm using to download an rss feed to my Kindle3.

The recipe itself works fine except that the article titles sometimes contain <em> and </em> tags (for example, the article title on the Kindle and Calibre v. 0.7.48 will show "<em>Godzilla</em> vs. Real Life"). This was also occurring in the main title once you opened the article but I was able to remove that via "preprocess_html".

Since the "preprocess_html" did not affect the article title, can someone provide me some direction as to how to remove the <em> and </em> tags from the article title?

I've included the recipe that I'm using below.

Thanks!

recipe:

Code:
import re
from calibre.web.feeds.recipes import BasicNewsRecipe

class AdvancedUserRecipe1288623850(BasicNewsRecipe):
    title = u'Hit and Run Blog'
    oldest_article = 1 
    max_articles_per_feed = 100
    timefmt = ''
    encoding= 'cp1252'
    preprocess_regexps = [
                                  (re.compile(r"&lt;em&gt;"),lambda match: ''),
                                  (re.compile(r"&lt;/em&gt;"),lambda match: '')
                                  ]
    feeds = [(u'Hit and Run Blog',
'http://feeds.feedburner.com/reason/HitandRun')]
Moderator Notice
Code tags added.

Last edited by Starson17; 03-11-2011 at 02:04 PM.
TonyDeWonderful is offline   Reply With Quote
Old 03-11-2011, 02:03 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 TonyDeWonderful View Post
The recipe itself works fine except that the article titles sometimes contain <em> and </em> tags (for example, the article title on the Kindle and Calibre v. 0.7.48 will show "<em>Godzilla</em> vs. Real Life"). This was also occurring in the main title once you opened the article but I was able to remove that via "preprocess_html".

Since the "preprocess_html" did not affect the article title, can someone provide me some direction as to how to remove the <em> and </em> tags from the article title?
Use populate_article_metadata like this:

Code:
    def populate_article_metadata(self, article, soup, first):
       print "Pop article title is: ", article.title
       article.title = article.title
       return
Except, do a replace or whatever you want to the article.title
Quote:
I've included the recipe that I'm using below.
Use code tags in the future, it makes it easier to use your code (highlight and hit the pound/hash symbol to mark your code.

Last edited by Starson17; 03-11-2011 at 02:14 PM.
Starson17 is offline   Reply With Quote
Old 03-15-2011, 12:23 PM   #3
TonyDeWonderful
Junior Member
TonyDeWonderful began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Mar 2011
Device: Kindle 3
Thanks for the help! I have it working now.
TonyDeWonderful is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
RSS article - page 1 of N MarcinJunger Recipes 0 03-06-2011 04:50 PM
Recipe for a RSS with a Hodgepodge of Sources? spedinfargo Recipes 1 03-01-2011 09:28 AM
Changing article titles in recipes tbaac Recipes 8 12-22-2010 12:03 PM
Help with Recipe inserting tag TonytheBookworm Recipes 1 09-25-2010 11:05 AM
Downloading and Converting Print version of RSS article Daanish87 Calibre 1 06-11-2010 02:08 AM


All times are GMT -4. The time now is 07:24 PM.


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