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

« back to all changes in this revision

Viewing changes to src/calibre/web/feeds/recipes/recipe_theeconomictimes_india.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__ = '2008-2009, Darko Miletic <darko.miletic at gmail.com>'
 
5
'''
 
6
economictimes.indiatimes.com
 
7
'''
 
8
 
 
9
from calibre.web.feeds.news import BasicNewsRecipe
 
10
from calibre.ebooks.BeautifulSoup import BeautifulSoup, Tag
 
11
 
 
12
class TheEconomicTimes(BasicNewsRecipe):
 
13
    title                  = 'The Economic Times India'
 
14
    __author__             = 'Darko Miletic'
 
15
    description            = 'Financial news from India' 
 
16
    publisher              = 'economictimes.indiatimes.com'
 
17
    category               = 'news, finances, politics, India'        
 
18
    oldest_article         = 2
 
19
    max_articles_per_feed  = 100
 
20
    no_stylesheets         = True
 
21
    use_embedded_content   = False
 
22
    simultaneous_downloads = 1
 
23
    encoding               = 'utf-8'
 
24
    lang                   = 'en-IN'
 
25
    language               = _('English')
 
26
 
 
27
    html2lrf_options = [
 
28
                          '--comment', description
 
29
                        , '--category', category
 
30
                        , '--publisher', publisher
 
31
                        , '--ignore-tables'
 
32
                        ]
 
33
    
 
34
    html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"\nlinearize_tables=True' 
 
35
    
 
36
    feeds          = [(u'All articles', u'http://economictimes.indiatimes.com/rssfeedsdefault.cms')]
 
37
 
 
38
    def print_version(self, url):
 
39
        rest, sep, art = url.rpartition('/articleshow/')
 
40
        return 'http://economictimes.indiatimes.com/articleshow/' + art + '?prtpage=1'
 
41
 
 
42
    def get_article_url(self, article):
 
43
        rurl = article.get('link',  None)
 
44
        if (rurl.find('/quickieslist/') > 0) or (rurl.find('/quickiearticleshow/') > 0):
 
45
           return None
 
46
        return rurl
 
47
        
 
48
    def preprocess_html(self, soup):
 
49
        soup.html['xml:lang'] = self.lang
 
50
        soup.html['lang']     = self.lang
 
51
        mlang = Tag(soup,'meta',[("http-equiv","Content-Language"),("content",self.lang)])
 
52
        mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=utf-8")])
 
53
        soup.head.insert(0,mlang)
 
54
        soup.head.insert(1,mcharset)
 
55
        return self.adeify_images(soup)
 
56
        
 
 
b'\\ No newline at end of file'