~ubuntu-branches/ubuntu/karmic/calibre/karmic

« back to all changes in this revision

Viewing changes to src/calibre/web/feeds/recipes/recipe_hln.py

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-30 12:49:41 UTC
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: james.westby@ubuntu.com-20090730124941-kviipg9ypwgppulc
Tags: upstream-0.6.3+dfsg
ImportĀ upstreamĀ versionĀ 0.6.3+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env  python
 
2
 
 
3
__license__   = 'GPL v3'
 
4
__copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
 
5
'''
 
6
www.hln.be
 
7
'''
 
8
from calibre.web.feeds.news import BasicNewsRecipe
 
9
from calibre.ebooks.BeautifulSoup import Tag
 
10
 
 
11
class HLN_be(BasicNewsRecipe):
 
12
    title                 = 'Het Belang Van Limburg'
 
13
    __author__            = 'Darko Miletic'
 
14
    description           = 'News from Belgium in Dutch'
 
15
    publisher             = 'Het Belang Van Limburg'
 
16
    category              = 'news, politics, Belgium'
 
17
    oldest_article        = 2
 
18
    max_articles_per_feed = 100
 
19
    no_stylesheets        = True
 
20
    use_embedded_content  = False
 
21
    encoding              = 'utf-8'
 
22
    language              = _('Dutch')
 
23
    lang                  = 'nl-BE'
 
24
    direction             = 'ltr'
 
25
 
 
26
    html2lrf_options = [
 
27
                          '--comment'  , description
 
28
                        , '--category' , category
 
29
                        , '--publisher', publisher
 
30
                        ]
 
31
 
 
32
    html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"\noverride_css=" p {text-indent: 0cm; margin-top: 0em; margin-bottom: 0.5em} "'
 
33
 
 
34
    keep_only_tags = [dict(name='div', attrs={'class':'art_box2'})]
 
35
    remove_tags    = [
 
36
                         dict(name=['embed','object'])
 
37
                     ]
 
38
 
 
39
    feeds = [(u'Alle nieuws', u'http://www.hln.be/rss.xml')]
 
40
 
 
41
    def preprocess_html(self, soup):
 
42
        del soup.body['onload']
 
43
        for item in soup.findAll(style=True):
 
44
            del item['style']
 
45
        soup.html['lang']     = self.lang
 
46
        soup.html['dir' ]     = self.direction
 
47
        mlang = Tag(soup,'meta',[("http-equiv","Content-Language"),("content",self.lang)])
 
48
        mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=utf-8")])
 
49
        soup.head.insert(0,mlang)
 
50
        soup.head.insert(1,mcharset)
 
51
        return soup
 
52