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

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-30 12:49:41 UTC
  • mfrom: (1.3.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090730124941-qjdsmri25zt8zocn
Tags: 0.6.3+dfsg-0ubuntu1
* New upstream release. Please see http://calibre.kovidgoyal.net/new_in_6/
  for the list of new features and changes.
* remove_postinstall.patch: Update for new version.
* build_debug.patch: Does not apply any more, disable for now. Might not be
  necessary any more.
* debian/copyright: Fix reference to versionless GPL.
* debian/rules: Drop obsolete dh_desktop call.
* debian/rules: Add workaround for weird Python 2.6 setuptools behaviour of
  putting compiled .so files into src/calibre/plugins/calibre/plugins
  instead of src/calibre/plugins.
* debian/rules: Drop hal fdi moving, new upstream version does not use hal
  any more. Drop hal dependency, too.
* debian/rules: Install udev rules into /lib/udev/rules.d.
* Add debian/calibre.preinst: Remove unmodified
  /etc/udev/rules.d/95-calibre.rules on upgrade.
* debian/control: Bump Python dependencies to 2.6, since upstream needs
  it now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env  python
 
2
# -*- coding: utf-8 -*-
 
3
 
 
4
__license__   = 'GPL v3'
 
5
__copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
 
6
'''
 
7
www.lavanguardia.es
 
8
'''
 
9
 
 
10
from calibre.web.feeds.news import BasicNewsRecipe
 
11
from calibre.ebooks.BeautifulSoup import Tag
 
12
 
 
13
class LaVanguardia(BasicNewsRecipe):
 
14
    title                 = 'La Vanguardia Digital'
 
15
    __author__            = 'Darko Miletic'
 
16
    description           = u'Noticias desde España'
 
17
    publisher             = 'La Vanguardia'
 
18
    category              = 'news, politics, Spain'
 
19
    oldest_article        = 2
 
20
    max_articles_per_feed = 100
 
21
    no_stylesheets        = True
 
22
    use_embedded_content  = False
 
23
    delay                 = 1
 
24
    encoding              = 'cp1252'
 
25
    language              = _('Spanish')
 
26
    direction             = 'ltr'
 
27
 
 
28
    html2lrf_options = [
 
29
                          '--comment'  , description
 
30
                        , '--category' , category
 
31
                        , '--publisher', publisher
 
32
                        ]
 
33
 
 
34
    html2epub_options  = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"'
 
35
 
 
36
    feeds              = [
 
37
                            (u'Ciudadanos'           , u'http://feeds.feedburner.com/lavanguardia/ciudadanos'   )
 
38
                           ,(u'Cultura'              , u'http://feeds.feedburner.com/lavanguardia/cultura'      )
 
39
                           ,(u'Deportes'             , u'http://feeds.feedburner.com/lavanguardia/deportes'     )
 
40
                           ,(u'Economia'             , u'http://feeds.feedburner.com/lavanguardia/economia'     )
 
41
                           ,(u'El lector opina'      , u'http://feeds.feedburner.com/lavanguardia/lectoropina'  )
 
42
                           ,(u'Gente y TV'           , u'http://feeds.feedburner.com/lavanguardia/gente'        )
 
43
                           ,(u'Internacional'        , u'http://feeds.feedburner.com/lavanguardia/internacional')
 
44
                           ,(u'Internet y tecnologia', u'http://feeds.feedburner.com/lavanguardia/internet'     )
 
45
                           ,(u'Motor'                , u'http://feeds.feedburner.com/lavanguardia/motor'        )
 
46
                           ,(u'Politica'             , u'http://feeds.feedburner.com/lavanguardia/politica'     )
 
47
                           ,(u'Sucessos'             , u'http://feeds.feedburner.com/lavanguardia/sucesos'      )
 
48
                         ]
 
49
 
 
50
 
 
51
    keep_only_tags = [
 
52
                       dict(name='div', attrs={'class':'element1_3'})
 
53
                     ]
 
54
 
 
55
    remove_tags        = [
 
56
                             dict(name=['object','link','script'])
 
57
                            ,dict(name='div', attrs={'class':['colC','peu']})
 
58
                         ]
 
59
 
 
60
    remove_tags_after = [dict(name='div', attrs={'class':'text'})]
 
61
 
 
62
    def preprocess_html(self, soup):
 
63
        soup.html['dir' ] = self.direction
 
64
        mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=utf-8")])
 
65
        soup.head.insert(0,mcharset)
 
66
        for item in soup.findAll(style=True):
 
67
            del item['style']
 
68
        return soup
 
69