View Single Post
Old 11-22-2012, 10:19 AM   #1
tylau0
Connoisseur
tylau0 began at the beginning.
 
Posts: 82
Karma: 10
Join Date: Oct 2010
Device: Kindle
New recipe - House News (主場新聞)

Could Kovid or other Calibre developer upload the following recipe to the next Calibre release? Thanks.

Code:
__license__   = 'GPL v3'
__copyright__ = '2012, Eddie Lau'
class AdvancedUserRecipeHouseNews(BasicNewsRecipe):
    title          = u'House News \u4e3b\u5834\u65b0\u805e'
    __author__     = 'Eddie Lau'
    publisher      = 'House News'
    oldest_article = 1
    max_articles_per_feed = 100
    auto_cleanup = False
    language = 'zh'
    encoding = 'utf-8'
    description = 'http://thehousenews.com'
    category    = 'Chinese, Blogs, Opinion, News, Hong Kong'
    masthead_url = 'http://thehousenews.com/static/images/housebeta.jpg'
    extra_css = 'img {display: block; margin-left: auto; margin-right: auto; margin-top: 10px; margin-bottom: 10px; max-height:90%;} p[class=date] {font-size:50%;} div[class=author] {font-size:75%;} p[class=caption] {font-size:50%;}'
    feeds          = [(u'Latest', u'http://thehousenews.com/rss/')]
    keep_only_tags = [dict(name='h1'),
                      dict(name='div', attrs={'class':['photo']}),
                      dict(name='p', attrs={'class':'caption'}),
                      dict(name='div', attrs={'class':'articleTextWrap'}),
                      dict(name='div', attrs={'class':['author']}),
                      dict(name='p', attrs={'class':'date'})]

    def populate_article_metadata(self, article, soup, first):
        if first and hasattr(self, 'add_toc_thumbnail'):
            picdiv = soup.find('img')
            if picdiv is not None:
                self.add_toc_thumbnail(article,picdiv['src'])
tylau0 is offline   Reply With Quote