| 1 |
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai |
| 2 |
from __future__ import unicode_literals |
| 3 |
|
| 4 |
from calibre.web.feeds.recipes import BasicNewsRecipe |
| 5 |
|
| 6 |
|
| 7 |
class novinkyRecipe(BasicNewsRecipe): |
| 8 |
__author__ = 'bubak' |
| 9 |
title = 'novinky.cz' |
| 10 |
publisher = 'seznam.cz' |
| 11 |
description = 'novinky.cz' |
| 12 |
oldest_article = 1 |
| 13 |
max_articles_per_feed = 20 |
| 14 |
|
| 15 |
feeds = [ |
| 16 |
('Domácí', 'http://www.novinky.cz/rss2/domaci/'), |
| 17 |
('Praha', 'http://www.novinky.cz/rss2/vase-zpravy/praha/'), |
| 18 |
('Ekonomika', 'http://www.novinky.cz/rss2/ekonomika/'), |
| 19 |
('Finance', 'http://www.novinky.cz/rss2/finance/'), |
| 20 |
] |
| 21 |
|
| 22 |
language = 'cs' |
| 23 |
cover_url = 'http://www.novinky.cz/static/images/logo.gif' |
| 24 |
remove_javascript = True |
| 25 |
no_stylesheets = True |
| 26 |
|
| 27 |
remove_tags = [ |
| 28 |
dict(name='div', attrs={'id': ['pictureInnerBox']}), |
| 29 |
dict(name='div', attrs={'id': ['discussionEntry']}), |
| 30 |
dict(name='span', attrs={'id': ['mynews-hits', 'mynews-author']}), |
| 31 |
dict(name='div', attrs={'class': ['related']}), |
| 32 |
dict(name='div', attrs={'id': ['multimediaInfo']}), |
| 33 |
] |
| 34 |
remove_tags_before = dict(name='div', attrs={'class': ['articleHeader']}) |
| 35 |
remove_tags_after = dict(name='div', attrs={'class': 'related'}) |
| 36 |
|
| 37 |
keep_only_tags = [] |
| 38 |
|
| 39 |
# This source has identical articles under different links |
| 40 |
# which are redirected to the common url. I've found |
| 41 |
# just this API method that has the real URL |
| 42 |
visited_urls = {} |
| 43 |
|
| 44 |
def encoding(self, source): |
| 45 |
url = source.newurl |
| 46 |
if url in self.visited_urls: |
| 47 |
self.log.debug('Ignoring duplicate: ' + url) |
| 48 |
return None |
| 49 |
else: |
| 50 |
self.visited_urls[url] = True |
| 51 |
self.log.debug('Accepting: ' + url) |
| 52 |
return source.decode('utf-8', 'replace') |