mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update Pecat
Fixes #1252285 [Updated recipe for serbian magazine Pecat](https://bugs.launchpad.net/calibre/+bug/1252285)
This commit is contained in:
parent
c20693d3d5
commit
bc07ab305b
@ -1,32 +1,34 @@
|
|||||||
|
# vim:fileencoding=utf-8
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2011, Darko Miletic <darko.miletic at gmail.com>'
|
__copyright__ = '2011-2013, Darko Miletic <darko.miletic at gmail.com>'
|
||||||
'''
|
'''
|
||||||
www.pecat.co.rs
|
www.pecat.co.rs
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import re
|
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
class Pecat_rs(BasicNewsRecipe):
|
class Pecat_rs(BasicNewsRecipe):
|
||||||
title = 'Pecat'
|
title = u'Печат'
|
||||||
__author__ = 'Darko Miletic'
|
__author__ = 'Darko Miletic'
|
||||||
description = 'Internet portal slobodne Srbije'
|
description = u'Интернет портал слободне Србије'
|
||||||
oldest_article = 15
|
publisher = u'NAŠ PEČAT A.D. BEOGRAD'
|
||||||
max_articles_per_feed = 100
|
oldest_article = 7
|
||||||
language = 'sr'
|
max_articles_per_feed = 100
|
||||||
encoding = 'utf-8'
|
language = 'sr'
|
||||||
no_stylesheets = True
|
encoding = 'utf-8'
|
||||||
use_embedded_content = True
|
no_stylesheets = True
|
||||||
masthead_url = 'http://www.pecat.co.rs/wp-content/themes/zenko-v1/images/logo.jpg'
|
use_embedded_content = True
|
||||||
publication_type = 'magazine'
|
masthead_url = 'http://www.pecat.co.rs/wp-content/themes/zenko-v1/images/logo.jpg'
|
||||||
extra_css = """
|
LOGIN = 'http://www.pecat.co.rs/'
|
||||||
@font-face {font-family: "serif1";src:url(res:///opt/sony/ebook/FONT/tt0011m_.ttf)}
|
remove_empty_feeds = True
|
||||||
@font-face {font-family: "sans1";src:url(res:///opt/sony/ebook/FONT/tt0003m_.ttf)}
|
ignore_duplicate_articles = {'url'}
|
||||||
|
needs_subscription = 'optional'
|
||||||
|
publication_type = 'magazine'
|
||||||
|
extra_css = """
|
||||||
body{font-family: Arial,Helvetica,sans1,sans-serif}
|
body{font-family: Arial,Helvetica,sans1,sans-serif}
|
||||||
img{display: block; margin-bottom: 1em; margin-top: 1em}
|
img{display: block; margin-bottom: 1em; margin-top: 1em}
|
||||||
p{display: block; margin-bottom: 1em; margin-top: 1em}
|
p{display: block; margin-bottom: 1em; margin-top: 1em}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
conversion_options = {
|
conversion_options = {
|
||||||
'comment' : description
|
'comment' : description
|
||||||
@ -35,38 +37,36 @@ class Pecat_rs(BasicNewsRecipe):
|
|||||||
, 'language' : language
|
, 'language' : language
|
||||||
}
|
}
|
||||||
|
|
||||||
preprocess_regexps = [(re.compile(u'\u0110'), lambda match: u'\u00D0')]
|
def get_browser(self):
|
||||||
|
br = BasicNewsRecipe.get_browser(self)
|
||||||
|
if self.username is not None and self.password is not None:
|
||||||
|
br.open(self.LOGIN)
|
||||||
|
br.select_form(name='loginform')
|
||||||
|
br['log'] = self.username
|
||||||
|
br['pwd'] = self.password
|
||||||
|
br.submit()
|
||||||
|
return br
|
||||||
|
|
||||||
feeds = [(u'Clanci', u'http://www.pecat.co.rs/feed/')]
|
feeds = [
|
||||||
|
(u'Уводник' , u'http://www.pecat.co.rs/category/uvodnik/feed/'),
|
||||||
def preprocess_html(self, soup):
|
(u'Интервју' , u'http://www.pecat.co.rs/category/intervju/feed/'),
|
||||||
for item in soup.findAll(style=True):
|
(u'Друштво' , u'http://www.pecat.co.rs/category/drustvo/feed/'),
|
||||||
del item['style']
|
(u'Регион' , u'http://www.pecat.co.rs/category/region/feed/'),
|
||||||
for item in soup.findAll('a'):
|
(u'Свет' , u'http://www.pecat.co.rs/category/svet/feed/'),
|
||||||
limg = item.find('img')
|
(u'Колумне' , u'http://www.pecat.co.rs/category/kolumne/feed/'),
|
||||||
if item.string is not None:
|
(u'Култура' , u'http://www.pecat.co.rs/category/kultura/feed/'),
|
||||||
str = item.string
|
(u'Документи', u'http://www.pecat.co.rs/category/dokumenti/feed/'),
|
||||||
item.replaceWith(str)
|
(u'Репортаже', u'http://www.pecat.co.rs/category/reportaze/feed/'),
|
||||||
else:
|
(u'Економија', u'http://www.pecat.co.rs/category/ekonomija/feed/'),
|
||||||
if limg:
|
(u'Изјаве' , u'http://www.pecat.co.rs/category/izjave/feed/'),
|
||||||
limg.extract()
|
(u'Преглед' , u'http://www.pecat.co.rs/category/pregled/feed/'),
|
||||||
item.replaceWith(limg)
|
(u'Сапутници', u'http://www.pecat.co.rs/category/saputnici/feed/'),
|
||||||
else:
|
(u'Сатира' , u'http://www.pecat.co.rs/category/satira/feed/'),
|
||||||
str = self.tag_to_string(item)
|
(u'Спорт' , u'http://www.pecat.co.rs/category/sport/feed/'),
|
||||||
item.replaceWith(str)
|
(u'Павле Ћосић', u'http://www.pecat.co.rs/category/agencijske-vesti-pavle-cosic/feed/'),
|
||||||
for item in soup.findAll('img'):
|
(u'ТВ Коментар', u'http://www.pecat.co.rs/category/tv-komentar/feed/'),
|
||||||
dad = item.findParent('p')
|
(u'Вести', u'http://www.pecat.co.rs/category/vesti/feed/'),
|
||||||
if dad:
|
(u'Календар', u'http://www.pecat.co.rs/category/kalendar/feed/'),
|
||||||
mydad = dad.parent
|
(u'Други Пишу', u'http://www.pecat.co.rs/category/drugi-pisu/feed/'),
|
||||||
myIndex = mydad.contents.index(dad)
|
(u'Одбрана и безбедност', u'http://www.pecat.co.rs/category/odbrana-i-bezbednost/feed/')
|
||||||
item.extract()
|
]
|
||||||
mydad.insert(myIndex,item)
|
|
||||||
for item in soup.findAll('strong'):
|
|
||||||
dad = item.findParent('p')
|
|
||||||
if dad:
|
|
||||||
mydad = dad.parent
|
|
||||||
myIndex = mydad.contents.index(dad)
|
|
||||||
item.extract()
|
|
||||||
item.name='h4'
|
|
||||||
mydad.insert(myIndex,item)
|
|
||||||
return soup
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user