mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
72 lines
2.9 KiB
Plaintext
72 lines
2.9 KiB
Plaintext
__license__ = 'GPL v3'
|
|
__copyright__ = '2008-2013, Darko Miletic <darko.miletic at gmail.com>'
|
|
'''
|
|
politika.rs
|
|
'''
|
|
import re
|
|
from calibre.web.feeds.news import BasicNewsRecipe
|
|
|
|
|
|
class Politika(BasicNewsRecipe):
|
|
title = 'Politika Online'
|
|
__author__ = 'Darko Miletic'
|
|
description = 'Najstariji dnevni list na Balkanu'
|
|
publisher = 'Politika novine i Magazini d.o.o'
|
|
category = 'news, politics, Serbia'
|
|
oldest_article = 2
|
|
max_articles_per_feed = 100
|
|
no_stylesheets = True
|
|
use_embedded_content = False
|
|
encoding = 'utf8'
|
|
delay = 1
|
|
language = 'sr'
|
|
publication_type = 'newspaper'
|
|
masthead_url = 'http://static.politika.co.rs/images_new/politika2.gif'
|
|
extra_css = """
|
|
@font-face {font-family: "serif1";src:url(res:///opt/sony/ebook/FONT/tt0011m_.ttf)}
|
|
@font-face {font-family: "sans1";src:url(res:///opt/sony/ebook/FONT/tt0003m_.ttf)}
|
|
body{font-family: Arial,Helvetica,sans1,sans-serif}
|
|
h1{font-family: "Times New Roman",Times,serif1,serif}
|
|
.articledescription{font-family: sans1, sans-serif}
|
|
"""
|
|
|
|
conversion_options = {
|
|
'comment': description, 'tags': category, 'publisher': publisher, 'language': language
|
|
}
|
|
|
|
preprocess_regexps = [(re.compile(u'\u0110'), lambda match: u'\u00D0')]
|
|
|
|
keep_only_tags = [
|
|
dict(name='div', attrs={'class': 'big_article_home item_details'})]
|
|
remove_tags_after = dict(attrs={'class': 'online_date'})
|
|
remove_tags = [dict(name=['link', 'meta', 'iframe', 'embed', 'object'])]
|
|
|
|
feeds = [
|
|
|
|
(u'Politika', u'http://www.politika.rs/rubrike/Politika/index.1.lt.xml'),
|
|
(u'Svet', u'http://www.politika.rs/rubrike/Svet/index.1.lt.xml'),
|
|
(u'Ostali komentari', u'http://www.politika.rs/rubrike/ostali-komentari/index.1.lt.xml'),
|
|
(u'Pogledi', u'http://www.politika.rs/pogledi/index.lt.xml'),
|
|
(u'Pogledi sa strane', u'http://www.politika.rs/rubrike/Pogledi-sa-strane/index.1.lt.xml'),
|
|
(u'Tema dana', u'http://www.politika.rs/rubrike/tema-dana/index.1.lt.xml'),
|
|
(u'Kultura', u'http://www.politika.rs/rubrike/Kultura/index.1.lt.xml'),
|
|
(u'Spektar', u'http://www.politika.rs/rubrike/zivot-i-stil/index.1.lt.xml')
|
|
]
|
|
|
|
def preprocess_html(self, soup):
|
|
for item in soup.findAll(style=True):
|
|
del item['style']
|
|
for item in soup.findAll('a', attrs={'class': 'category'}):
|
|
item.name = 'span'
|
|
item['href'] = item['title'] = ''
|
|
del item['href']
|
|
del item['title']
|
|
return soup
|
|
|
|
def get_cover_url(self):
|
|
soup = self.index_to_soup('http://www.politika.rs/')
|
|
coverlink = soup.find('a', attrs={'class': 'home_print_img'})
|
|
if coverlink:
|
|
return coverlink['href']
|
|
return None
|