View Single Post
Old 11-05-2012, 07:54 PM   #1
Frescard
Enthusiast
Frescard plays well with othersFrescard plays well with othersFrescard plays well with othersFrescard plays well with othersFrescard plays well with othersFrescard plays well with othersFrescard plays well with othersFrescard plays well with othersFrescard plays well with othersFrescard plays well with othersFrescard plays well with others
 
Posts: 29
Karma: 2910
Join Date: Aug 2012
Location: Montreal, Canada
Device: Sony PRS-T1
London Review of Books - fixed cover URL

The current recipe doesn't seem to download the cover page for the London Review of Books anymore.

Changing the URL to the code below should get you the cover back:

Code:
__license__   = 'GPL v3'
__copyright__ = '2008-2010, Darko Miletic <darko.miletic at gmail.com>'
'''
lrb.co.uk
'''

from calibre.web.feeds.news import BasicNewsRecipe

class LondonReviewOfBooks(BasicNewsRecipe):
    title                 = 'London Review of Books (free)'
    __author__            = 'Darko Miletic'
    description           = 'Literary review publishing essay-length book reviews and topical articles on politics, literature, history, philosophy, science and the arts by leading writers and thinkers'
    category              = 'News'
    publisher             = 'LRB ltd.'
    oldest_article        = 15
    max_articles_per_feed = 100
    language              = 'en_GB'
    no_stylesheets        = True
    use_embedded_content  = False
    encoding              = 'utf-8'
    publication_type      = 'magazine'
    masthead_url          = 'http://www.lrb.co.uk/assets/images/lrb_logo_big.gif'
    extra_css             = ' body{font-family: Georgia,Palatino,"Palatino Linotype",serif} '

    conversion_options = {
                             'comments'  : description
                            ,'tags'      : category
                            ,'language'  : language
                            ,'publisher' : publisher
                         }

    keep_only_tags = [dict(attrs={'class':['article-body indent','letters','article-list']})]
    remove_attributes = ['width','height']

    feeds = [(u'London Review of Books', u'http://www.lrb.co.uk/lrbrss.xml')]

    def get_cover_url(self):
        cover_url = None
        soup = self.index_to_soup('http://www.lrb.co.uk/')
        cover_item = soup.find('p',attrs={'class':'cover'})
        if cover_item:
           #old: 
           #cover_url = 'http://www.lrb.co.uk' + cover_item.a.img['src']
           #new:
           cover_url = cover_item.a.img['src']
        return cover_url
Frescard is offline   Reply With Quote