mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update Danas
Fixes #1757439 [Updated recipe for Danas](https://bugs.launchpad.net/calibre/+bug/1757439)
This commit is contained in:
parent
2d2d66113d
commit
c172e54223
@ -8,7 +8,7 @@ danas.rs
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
from datetime import date, timedelta
|
from datetime import date
|
||||||
|
|
||||||
|
|
||||||
class Danas(BasicNewsRecipe):
|
class Danas(BasicNewsRecipe):
|
||||||
@ -22,15 +22,14 @@ class Danas(BasicNewsRecipe):
|
|||||||
no_stylesheets = False
|
no_stylesheets = False
|
||||||
use_embedded_content = False
|
use_embedded_content = False
|
||||||
encoding = 'utf-8'
|
encoding = 'utf-8'
|
||||||
masthead_url = 'http://www.danas.rs/images/basic/logo.png'
|
masthead_url = 'https://www.danas.rs/wp-content/themes/danas/assets/public/images/danas-logo.png'
|
||||||
language = 'sr'
|
language = 'sr'
|
||||||
remove_javascript = True
|
remove_javascript = True
|
||||||
publication_type = 'newspaper'
|
publication_type = 'newspaper'
|
||||||
remove_empty_feeds = True
|
remove_empty_feeds = True
|
||||||
auto_cleanup = True
|
auto_cleanup = True
|
||||||
auto_cleanup_keep = '//h1[@class="title"] | //div[@class="subTitle"] | //div[@class="author"] | //div[@class="published"]'
|
auto_cleanup_keep = '//div[@class="post-intro-above"] //h1[@class="post-title"] | //div[@class="post-intro-title"] | //div[@class="post-meta-wrapper"]'
|
||||||
resolve_internal_links = True
|
resolve_internal_links = True
|
||||||
INDEX = "http://www.danas.rs"
|
|
||||||
extra_css = """
|
extra_css = """
|
||||||
.author{font-size: small}
|
.author{font-size: small}
|
||||||
.published {font-size: small}
|
.published {font-size: small}
|
||||||
@ -45,58 +44,30 @@ class Danas(BasicNewsRecipe):
|
|||||||
}
|
}
|
||||||
|
|
||||||
feeds = [
|
feeds = [
|
||||||
(u'Politika', u'http://www.danas.rs/politika.56.html'),
|
(u'Politika', u'https://www.danas.rs/rubrika/politika/feed/'),
|
||||||
(u'Drustvo', u'http://www.danas.rs/drustvo.55.html'),
|
(u'Drustvo', u'https://www.danas.rs/rubrika/drustvo/feed/'),
|
||||||
(u'Dijalog', u'http://www.danas.rs/dijalog.46.html'),
|
(u'Dijalog', u'https://www.danas.rs/rubrika/dijalog/feed/'),
|
||||||
(u'Drustvo', u'http://www.danas.rs/drustvo.55.html'),
|
(u'Ekonomija', u'https://www.danas.rs/rubrika/ekonomija/feed/'),
|
||||||
(u'Ekonomija', u'http://www.danas.rs/ekonomija.4.html'),
|
(u'Svet', u'https://www.danas.rs/rubrika/svet/feed/'),
|
||||||
(u'Svet', u'http://www.danas.rs/svet.1160.html'),
|
(u'Sport', u'https://www.danas.rs/rubrika/sport/feed/'),
|
||||||
(u'Sport', u'http://www.danas.rs/sport.18.html'),
|
(u'Kultura', u'https://www.danas.rs/rubrika/kultura/feed/'),
|
||||||
(u'Kultura', u'http://www.danas.rs/kultura.11.html'),
|
(u'Scena', u'https://www.danas.rs/rubrika/scena/feed/'),
|
||||||
(u'Scena', u'http://www.danas.rs/scena.561.html'),
|
(u'Zivot', u'https://www.danas.rs/rubrika/zivot/feed/'),
|
||||||
(u'Zivot', u'http://www.danas.rs/zivot.1140.html'),
|
(u'Auto', u'https://www.danas.rs/rubrika/auto/feed/'),
|
||||||
(u'Auto', u'http://www.danas.rs/auto.1171.html'),
|
(u'IT', u'https://www.danas.rs/rubrika/tehnologije/feed/'),
|
||||||
(u'IT', u'http://www.danas.rs/it.29.html'),
|
(u'Ljudi', u'https://www.danas.rs/rubrika/ljudi/feed/'),
|
||||||
(u'Ljudi', u'http://www.danas.rs/ljudi.1141.html'),
|
(u'Beograd', u'https://www.danas.rs/rubrika/beograd/feed/'),
|
||||||
(u'Beograd', u'http://www.danas.rs/beograd.39.html'),
|
(u'Famozno', u'https://www.danas.rs/kolumnista/svetislav-basara/feed/'),
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_cover_url(self):
|
def get_cover_url(self):
|
||||||
td = date.today() - timedelta(1)
|
months = ['januar', 'februar', 'mart', 'april', 'maj', 'jun', 'jul',
|
||||||
cpart = str(td.year) + '/' + str(td.month) + '/' + str(td.day)
|
'avgust', 'septembar', 'oktobar', 'novembar', 'decembar']
|
||||||
return 'http://www.danas.rs/upload/images/' + cpart + '/Naslovna_velika.jpg'
|
td = date.today()
|
||||||
|
monthname = months[td.month - 1]
|
||||||
def parse_index(self):
|
lurl = td.strftime("https://www.danas.rs/naslovna/naslovna-strana-za-%d-" + monthname + "-%Y/")
|
||||||
totalfeeds = []
|
soup = self.index_to_soup(lurl)
|
||||||
lfeeds = self.get_feeds()
|
al = soup.find('div', attrs={'class':'corax-image'})
|
||||||
for feedobj in lfeeds:
|
if al and al.img:
|
||||||
feedtitle, feedurl = feedobj
|
return al.img['src']
|
||||||
self.report_progress(
|
return None
|
||||||
0,
|
|
||||||
_('Fetching feed') + ' %s...' %
|
|
||||||
(feedtitle if feedtitle else feedurl)
|
|
||||||
)
|
|
||||||
articles = []
|
|
||||||
soup = self.index_to_soup(feedurl)
|
|
||||||
for item in soup.findAll(
|
|
||||||
'div', attrs={
|
|
||||||
'class': lambda x: x and 'newsBox' in x.split()
|
|
||||||
}
|
|
||||||
):
|
|
||||||
atag = item.find('h2').a
|
|
||||||
ptag = item.find('p', attrs={'class': 'lead'})
|
|
||||||
artdate = item.find('div', attrs={'class': 'date'})
|
|
||||||
url = self.INDEX + atag['href']
|
|
||||||
title = self.tag_to_string(atag)
|
|
||||||
description = ''
|
|
||||||
if ptag:
|
|
||||||
description = self.tag_to_string(ptag)
|
|
||||||
date = self.tag_to_string(artdate)
|
|
||||||
articles.append({
|
|
||||||
'title': title,
|
|
||||||
'date': date,
|
|
||||||
'url': url,
|
|
||||||
'description': description
|
|
||||||
})
|
|
||||||
totalfeeds.append((feedtitle, articles))
|
|
||||||
return totalfeeds
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user