| 1 |
# -*- mode: python -*- |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
|
| 4 |
__license__ = 'GPL v3' |
| 5 |
__copyright__ = '2008-2018, Darko Miletic <darko.miletic at gmail.com>' |
| 6 |
''' |
| 7 |
danas.rs |
| 8 |
''' |
| 9 |
|
| 10 |
from datetime import date |
| 11 |
|
| 12 |
from calibre.web.feeds.news import BasicNewsRecipe |
| 13 |
|
| 14 |
|
| 15 |
class Danas(BasicNewsRecipe): |
| 16 |
title = 'Danas' |
| 17 |
__author__ = 'Darko Miletic' |
| 18 |
description = 'Dnevne novine sa vestima iz sveta, politike, ekonomije, kulture, sporta, Beograda, Novog Sada i cele Srbije.' |
| 19 |
publisher = 'DAN GRAF d.o.o.' |
| 20 |
category = 'danas Dnevne novine politika drustvo ekonomija svet sport beograd vojvodina periskop terazije Beograd Srbija Novi Sad Nis Kragujevac Vojvodina politics Serbia' # noqa: E501 |
| 21 |
oldest_article = 2 |
| 22 |
max_articles_per_feed = 100 |
| 23 |
no_stylesheets = False |
| 24 |
use_embedded_content = False |
| 25 |
encoding = 'utf-8' |
| 26 |
masthead_url = 'https://www.danas.rs/wp-content/themes/danas/assets/public/images/danas-logo.png' |
| 27 |
language = 'sr' |
| 28 |
remove_javascript = True |
| 29 |
publication_type = 'newspaper' |
| 30 |
remove_empty_feeds = True |
| 31 |
auto_cleanup = True |
| 32 |
auto_cleanup_keep = '//div[@class="post-intro-above"] //h1[@class="post-title"] | //div[@class="post-intro-title"] | //div[@class="post-meta-wrapper"]' |
| 33 |
resolve_internal_links = True |
| 34 |
extra_css = ''' |
| 35 |
.author{font-size: small} |
| 36 |
.published {font-size: small} |
| 37 |
img{margin-bottom: 0.8em} |
| 38 |
''' |
| 39 |
|
| 40 |
conversion_options = {'comment': description, 'tags': category, 'publisher': publisher, 'language': language} |
| 41 |
|
| 42 |
feeds = [ |
| 43 |
('Politika', 'https://www.danas.rs/rubrika/politika/feed/'), |
| 44 |
('Drustvo', 'https://www.danas.rs/rubrika/drustvo/feed/'), |
| 45 |
('Dijalog', 'https://www.danas.rs/rubrika/dijalog/feed/'), |
| 46 |
('Ekonomija', 'https://www.danas.rs/rubrika/ekonomija/feed/'), |
| 47 |
('Svet', 'https://www.danas.rs/rubrika/svet/feed/'), |
| 48 |
('Sport', 'https://www.danas.rs/rubrika/sport/feed/'), |
| 49 |
('Kultura', 'https://www.danas.rs/rubrika/kultura/feed/'), |
| 50 |
('Scena', 'https://www.danas.rs/rubrika/scena/feed/'), |
| 51 |
('Zivot', 'https://www.danas.rs/rubrika/zivot/feed/'), |
| 52 |
('Auto', 'https://www.danas.rs/rubrika/auto/feed/'), |
| 53 |
('IT', 'https://www.danas.rs/rubrika/tehnologije/feed/'), |
| 54 |
('Ljudi', 'https://www.danas.rs/rubrika/ljudi/feed/'), |
| 55 |
('Beograd', 'https://www.danas.rs/rubrika/beograd/feed/'), |
| 56 |
('Famozno', 'https://www.danas.rs/kolumnista/svetislav-basara/feed/'), |
| 57 |
] |
| 58 |
|
| 59 |
def get_cover_url(self): |
| 60 |
months = ['januar', 'februar', 'mart', 'april', 'maj', 'jun', 'jul', 'avgust', 'septembar', 'oktobar', 'novembar', 'decembar'] |
| 61 |
td = date.today() |
| 62 |
monthname = months[td.month - 1] |
| 63 |
lurl = td.strftime('https://www.danas.rs/naslovna/naslovna-strana-za-%d-' + monthname + '-%Y/') |
| 64 |
soup = self.index_to_soup(lurl) |
| 65 |
al = soup.find('div', attrs={'class': 'corax-image'}) |
| 66 |
if al and al.img: |
| 67 |
return al.img['src'] |
| 68 |
return None |