mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update Dilema Veche
Merge branch 'patch-1' of https://github.com/mapopescu/calibre
This commit is contained in:
commit
30dd304eaf
@ -2,10 +2,11 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = u'2011, Silviu Cotoar\u0103'
|
||||
__copyright__ = u'2014-01-09, Silviu Cotoar\u0103, Marius Popescu'
|
||||
'''
|
||||
dilemaveche.ro
|
||||
'''
|
||||
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
|
||||
class DilemaVeche(BasicNewsRecipe):
|
||||
@ -15,78 +16,110 @@ class DilemaVeche(BasicNewsRecipe):
|
||||
description = '"Sint vechi, domnule!" (I.L. Caragiale)'
|
||||
publisher = 'Adevarul Holding'
|
||||
oldest_article = 7
|
||||
max_articles_per_feed = 200
|
||||
encoding = 'utf8'
|
||||
language = 'ro'
|
||||
language = 'ro'
|
||||
max_articles_per_feed = 150
|
||||
encoding = 'utf-8'
|
||||
simultaneous_downloads = 5
|
||||
masthead_url = 'http://www.dilemaveche.ro/sites/all/themes/dilema/theme/dilema_two/layouter/dilema_two_homepage/logo.png'
|
||||
publication_type = 'magazine'
|
||||
feeds = [
|
||||
needs_subscription = True
|
||||
use_embedded_content = False
|
||||
publication_type = 'magazine'
|
||||
remove_javascript = True
|
||||
no_stylesheets = True
|
||||
remove_empty_feeds = True
|
||||
feeds = [
|
||||
#('Editoriale şi opinii', 'http://www.dilemaveche.ro/taxonomy/term/1/0/feed'),
|
||||
('Editoriale si opinii - Situatiunea', 'http://www.dilemaveche.ro/taxonomy/term/37/0/feed'),
|
||||
('Editoriale si opinii - Pe ce lume traim', 'http://www.dilemaveche.ro/taxonomy/term/38/0/feed'),
|
||||
('Editoriale si opinii - Bordeie si obiceie', 'http://www.dilemaveche.ro/taxonomy/term/44/0/feed'),
|
||||
('Editoriale si opinii - Talc Show', 'http://www.dilemaveche.ro/taxonomy/term/44/0/feed'),
|
||||
('Editoriale si opinii - Talc Show', 'http://www.dilemaveche.ro/taxonomy/term/39/0/feed'),
|
||||
('Tema saptamanii', 'http://www.dilemaveche.ro/taxonomy/term/19/0/feed'),
|
||||
#('La zi în cultură', 'http://www.dilemaveche.ro/taxonomy/term/2/0/feed'),
|
||||
('La zi in cultura - Dilema va recomanda', 'http://www.dilemaveche.ro/taxonomy/term/58/0/feed'),
|
||||
('La zi in cultura - Carte', 'http://www.dilemaveche.ro/taxonomy/term/14/0/feed'),
|
||||
('La zi in cultura - Film', 'http://www.dilemaveche.ro/taxonomy/term/13/0/feed'),
|
||||
('La zi in cultura - Muzica', 'http://www.dilemaveche.ro/taxonomy/term/1341/0/feed'),
|
||||
('La zi in cultura - Arte performative', 'http://www.dilemaveche.ro/taxonomy/term/1342/0/feed'),
|
||||
('La zi in cultura - Arte vizuale', 'http://www.dilemaveche.ro/taxonomy/term/1512/0/feed'),
|
||||
#('Societate', 'http://www.dilemaveche.ro/taxonomy/term/3/0/feed'),
|
||||
('Societate - Ieri cu vedere spre azi', 'http://www.dilemaveche.ro/taxonomy/term/15/0/feed'),
|
||||
('Societate - Din polul opus', 'http://www.dilemaveche.ro/taxonomy/term/41/0/feed'),
|
||||
('Societate - Mass comedia', 'http://www.dilemaveche.ro/taxonomy/term/43/0/feed'),
|
||||
('Societate - La singular si la plural', 'http://www.dilemaveche.ro/taxonomy/term/42/0/feed'),
|
||||
#('Oameni şi idei', 'http://www.dilemaveche.ro/taxonomy/term/4/0/feed'),
|
||||
('Oameni si idei - Educatie', 'http://www.dilemaveche.ro/taxonomy/term/46/0/feed'),
|
||||
('Oameni si idei - Polemici si dezbateri', 'http://www.dilemaveche.ro/taxonomy/term/48/0/feed'),
|
||||
('Oameni si idei - Stiinta si tehnologie', 'http://www.dilemaveche.ro/taxonomy/term/46/0/feed'),
|
||||
('Dileme on-line', 'http://www.dilemaveche.ro/taxonomy/term/005/0/feed')
|
||||
('Oameni si idei - Stiinta si tehnologie', 'http://www.dilemaveche.ro/taxonomy/term/47/0/feed'),
|
||||
('Dileme on-line', 'http://www.dilemaveche.ro/taxonomy/term/5/0/feed'), #online only articles
|
||||
('Dilemateca', 'http://dilemaveche.ro/taxonomy/term/21/0/feed'), #once per month, 6-7 day of the month
|
||||
('Dilematix', 'http://dilemaveche.ro/taxonomy/term/20/0/feed'), #children, once-twice per year
|
||||
('Dilema Studiilor Postuniversitare', 'http://dilemaveche.ro/taxonomy/term/1635/0/feed') #once per year, July
|
||||
]
|
||||
remove_tags_before = dict(name='div',attrs={'class':'spacer_10'})
|
||||
remove_tags = [
|
||||
dict(name='div', attrs={'class':'art_related_left'}),
|
||||
dict(name='div', attrs={'class':'controale'}),
|
||||
dict(name='div', attrs={'class':'simple_overlay'}),
|
||||
]
|
||||
remove_tags_after = [dict(id='facebookLike')]
|
||||
remove_javascript = True
|
||||
no_stylesheets = True
|
||||
remove_empty_feeds = True
|
||||
dict(name='div', attrs={'id':['adshop_widget_428x60']}),
|
||||
dict(name='div', attrs={'id':['gallery']}),
|
||||
dict(name='div', attrs={'class':['art_related_left']}),
|
||||
#dict(name='div', attrs={'class':['box']}),
|
||||
dict(name='a', attrs={'class':['prevPage']}),
|
||||
dict(name='a', attrs={'class':['nextPage']}),
|
||||
dict(name='div', attrs={'class':['article_details']}),
|
||||
dict(name='div', attrs={'id':['comments']}),
|
||||
dict(name='ul', attrs={'class':['social-buttons-list']}),
|
||||
dict(name='a', attrs={'class':['editie']}),
|
||||
dict(name='div', attrs={'class':'simple_overlay'}),
|
||||
dict(name='div', attrs={'class':'c_right_column'}),
|
||||
dict(name='div', attrs={'id':'content_right'}),
|
||||
dict(name='div', attrs={'class':'box_shadow_top'}),
|
||||
dict(name='div', attrs={'class':'box_shadow_bottom'}),
|
||||
dict(name='div', attrs={'id':['footer']}),
|
||||
dict(name='div', attrs={'class':['clear spacer_20']}),
|
||||
dict(name='div', attrs={'id':['adh-footer']}),
|
||||
dict(name='div', attrs={'id':['skyright']}),
|
||||
dict(name='div', attrs={'id':['closure']})
|
||||
]
|
||||
remove_tags_after = [
|
||||
dict(name='div', attrs={'id':['adshop_widget_428x60']})
|
||||
]
|
||||
extra_css = """
|
||||
body{font-family: Georgia,Times,serif }
|
||||
img{margin-bottom: 0.4em; display:block}
|
||||
"""
|
||||
needs_subscription = 'optional'
|
||||
cover_margins = (10, 15, '#ffffff')
|
||||
|
||||
def get_browser(self):
|
||||
br = BasicNewsRecipe.get_browser(self)
|
||||
if self.username is not None and self.password is not None:
|
||||
br.open('http://dilemaveche.ro/user/login')
|
||||
br.select_form(nr=0)
|
||||
br['username'] = self.username
|
||||
br.open('http://pay.dilemaveche.ro/autentificare/?redirect=http%3A%2F%2Fdilemaveche.ro%2F%2F&return=true')
|
||||
br.select_form(nr = 0)
|
||||
br['username'] = self.username
|
||||
br['password'] = self.password
|
||||
br.submit()
|
||||
return br
|
||||
|
||||
def preprocess_html(self, soup):
|
||||
return self.adeify_images(soup)
|
||||
|
||||
def get_cover_url(self):
|
||||
# small, from the current number article: http://dilemaveche.ro/sites/default/files/imagecache/articol_teaser/DV517web-1_copy.JPG
|
||||
# medium, from the homepage PDF link: http://dilemaveche.ro/sites/default/files/imagecache/editie_small/DV517web-1_copy_0.JPG
|
||||
# big, from the current number article, click on the samll image: http://dilemaveche.ro/sites/default/files/imagecache/image_gallery_large/DV517web-1_copy.JPG
|
||||
cover_url = None
|
||||
soup = self.index_to_soup('http://dilemaveche.ro')
|
||||
link_item = soup.find('div',attrs={'class':'box_dr_pdf_picture'})
|
||||
if link_item and link_item.a:
|
||||
cover_url = link_item.a['href']
|
||||
br = BasicNewsRecipe.get_browser()
|
||||
cover_url = link_item.a['href']
|
||||
br = BasicNewsRecipe.get_browser(self)
|
||||
try:
|
||||
br.open(cover_url)
|
||||
except: # daca nu gaseste pdf-ul
|
||||
br.open(cover_url)
|
||||
except: #daca nu gaseste pdf-ul
|
||||
self.log("\nPDF indisponibil")
|
||||
link_item = soup.find('div',attrs={'class':'box_dr_pdf_picture'})
|
||||
if link_item and link_item.img:
|
||||
cover_url = link_item.img['src']
|
||||
br = BasicNewsRecipe.get_browser()
|
||||
br = BasicNewsRecipe.get_browser(self)
|
||||
try:
|
||||
br.open(cover_url)
|
||||
except: # daca nu gaseste nici imaginea mica mica
|
||||
print('Mama lor de nenorociti! nu este nici pdf nici imagine')
|
||||
br.open(cover_url)
|
||||
except: #daca nu gaseste nici imaginea mica mica
|
||||
print('nu este nici pdf nici imagine')
|
||||
cover_url ='http://www.dilemaveche.ro/sites/all/themes/dilema/theme/dilema_two/layouter/dilema_two_homepage/logo.png'
|
||||
return cover_url
|
||||
|
||||
cover_margins = (10, 15, '#ffffff')
|
||||
|
Loading…
x
Reference in New Issue
Block a user