mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Added with: to dispatch enabling __enter__ execution
This commit is contained in:
commit
a94451984d
BIN
resources/images/news/eluniversal_ve.png
Normal file
BIN
resources/images/news/eluniversal_ve.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 521 B |
52
resources/recipes/eluniversal_ve.recipe
Normal file
52
resources/recipes/eluniversal_ve.recipe
Normal file
@ -0,0 +1,52 @@
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>'
|
||||
'''
|
||||
www.eluniversal.com
|
||||
'''
|
||||
|
||||
from calibre import strftime
|
||||
from calibre.web.feeds.recipes import BasicNewsRecipe
|
||||
|
||||
class ElUniversal(BasicNewsRecipe):
|
||||
title = 'El Universal'
|
||||
__author__ = 'Darko Miletic'
|
||||
description = 'Noticias de Venezuela'
|
||||
oldest_article = 2
|
||||
max_articles_per_feed = 100
|
||||
no_stylesheets = True
|
||||
use_embedded_content = False
|
||||
encoding = 'cp1252'
|
||||
publisher = 'El Universal'
|
||||
category = 'news, Caracas, Venezuela, world'
|
||||
language = 'es'
|
||||
cover_url = strftime('http://static.eluniversal.com/%Y/%m/%d/portada.jpg')
|
||||
|
||||
conversion_options = {
|
||||
'comments' : description
|
||||
,'tags' : category
|
||||
,'language' : language
|
||||
,'publisher' : publisher
|
||||
}
|
||||
|
||||
keep_only_tags = [dict(name='div', attrs={'class':'Nota'})]
|
||||
remove_tags = [
|
||||
dict(name=['object','link','script','iframe'])
|
||||
,dict(name='div',attrs={'class':'Herramientas'})
|
||||
]
|
||||
|
||||
feeds = [
|
||||
(u'Ultimas Noticias', u'http://www.eluniversal.com/rss/avances.xml' )
|
||||
,(u'Economia' , u'http://www.eluniversal.com/rss/eco_avances.xml')
|
||||
,(u'Internacionales' , u'http://www.eluniversal.com/rss/int_avances.xml')
|
||||
,(u'Deportes' , u'http://www.eluniversal.com/rss/dep_avances.xml')
|
||||
,(u'Cultura' , u'http://www.eluniversal.com/rss/cul_avances.xml')
|
||||
,(u'Nacional y politica' , u'http://www.eluniversal.com/rss/pol_avances.xml')
|
||||
,(u'Ciencia y tecnologia', u'http://www.eluniversal.com/rss/cyt_avances.xml')
|
||||
,(u'Universo empresarial', u'http://www.eluniversal.com/rss/uni_avances.xml')
|
||||
,(u'Caracas' , u'http://www.eluniversal.com/rss/ccs_avances.xml')
|
||||
]
|
||||
|
||||
def print_version(self, url):
|
||||
rp,sep,rest = url.rpartition('/')
|
||||
return rp + sep + 'imp_' + rest
|
||||
|
@ -1,3 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from calibre.web.feeds.recipes import BasicNewsRecipe
|
||||
|
||||
class NYTimes(BasicNewsRecipe):
|
||||
@ -9,21 +10,17 @@ class NYTimes(BasicNewsRecipe):
|
||||
needs_subscription = True
|
||||
|
||||
no_stylesheets = True
|
||||
#remove_tags_before = dict(name='h1', attrs={'class':'heading'})
|
||||
#remove_tags_after = dict(name='td', attrs={'class':'newptool1'})
|
||||
remove_tags_before = dict(name='div', attrs={'align':'center'})
|
||||
remove_tags_after = dict(name='ol', attrs={'compact':'COMPACT'})
|
||||
remove_tags = [
|
||||
dict(name='iframe'),
|
||||
#dict(name='div', attrs={'class':'related-articles'}),
|
||||
#dict(name='div', attrs={'id':['qrformdiv', 'inSection', 'alpha-inner']}),
|
||||
dict(name='form', attrs={'onsubmit':"return verifySearch(this.w,'Keyword, citation, or author')"}),
|
||||
dict(name='table', attrs={'cellspacing':'0'}),
|
||||
dict(name='div', attrs={'id':['sidebar']}),
|
||||
#dict(name='form', attrs={'onsubmit':"return verifySearch(this.w,'Keyword, citation, or author')"}),
|
||||
dict(name='table', attrs={'align':'RIGHT'}),
|
||||
]
|
||||
|
||||
def preprocess_html(self, soup):
|
||||
table = soup.find('table')
|
||||
if table is not None:
|
||||
table.extract()
|
||||
return soup
|
||||
|
||||
|
||||
#TO LOGIN
|
||||
def get_browser(self):
|
||||
@ -44,9 +41,9 @@ class NYTimes(BasicNewsRecipe):
|
||||
|
||||
# To parse artice toc
|
||||
def parse_index(self):
|
||||
soup = self.nejm_get_index()
|
||||
parse_soup = self.nejm_get_index()
|
||||
|
||||
div = soup.find(id='centerTOC')
|
||||
div = parse_soup.find(id='centerTOC')
|
||||
|
||||
current_section = None
|
||||
current_articles = []
|
||||
@ -81,3 +78,20 @@ class NYTimes(BasicNewsRecipe):
|
||||
|
||||
return feeds
|
||||
|
||||
def preprocess_html(self, soup):
|
||||
for a in soup.findAll(text=lambda x: x and '[in this window]' in x):
|
||||
a = a.findParent('a')
|
||||
url = a.get('href', None)
|
||||
if not url:
|
||||
continue
|
||||
if url.startswith('/'):
|
||||
url = 'http://content.nejm.org'+url
|
||||
isoup = self.index_to_soup(url)
|
||||
img = isoup.find('img', src=lambda x: x and
|
||||
x.startswith('/content/'))
|
||||
if img is not None:
|
||||
img.extract()
|
||||
table = a.findParent('table')
|
||||
table.replaceWith(img)
|
||||
return soup
|
||||
|
||||
|
@ -367,8 +367,6 @@ def plugin_for_catalog_format(fmt):
|
||||
for plugin in catalog_plugins():
|
||||
if fmt.lower() in plugin.file_types:
|
||||
return plugin
|
||||
else:
|
||||
return None
|
||||
|
||||
def device_plugins():
|
||||
for plugin in _initialized_plugins:
|
||||
|
@ -7,10 +7,12 @@ __docformat__ = 'restructuredtext en'
|
||||
'''
|
||||
import textwrap, os
|
||||
|
||||
from PyQt4.QtCore import QCoreApplication, SIGNAL, QModelIndex, QUrl
|
||||
from PyQt4.QtCore import QCoreApplication, SIGNAL, QModelIndex, QUrl, QTimer, Qt
|
||||
from PyQt4.QtGui import QDialog, QPixmap, QGraphicsScene, QIcon, QDesktopServices
|
||||
|
||||
from calibre.gui2.dialogs.book_info_ui import Ui_BookInfo
|
||||
from calibre.gui2 import dynamic
|
||||
from calibre import fit_image
|
||||
|
||||
class BookInfo(QDialog, Ui_BookInfo):
|
||||
|
||||
@ -18,6 +20,7 @@ class BookInfo(QDialog, Ui_BookInfo):
|
||||
QDialog.__init__(self, parent)
|
||||
Ui_BookInfo.__init__(self)
|
||||
self.setupUi(self)
|
||||
self.cover_pixmap = None
|
||||
desktop = QCoreApplication.instance().desktop()
|
||||
screen_height = desktop.availableGeometry().height() - 100
|
||||
self.resize(self.size().width(), screen_height)
|
||||
@ -25,12 +28,22 @@ class BookInfo(QDialog, Ui_BookInfo):
|
||||
|
||||
self.view = view
|
||||
self.current_row = None
|
||||
self.fit_cover.setChecked(dynamic.get('book_info_dialog_fit_cover',
|
||||
False))
|
||||
self.refresh(row)
|
||||
self.connect(self.view.selectionModel(), SIGNAL('currentChanged(QModelIndex,QModelIndex)'), self.slave)
|
||||
self.connect(self.next_button, SIGNAL('clicked()'), self.next)
|
||||
self.connect(self.previous_button, SIGNAL('clicked()'), self.previous)
|
||||
self.connect(self.text, SIGNAL('linkActivated(QString)'), self.open_book_path)
|
||||
self.fit_cover.stateChanged.connect(self.toggle_cover_fit)
|
||||
self.cover.resizeEvent = self.cover_view_resized
|
||||
|
||||
def toggle_cover_fit(self, state):
|
||||
dynamic.set('book_info_dialog_fit_cover', self.fit_cover.isChecked())
|
||||
self.resize_cover()
|
||||
|
||||
def cover_view_resized(self, event):
|
||||
QTimer.singleShot(1, self.resize_cover)
|
||||
def slave(self, current, previous):
|
||||
row = current.row()
|
||||
self.refresh(row)
|
||||
@ -57,6 +70,22 @@ class BookInfo(QDialog, Ui_BookInfo):
|
||||
if ni.isValid():
|
||||
self.view.setCurrentIndex(ni)
|
||||
|
||||
def resize_cover(self):
|
||||
if self.cover_pixmap is None:
|
||||
return
|
||||
self.setWindowIcon(QIcon(self.cover_pixmap))
|
||||
self.scene = QGraphicsScene()
|
||||
pixmap = self.cover_pixmap
|
||||
if self.fit_cover.isChecked():
|
||||
scaled, new_width, new_height = fit_image(pixmap.width(),
|
||||
pixmap.height(), self.cover.size().width()-10,
|
||||
self.cover.size().height()-10)
|
||||
if scaled:
|
||||
pixmap = pixmap.scaled(new_width, new_height,
|
||||
Qt.KeepAspectRatio, Qt.SmoothTransformation)
|
||||
self.scene.addPixmap(pixmap)
|
||||
self.cover.setScene(self.scene)
|
||||
|
||||
def refresh(self, row):
|
||||
if isinstance(row, QModelIndex):
|
||||
row = row.row()
|
||||
@ -71,12 +100,8 @@ class BookInfo(QDialog, Ui_BookInfo):
|
||||
self.comments.setText(info.pop(_('Comments'), ''))
|
||||
|
||||
cdata = info.pop('cover', '')
|
||||
pixmap = QPixmap.fromImage(cdata)
|
||||
self.setWindowIcon(QIcon(pixmap))
|
||||
|
||||
self.scene = QGraphicsScene()
|
||||
self.scene.addPixmap(pixmap)
|
||||
self.cover.setScene(self.scene)
|
||||
self.cover_pixmap = QPixmap.fromImage(cdata)
|
||||
self.resize_cover()
|
||||
|
||||
rows = u''
|
||||
self.text.setText('')
|
||||
|
@ -1,3 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BookInfo</class>
|
||||
<widget class="QDialog" name="BookInfo">
|
||||
@ -53,6 +54,13 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="fit_cover">
|
||||
<property name="text">
|
||||
<string>Fit &cover to view</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
|
@ -691,6 +691,7 @@ def command_catalog(args, dbpath):
|
||||
return 1
|
||||
if opts.verbose:
|
||||
log("library.cli:command_catalog dispatching to plugin %s" % plugin.name)
|
||||
with plugin:
|
||||
plugin.run(args[1], opts, get_db(dbpath, opts))
|
||||
return 0
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user