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

« back to all changes in this revision

Viewing changes to src/calibre/web/feeds/recipes/recipe_newsweek_argentina.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
 
 
3
__license__   = 'GPL v3'
 
4
__copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
 
5
'''
 
6
elargentino.com
 
7
'''
 
8
 
 
9
from calibre.web.feeds.news import BasicNewsRecipe
 
10
from calibre.ebooks.BeautifulSoup import Tag
 
11
 
 
12
class Newsweek_Argentina(BasicNewsRecipe):
 
13
    title                 = 'NewsWeek Argentina'
 
14
    __author__            = 'Darko Miletic'
 
15
    description           = 'Revista dedicada a politica'
 
16
    publisher             = 'ElArgentino.com'
 
17
    category              = 'news, politics, world, Argentina'
 
18
    oldest_article        = 7
 
19
    max_articles_per_feed = 100
 
20
    no_stylesheets        = True
 
21
    use_embedded_content  = False
 
22
    encoding              = 'utf-8'
 
23
    language              = _('Spanish')
 
24
    lang                  = 'es-AR'
 
25
    direction             = 'ltr'
 
26
    INDEX                 = 'http://www.elargentino.com/medios/126/Newsweek.html'
 
27
    extra_css             = ' .titulo{font-size: x-large; font-weight: bold} .volantaImp{font-size: small; font-weight: bold} '
 
28
 
 
29
    html2lrf_options = [
 
30
                          '--comment'  , description
 
31
                        , '--category' , category
 
32
                        , '--publisher', publisher
 
33
                        ]
 
34
 
 
35
    html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"\noverride_css=" p {text-indent: 0cm; margin-top: 0em; margin-bottom: 0.5em} "'
 
36
 
 
37
    keep_only_tags = [dict(name='div', attrs={'class':'ContainerPop'})]
 
38
 
 
39
    remove_tags = [dict(name='link')]
 
40
 
 
41
    feeds = [(u'Articulos', u'http://www.elargentino.com/Highlights.aspx?ParentType=Section&ParentId=126&Content-Type=text/xml&ChannelDesc=Newsweek')]
 
42
 
 
43
    def print_version(self, url):
 
44
        main, sep, article_part = url.partition('/nota-')
 
45
        article_id, rsep, rrest = article_part.partition('-')
 
46
        return u'http://www.elargentino.com/Impresion.aspx?Id=' + article_id
 
47
 
 
48
    def preprocess_html(self, soup):
 
49
        for item in soup.findAll(style=True):
 
50
            del item['style']
 
51
        soup.html['lang'] = self.lang
 
52
        soup.html['dir' ] = self.direction
 
53
        mlang = Tag(soup,'meta',[("http-equiv","Content-Language"),("content",self.lang)])
 
54
        mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=utf-8")])
 
55
        soup.head.insert(0,mlang)
 
56
        soup.head.insert(1,mcharset)
 
57
        return soup
 
58
 
 
59
    def get_cover_url(self):
 
60
        cover_url = None
 
61
        soup = self.index_to_soup(self.INDEX)
 
62
        cover_item = soup.find('div',attrs={'class':'colder'})
 
63
        if cover_item:
 
64
           clean_url = self.image_url_processor(None,cover_item.div.img['src'])
 
65
           cover_url = 'http://www.elargentino.com' + clean_url + '&height=600'
 
66
        return cover_url
 
67
 
 
68
    def image_url_processor(self, baseurl, url):
 
69
        base, sep, rest = url.rpartition('?Id=')
 
70
        img, sep2, rrest = rest.partition('&')
 
71
        return base + sep + img