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 11-27-2014, 04:23 AM   #1
cyttorak
Member
cyttorak began at the beginning.
 
Posts: 18
Karma: 10
Join Date: Nov 2014
Device: Kobo Mini
Question Rewrite title from each article

Hi

How can I do that my recipe change the title of each feed?

For example, the original title of the feeds are: http://ganemosmadrid.info/category/a...minismos/feed/

3er. ACTA REUNION GANEMOS FEMINISMOS MADRID
1er ACTA REUNIÓN-GANEMOS FEMINISMO_MADRID
4ª ACTA REUNION GANEMOS FENIMISMOS MADRID
2o. ACTA REUNIÓN GANEMOS FEMINISMO MADRID

And I want to change it for:

3º Acta Ganemos Feminismos
1º Acta Ganemos Feminismos
4º Acta Ganemos Feminismos
2º Acta Ganemos Feminismos

So I gues I need a function that get the original title to be able to check it with regular expressions, modification it and return the new title, but I don't find this function.

Any help?

Thanks
cyttorak is offline   Reply With Quote
Old 11-28-2014, 06:29 PM   #2
cyttorak
Member
cyttorak began at the beginning.
 
Posts: 18
Karma: 10
Join Date: Nov 2014
Device: Kobo Mini
Question

Finally I do it work with:

Code:
	def parse_feeds (self):
		r = re.compile(u'^(\d+)(er\.?|o\.?|a\.|º|ª) (.*ACTA.*FE[MN]I[MN]ISMO.*)$', re.IGNORECASE|re.UNICODE)
		feeds = BasicNewsRecipe.parse_feeds(self)
		for f in feeds:
			for a,c in enumerate(f.articles):
				c.title=r.sub('\\1ª Acta Ganemos Feminismos',c.title)
		return feeds
is it a elegant solution? or is there a better way?
cyttorak is offline   Reply With Quote
Advert
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Preventing Page Title from Being Inserted into Article Text buffaloseven Recipes 0 07-25-2013 11:39 PM
KT -- complete rewrite? tlc Kindle Developer's Corner 2 11-30-2011 10:29 AM
Can't extract article title in parse index hiperlink Recipes 19 01-18-2011 11:00 AM
Article tweak for title sort not working Manichean Calibre 2 10-04-2010 11:56 AM


All times are GMT -4. The time now is 01:51 AM.


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