diff --git a/recipes/attac_es.recipe b/recipes/attac_es.recipe index 6ff67efbdd..e57d321423 100644 --- a/recipes/attac_es.recipe +++ b/recipes/attac_es.recipe @@ -1,7 +1,6 @@ # vim:fileencoding=utf-8 from __future__ import unicode_literals from calibre.web.feeds.news import BasicNewsRecipe -import urllib class AttacEspanaRecipe (BasicNewsRecipe): __author__ = 'Marc Busqué ' @@ -17,7 +16,14 @@ class AttacEspanaRecipe (BasicNewsRecipe): oldest_article = 7 remove_empty_feeds = True no_stylesheets = True - extra_css = urllib.urlopen('https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '') + + def get_extra_css(self): + if not self.extra_css: + br = self.get_browser() + self.extra_css = br.open_novisit( + 'https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '') + return self.extra_css + cover_url = u'http://www.attac.es/wp-content/themes/attacweb/images/attaces.jpg' feeds = [ diff --git a/recipes/grandes_corresponsales_es.recipe b/recipes/grandes_corresponsales_es.recipe index 8b7e8f670c..5ce2ad71ba 100644 --- a/recipes/grandes_corresponsales_es.recipe +++ b/recipes/grandes_corresponsales_es.recipe @@ -1,7 +1,6 @@ # vim:fileencoding=utf-8 from __future__ import unicode_literals from calibre.web.feeds.news import BasicNewsRecipe -import urllib class GrandesCorresponsalesRecipe (BasicNewsRecipe): __author__ = 'Marc Busqué ' @@ -16,7 +15,13 @@ class GrandesCorresponsalesRecipe (BasicNewsRecipe): oldest_article = 30 remove_empty_feeds = True no_stylesheets = True - extra_css = urllib.urlopen('https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '') + + def get_extra_css(self): + if not self.extra_css: + br = self.get_browser() + self.extra_css = br.open_novisit( + 'https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '') + return self.extra_css feeds = [ (u'Rafael Poch', u'http://blogs.lavanguardia.com/berlin/feed'), diff --git a/recipes/historias_del_mundo_es.recipe b/recipes/historias_del_mundo_es.recipe index ee75cda891..5cc2fb3022 100644 --- a/recipes/historias_del_mundo_es.recipe +++ b/recipes/historias_del_mundo_es.recipe @@ -1,7 +1,6 @@ # vim:fileencoding=utf-8 from __future__ import unicode_literals from calibre.web.feeds.news import BasicNewsRecipe -import urllib class HistoriasDelMundo (BasicNewsRecipe): __author__ = 'Marc Busqué ' @@ -18,7 +17,13 @@ class HistoriasDelMundo (BasicNewsRecipe): remove_empty_feeds = True no_stylesheets = True cover_url = u'http://www.marcbusque.org/wp-content/uploads/2011/12/cuchitril.png' - extra_css = urllib.urlopen('https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '') + + def get_extra_css(self): + if not self.extra_css: + br = self.get_browser() + self.extra_css = br.open_novisit( + 'https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '') + return self.extra_css feeds = [ (u'Historias del Mundo', u'http://www.marcbusque.org/?feed=rss'), diff --git a/recipes/histories_del_mon_ca.recipe b/recipes/histories_del_mon_ca.recipe index 2766e70cb8..f3f682ddc8 100644 --- a/recipes/histories_del_mon_ca.recipe +++ b/recipes/histories_del_mon_ca.recipe @@ -1,7 +1,6 @@ # vim:fileencoding=utf-8 from __future__ import unicode_literals from calibre.web.feeds.news import BasicNewsRecipe -import urllib class HistoriesDelMon (BasicNewsRecipe): __author__ = 'Marc Busqué ' @@ -18,7 +17,13 @@ class HistoriesDelMon (BasicNewsRecipe): remove_empty_feeds = True no_stylesheets = True cover_url = u'http://www.marcbusque.org/wp-content/uploads/2011/12/cuchitril.png' - extra_css = urllib.urlopen('https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '') + + def get_extra_css(self): + if not self.extra_css: + br = self.get_browser() + self.extra_css = br.open_novisit( + 'https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '') + return self.extra_css feeds = [ (u'Històries del Món', u'http://www.marcbusque.org/ca/feed/'), diff --git a/recipes/lavanguardia_corresponsales_es.recipe b/recipes/lavanguardia_corresponsales_es.recipe index 44ef8bae00..d2c9708c8c 100644 --- a/recipes/lavanguardia_corresponsales_es.recipe +++ b/recipes/lavanguardia_corresponsales_es.recipe @@ -1,7 +1,6 @@ # vim:fileencoding=utf-8 from __future__ import unicode_literals from calibre.web.feeds.news import BasicNewsRecipe -import urllib class LaVanguardiaCorresponsalesRecipe (BasicNewsRecipe): __author__ = 'Marc Busqué ' @@ -17,7 +16,13 @@ class LaVanguardiaCorresponsalesRecipe (BasicNewsRecipe): oldest_article = 30 remove_empty_feeds = True no_stylesheets = True - extra_css = urllib.urlopen('https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '') + + def get_extra_css(self): + if not self.extra_css: + br = self.get_browser() + self.extra_css = br.open_novisit( + 'https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '') + return self.extra_css feeds = [ (u'Marc Bassets - Diario de Washington', u'http://blogs.lavanguardia.com/washington/feed'), diff --git a/recipes/list_apart.recipe b/recipes/list_apart.recipe index 071d92b426..03be607142 100644 --- a/recipes/list_apart.recipe +++ b/recipes/list_apart.recipe @@ -2,7 +2,6 @@ from __future__ import unicode_literals from calibre.web.feeds.news import BasicNewsRecipe import re -import urllib class AListApart (BasicNewsRecipe): __author__ = 'Marc Busqué ' @@ -18,7 +17,13 @@ class AListApart (BasicNewsRecipe): remove_empty_feeds = True encoding = 'utf8' cover_url = u'http://alistapart.com/pix/alalogo.gif' - extra_css = urllib.urlopen('https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '') + + def get_extra_css(self): + if not self.extra_css: + br = self.get_browser() + self.extra_css = br.open_novisit( + 'https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '') + return self.extra_css feeds = [ (u'A List Apart', u'http://feeds.feedburner.com/alistapart/abridged'), diff --git a/recipes/periodismo_humano_es.recipe b/recipes/periodismo_humano_es.recipe index ffd70bf51f..7817da9236 100644 --- a/recipes/periodismo_humano_es.recipe +++ b/recipes/periodismo_humano_es.recipe @@ -1,7 +1,6 @@ # vim:fileencoding=utf-8 from __future__ import unicode_literals from calibre.web.feeds.news import BasicNewsRecipe -import urllib class PeriodismoHumanoRecipe (BasicNewsRecipe): __author__ = 'Marc Busqué ' @@ -16,7 +15,13 @@ class PeriodismoHumanoRecipe (BasicNewsRecipe): language = u'es' tags = u'información, contrainformación, información alternativa' remove_empty_feeds = True - extra_css = urllib.urlopen('https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '') + + def get_extra_css(self): + if not self.extra_css: + br = self.get_browser() + self.extra_css = br.open_novisit( + 'https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '') + return self.extra_css feeds = [ (u'Periodismo Humano', u'http://periodismohumano.com/feed'), diff --git a/recipes/smashing.recipe b/recipes/smashing.recipe index d242dd1f9a..71741a0d99 100644 --- a/recipes/smashing.recipe +++ b/recipes/smashing.recipe @@ -1,7 +1,6 @@ # vim:fileencoding=utf-8 from __future__ import unicode_literals from calibre.web.feeds.news import BasicNewsRecipe -import urllib class SmashingMagazine (BasicNewsRecipe): __author__ = 'Marc Busqué ' @@ -19,7 +18,13 @@ class SmashingMagazine (BasicNewsRecipe): encoding = 'utf8' cover_url = u'http://media.smashingmagazine.com/themes/smashingv4/images/logo.png' remove_attributes = ['border', 'cellspacing', 'align', 'cellpadding', 'colspan', 'valign', 'vspace', 'hspace', 'alt', 'width', 'height', 'style'] - extra_css = urllib.urlopen('https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '') + + def get_extra_css(self): + if not self.extra_css: + br = self.get_browser() + self.extra_css = br.open_novisit( + 'https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '') + return self.extra_css feeds = [ (u'Smashing Magazine', u'http://rss1.smashingmagazine.com/feed/'), diff --git a/src/calibre/web/feeds/news.py b/src/calibre/web/feeds/news.py index 36123ec4a8..2573f85114 100644 --- a/src/calibre/web/feeds/news.py +++ b/src/calibre/web/feeds/news.py @@ -162,6 +162,8 @@ class BasicNewsRecipe(Recipe): #: It will be inserted into `'%( - self.template_css +'\n\n'+(self.extra_css if self.extra_css else ''))).find('style') + self.template_css +'\n\n'+(self.get_extra_css() or ''))).find('style') head.insert(len(head.contents), style) if first_fetch and job_info: url, f, a, feed_len = job_info @@ -942,7 +951,7 @@ class BasicNewsRecipe(Recipe): not self.has_single_feed, url, __appname__, center=self.center_navbar, - extra_css=self.extra_css) + extra_css=self.get_extra_css() or '') elem = BeautifulSoup(templ.render(doctype='xhtml').decode('utf-8')).find('div') body.insert(0, elem) if self.remove_javascript: @@ -1021,7 +1030,7 @@ class BasicNewsRecipe(Recipe): templ = (templates.TouchscreenIndexTemplate if self.touchscreen else templates.IndexTemplate) templ = templ(lang=self.lang_for_html) - css = self.template_css + '\n\n' +(self.extra_css if self.extra_css else '') + css = self.template_css + '\n\n' +(self.get_extra_css() or '') timefmt = self.timefmt return templ.generate(self.title, "mastheadImage.jpg", timefmt, feeds, extra_css=css).render(doctype='xhtml') @@ -1076,7 +1085,7 @@ class BasicNewsRecipe(Recipe): templ = (templates.TouchscreenFeedTemplate if self.touchscreen else templates.FeedTemplate) templ = templ(lang=self.lang_for_html) - css = self.template_css + '\n\n' +(self.extra_css if self.extra_css else '') + css = self.template_css + '\n\n' +(self.get_extra_css() or '') return templ.generate(f, feeds, self.description_limiter, extra_css=css).render(doctype='xhtml')