mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update .týždeň recipe
This commit is contained in:
parent
db6243dfff
commit
25cfde2945
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=utf-8
|
# vim:fileencoding=utf-8
|
||||||
#
|
#
|
||||||
# Copyright 2014 - 2016 Martin Račák <rakyi@riseup.net>
|
# Copyright 2014 - 2017 Martin Račák <rakyi@riseup.net>
|
||||||
# Copyright 2011 Miroslav Vasko <zemiak@gmail.com>
|
# Copyright 2011 Miroslav Vasko <zemiak@gmail.com>
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
@ -18,12 +18,10 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = ('2014 - 2015 Martin Račák <martin.racak@riseup.net>,'
|
__copyright__ = ('2014 - 2017 Martin Račák <martin.racak@riseup.net>,'
|
||||||
'2011 Miroslav Vasko <zemiak@gmail.com>')
|
'2011 Miroslav Vasko <zemiak@gmail.com>')
|
||||||
|
|
||||||
'''
|
import re
|
||||||
.týždeň - iný pohľad na spoločnosť
|
|
||||||
'''
|
|
||||||
|
|
||||||
from calibre import strftime
|
from calibre import strftime
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
@ -39,102 +37,90 @@ class Tyzden(BasicNewsRecipe):
|
|||||||
needs_subscription = 'optional'
|
needs_subscription = 'optional'
|
||||||
use_embedded_content = False
|
use_embedded_content = False
|
||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
base_url = 'http://www.tyzden.sk'
|
issue_url = 'http://www.tyzden.sk/casopis/'
|
||||||
piano_param = '?piano_d=1'
|
|
||||||
issue_url = base_url + '/casopis/'
|
|
||||||
keep_only_tags = [
|
keep_only_tags = [
|
||||||
dict(name='div', attrs={'class': 'detail__title article__title'}),
|
dict(name='div', attrs={'class': 'section__content section__content--archive'}),
|
||||||
dict(name='div', attrs={'class': 'article'}),
|
dict(name='article', attrs={'class': re.compile(r'\barticle\b')}),
|
||||||
]
|
]
|
||||||
extra_css = """*, *::before, *::after {
|
|
||||||
-moz-box-sizing: border-box;
|
extra_css = """.theme-highlight {
|
||||||
-webkit-box-sizing: border-box;
|
color: #999;
|
||||||
box-sizing: border-box;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.detail__content h2::before {
|
.author-highlight {
|
||||||
color: #000;
|
color: #bf1f10;
|
||||||
content: ".";
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article__content h2::before {
|
||||||
|
content: '.';
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
.highlight {
|
.article__image-credit {
|
||||||
color: #bf1f10;
|
font: 12px "TheSerifSemiLight",arial;
|
||||||
}
|
|
||||||
|
|
||||||
.content-photo__image-credit,
|
|
||||||
.photo__image-credit {
|
|
||||||
font-size: 11px;
|
|
||||||
font-family: 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
|
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
}
|
}
|
||||||
|
|
||||||
.image-title {
|
.article__image-title {
|
||||||
border-bottom: 3px solid #bf1f10;
|
padding-top: 2px;
|
||||||
display: block;
|
padding-bottom: 2px;
|
||||||
padding-bottom: 3px;
|
margin: 0;
|
||||||
line-height: 22px;
|
font: 15px "TheSerifBold",arial;
|
||||||
font-size: 16px;
|
border-bottom: 2px solid #bf1f10;
|
||||||
font-family: 'TheMix_Bold', 'Georgia', 'Times', 'Times New Roman', serif;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
.teaser--mag-feature {
|
|
||||||
margin-top: 25px;
|
|
||||||
padding: 10px 0 10px;
|
|
||||||
width: 100%;
|
|
||||||
box-sizing: content-box;
|
|
||||||
border-top: 2px dotted #555;
|
|
||||||
border-bottom: 2px dotted #555;
|
|
||||||
font-size: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.teaser__wrapper {
|
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.teaser a {
|
.teaser__title {
|
||||||
outline: none;
|
font: 18px "TheSerifBold",arial;
|
||||||
text-decoration: none;
|
color: #bf1f10;
|
||||||
color: inherit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.teaser__title {
|
.teaser__title .highlight {
|
||||||
font-size: 26px;
|
color: #000;
|
||||||
}"""
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
def get_browser(self):
|
def get_browser(self):
|
||||||
br = BasicNewsRecipe.get_browser(self)
|
br = BasicNewsRecipe.get_browser(self)
|
||||||
br.open(self.base_url + '/' + self.piano_param)
|
|
||||||
br.set_cookie('_t', '9bcb7dc397cf9516cbc504b700cf14e', '.tyzden.sk')
|
|
||||||
br.set_cookie('pianovisitkey', '', '.tyzden.sk')
|
|
||||||
if self.username is not None and self.password is not None:
|
if self.username is not None and self.password is not None:
|
||||||
br.select_form(nr=2)
|
br.open('https://crm.tyzden.sk/sign/in/')
|
||||||
br['email'] = self.username
|
br.select_form(nr=0)
|
||||||
|
br['username'] = self.username
|
||||||
br['password'] = self.password
|
br['password'] = self.password
|
||||||
br.submit()
|
br.submit()
|
||||||
return br
|
return br
|
||||||
|
|
||||||
def find_sections(self):
|
def parse_index(self):
|
||||||
soup = self.index_to_soup(self.issue_url)
|
soup = self.index_to_soup(self.issue_url)
|
||||||
img_wrapper = soup.find('div', 'mag__title-img-wrapper')
|
cover_img = soup.findAll('img', 'teaser__image')[-1]
|
||||||
if img_wrapper is not None:
|
if cover_img is not None:
|
||||||
self.cover_url = img_wrapper.img['src']
|
self.cover_url = cover_img['src']
|
||||||
|
|
||||||
for section in soup.findAll('div', 'mag__section'):
|
feeds = []
|
||||||
section_title = section.find('span', 'mag__section-title')
|
teasers = soup.findAll('div', {'class': re.compile(r'\bteaser--list\b')})
|
||||||
yield (self.tag_to_string(section_title), section)
|
for teaser in teasers:
|
||||||
|
section = self.tag_to_string(teaser.find('a', 'theme-heading__wrapper'))
|
||||||
def find_articles(self, soup):
|
article_title = self.tag_to_string(
|
||||||
for title in soup.findAll('h1', 'teaser__title'):
|
teaser.find('h1', {'class': re.compile(r'\bteaser__title\b')}))
|
||||||
yield {
|
article_link = teaser.find('a', 'teaser__link--main')
|
||||||
'title': self.tag_to_string(title.a),
|
article = {
|
||||||
'url': title.a['href'],
|
'title': article_title,
|
||||||
'date': strftime(' %a, %d %b'),
|
'url': article_link['href'],
|
||||||
|
'date': strftime(' %a, %d %b')
|
||||||
}
|
}
|
||||||
|
|
||||||
def parse_index(self):
|
if not feeds:
|
||||||
feeds = []
|
# First cycle iteration.
|
||||||
for title, section in self.find_sections():
|
feeds.append((section, [article]))
|
||||||
feeds.append((title, list(self.find_articles(section))))
|
continue
|
||||||
|
|
||||||
|
last_section, last_articles = feeds[-1]
|
||||||
|
if section == last_section:
|
||||||
|
last_articles.append(article)
|
||||||
|
else:
|
||||||
|
feeds.append((section, [article]))
|
||||||
|
|
||||||
return feeds
|
return feeds
|
||||||
|
Loading…
x
Reference in New Issue
Block a user