mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
align to kalibrator - focus_pl.recipe
This commit is contained in:
parent
a114202648
commit
ace07d1cc6
@ -2,7 +2,9 @@ import re
|
|||||||
|
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
|
|
||||||
class FocusRecipe(BasicNewsRecipe):
|
class FocusRecipe(BasicNewsRecipe):
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__author__ = u'intromatyk <intromatyk@gmail.com>'
|
__author__ = u'intromatyk <intromatyk@gmail.com>'
|
||||||
language = 'pl'
|
language = 'pl'
|
||||||
@ -12,10 +14,10 @@ class FocusRecipe(BasicNewsRecipe):
|
|||||||
publisher = u'Gruner + Jahr Polska'
|
publisher = u'Gruner + Jahr Polska'
|
||||||
category = u'News'
|
category = u'News'
|
||||||
description = u'Newspaper'
|
description = u'Newspaper'
|
||||||
category='magazine'
|
category = 'magazine'
|
||||||
cover_url=''
|
cover_url = ''
|
||||||
remove_empty_feeds= True
|
remove_empty_feeds = True
|
||||||
no_stylesheets=True
|
no_stylesheets = True
|
||||||
oldest_article = 7
|
oldest_article = 7
|
||||||
max_articles_per_feed = 100000
|
max_articles_per_feed = 100000
|
||||||
recursions = 0
|
recursions = 0
|
||||||
@ -27,15 +29,15 @@ class FocusRecipe(BasicNewsRecipe):
|
|||||||
simultaneous_downloads = 5
|
simultaneous_downloads = 5
|
||||||
|
|
||||||
r = re.compile('.*(?P<url>http:\/\/(www.focus.pl)|(rss.feedsportal.com\/c)\/.*\.html?).*')
|
r = re.compile('.*(?P<url>http:\/\/(www.focus.pl)|(rss.feedsportal.com\/c)\/.*\.html?).*')
|
||||||
keep_only_tags =[]
|
keep_only_tags = []
|
||||||
keep_only_tags.append(dict(name = 'div', attrs = {'id' : 'cll'}))
|
keep_only_tags.append(dict(name='div', attrs={'id': 'cll'}))
|
||||||
|
|
||||||
remove_tags =[]
|
remove_tags = []
|
||||||
remove_tags.append(dict(name = 'div', attrs = {'class' : 'ulm noprint'}))
|
remove_tags.append(dict(name='div', attrs={'class': 'ulm noprint'}))
|
||||||
remove_tags.append(dict(name = 'div', attrs = {'class' : 'txb'}))
|
remove_tags.append(dict(name='div', attrs={'class': 'txb'}))
|
||||||
remove_tags.append(dict(name = 'div', attrs = {'class' : 'h2'}))
|
remove_tags.append(dict(name='div', attrs={'class': 'h2'}))
|
||||||
remove_tags.append(dict(name = 'ul', attrs = {'class' : 'txu'}))
|
remove_tags.append(dict(name='ul', attrs={'class': 'txu'}))
|
||||||
remove_tags.append(dict(name = 'div', attrs = {'class' : 'ulc'}))
|
remove_tags.append(dict(name='div', attrs={'class': 'ulc'}))
|
||||||
|
|
||||||
extra_css = '''
|
extra_css = '''
|
||||||
body {font-family: verdana, arial, helvetica, geneva, sans-serif ;}
|
body {font-family: verdana, arial, helvetica, geneva, sans-serif ;}
|
||||||
@ -46,16 +48,15 @@ class FocusRecipe(BasicNewsRecipe):
|
|||||||
.fot{font-size: x-small; color: #666666;}
|
.fot{font-size: x-small; color: #666666;}
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
feeds = [
|
||||||
feeds = [
|
('Nauka', 'http://www.focus.pl/nauka/rss/'),
|
||||||
('Nauka', 'http://focus.pl.feedsportal.com/c/32992/f/532693/index.rss'),
|
('Historia', 'http://www.focus.pl/historia/rss/'),
|
||||||
('Historia', 'http://focus.pl.feedsportal.com/c/32992/f/532694/index.rss'),
|
('Cywilizacja', 'http://www.focus.pl/cywilizacja/rss/'),
|
||||||
('Cywilizacja', 'http://focus.pl.feedsportal.com/c/32992/f/532695/index.rss'),
|
('Sport', 'http://www.focus.pl/sport/rss/'),
|
||||||
('Sport', 'http://focus.pl.feedsportal.com/c/32992/f/532696/index.rss'),
|
('Technika', 'http://www.focus.pl/technika/rss/'),
|
||||||
('Technika', 'http://focus.pl.feedsportal.com/c/32992/f/532697/index.rss'),
|
('Przyroda', 'http://www.focus.pl/przyroda/rss/'),
|
||||||
('Przyroda', 'http://focus.pl.feedsportal.com/c/32992/f/532698/index.rss'),
|
('Technologie', 'http://www.focus.pl/gadzety/rss/')
|
||||||
('Technologie', 'http://focus.pl.feedsportal.com/c/32992/f/532699/index.rss'),
|
]
|
||||||
]
|
|
||||||
|
|
||||||
def skip_ad_pages(self, soup):
|
def skip_ad_pages(self, soup):
|
||||||
if ('advertisement' in soup.find('title').string.lower()):
|
if ('advertisement' in soup.find('title').string.lower()):
|
||||||
@ -65,20 +66,20 @@ class FocusRecipe(BasicNewsRecipe):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def get_cover_url(self):
|
def get_cover_url(self):
|
||||||
soup=self.index_to_soup('http://www.focus.pl/magazyn/')
|
soup = self.index_to_soup('http://www.focus.pl/magazyn/')
|
||||||
tag=soup.find(name='div', attrs={'class':'clr fl'})
|
tag = soup.find(name='div', attrs={'class': 'clr fl'})
|
||||||
if tag:
|
if tag:
|
||||||
self.cover_url='http://www.focus.pl/' + tag.a['href']
|
self.cover_url = 'http://www.focus.pl/' + tag.a['href']
|
||||||
return getattr(self, 'cover_url', self.cover_url)
|
return getattr(self, 'cover_url', self.cover_url)
|
||||||
|
|
||||||
def print_version(self, url):
|
def print_version(self, url):
|
||||||
if url.count ('focus.pl.feedsportal.com'):
|
if url.count('focus.pl.feedsportal.com'):
|
||||||
u = url.find('focus0Bpl')
|
u = url.find('focus0Bpl')
|
||||||
u = 'http://www.focus.pl/' + url[u + 11:]
|
u = 'http://www.focus.pl/' + url[u + 11:]
|
||||||
u = u.replace('0C', '/')
|
u = u.replace('0C', '/')
|
||||||
u = u.replace('A', '')
|
u = u.replace('A', '')
|
||||||
u = u.replace ('0E','-')
|
u = u.replace('0E', '-')
|
||||||
u = u.replace('/nc/1//story01.htm', '/do-druku/1')
|
u = u.replace('/nc/1//story01.htm', '/do-druku/1')
|
||||||
else:
|
else:
|
||||||
u = url.replace('/nc/1','/do-druku/1')
|
u = url.replace('/nc/1', '/do-druku/1')
|
||||||
return u
|
return u
|
||||||
|
Loading…
x
Reference in New Issue
Block a user