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 12-31-2011, 10:51 AM   #1
pietvo
Reader
pietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notes
 
pietvo's Avatar
 
Posts: 519
Karma: 24612
Join Date: Aug 2009
Location: Utrecht, NL
Device: Kobo Aura 2, iPhone, iPad
Is there a way to preprocess a feed XML

I am writing a recipe for a newspaper that mixes up encodings in its RSS feeds. Meaning that they use two encodings in one file: iso-8859-1 and utf-8. Calibre most of the time decodes the text correctly, but not always. I would like to preprocess the feeds and recode the iso-8859-1 parts to utf-8 before processing them (I think I know which parts have which encoding).

In calibre/src/calibre/web/feeds/news.py it says in parse_feeds:

parsed_feeds.append(feed_from_xml(f.read(),

Basically I would like to process between the read() and the feed_from_xml(). I could copy-paste parse_feeds to my recipe and change that, but IMHO that violates OO principles (DRY). The other way that I can think of is monkey-patching or subclassing the browser class and/or related classes but that probably is even uglier. Is there a better way? Or can I request this as a feature?
pietvo is offline   Reply With Quote
Old 12-31-2011, 12:34 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
One way to do it is to download the feeds yourself in the recipe, fix them, save them to temp files on disk and return the file:// url
kovidgoyal is offline   Reply With Quote
Reply

Tags
encoding, rss feed


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Preprocess cbz before sending to Kindle mhkey Conversion 3 07-02-2011 06:15 PM
xml epub yuxi_kelly ePub 4 05-13-2011 10:52 AM
Preprocess or Postprocess epub Conversion? robert_epub Calibre 1 03-20-2010 11:12 PM
Why xml?? real_yoni Sony Reader Dev Corner 1 01-20-2009 11:45 AM
PRS-500 Available XML commands johnmcelfresh Sony Reader Dev Corner 0 08-18-2007 01:55 PM


All times are GMT -4. The time now is 08:35 AM.


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