From a7cab66b6f851d27e23d1799eecc85c6769aeca7 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 14 Sep 2012 17:47:38 +0200 Subject: [PATCH] Tweak XKCD recipe: Add a masthead image, put the strip title in an h1 tag --- recipes/xkcd.recipe | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/recipes/xkcd.recipe b/recipes/xkcd.recipe index 42dceda65b..2aa704992e 100644 --- a/recipes/xkcd.recipe +++ b/recipes/xkcd.recipe @@ -2,6 +2,8 @@ __license__ = 'GPL v3' __copyright__ = '2008, Kovid Goyal ' ''' Changelog: +2012-04-06 +Fixed empty articles, added masthead img (NiLuJe) 2011-09-24 Changed cover (drMerry) ''' @@ -13,7 +15,8 @@ import time, re from calibre.web.feeds.news import BasicNewsRecipe class XkcdCom(BasicNewsRecipe): - cover_url = 'http://imgs.xkcd.com/s/9be30a7.png' + cover_url = 'http://imgs.xkcd.com/static/terrible_small_logo.png' + masthead_url = 'http://imgs.xkcd.com/static/terrible_small_logo.png' title = 'xkcd' description = 'A webcomic of romance and math humor.' __author__ = 'Martin Pitt updated by DrMerry.' @@ -21,13 +24,14 @@ class XkcdCom(BasicNewsRecipe): use_embedded_content = False oldest_article = 60 - keep_only_tags = [dict(id='middleContainer')] - remove_tags = [dict(name='ul'), dict(name='h3'), dict(name='br')] + #keep_only_tags = [dict(id='middleContainer')] + #remove_tags = [dict(name='ul'), dict(name='h3'), dict(name='br')] + keep_only_tags = [dict(id='comic')] no_stylesheets = True - # turn image bubblehelp into a paragraph + # turn image bubblehelp into a paragraph, and put alt in a heading preprocess_regexps = [ - (re.compile(r'()'), - lambda m: '%s%s

%s

' % (m.group(1), m.group(3), m.group(2))) + (re.compile(r'()'), + lambda m: '

%s

%s%s%s

%s

' % (m.group(4), m.group(1), m.group(3), m.group(5), m.group(2))) ] def parse_index(self):