Recipe for The London Review of Books (thanks to Darko Miletic)

This commit is contained in:
Kovid Goyal 2008-12-03 23:58:28 -08:00
parent 657fa4d6c2
commit 263c6d7247
8 changed files with 65 additions and 9 deletions

View File

@ -231,6 +231,7 @@ class SchedulerDialog(QDialog, Ui_Dialog):
self.connect(self.download, SIGNAL('clicked()'), self.download_now)
self.search.setFocus(Qt.OtherFocusReason)
self.old_news.setValue(gconf['oldest_news'])
self.rnumber.setText(_('%d recipes')%self._model.rowCount(None))
def download_now(self):
recipe = self._model.data(self.recipes.currentIndex(), Qt.UserRole)

View File

@ -30,6 +30,13 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="rnumber" >
<property name="text" >
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -473,8 +473,8 @@ class BooksModel(QAbstractTableModel):
if role in (Qt.DisplayRole, Qt.EditRole):
ans = self.dc[self.column_map[index.column()]](index.row())
return NONE if ans is None else QVariant(ans)
elif role == Qt.TextAlignmentRole and self.column_map[index.column()] in ('size', 'timestamp'):
return QVariant(Qt.AlignCenter | Qt.AlignVCenter)
#elif role == Qt.TextAlignmentRole and self.column_map[index.column()] in ('size', 'timestamp'):
# return QVariant(Qt.AlignVCenter | Qt.AlignCenter)
#elif role == Qt.ToolTipRole and index.isValid():
# if self.column_map[index.column()] in self.editable_cols:
# return QVariant(_("Double click to <b>edit</b> me<br><br>"))

View File

@ -99,12 +99,18 @@ class Main(MainWindow, Ui_MainWindow):
self.donate_action = self.system_tray_menu.addAction(QIcon(':/images/donate.svg'), _('&Donate'))
self.quit_action = QAction(QIcon(':/images/window-close.svg'), _('&Quit'), self)
self.addAction(self.quit_action)
self.action_restart = QAction(_('&Restart'), self)
self.addAction(self.action_restart)
self.system_tray_menu.addAction(self.quit_action)
self.quit_action.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_Q))
self.action_restart.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_R))
self.system_tray_icon.setContextMenu(self.system_tray_menu)
self.connect(self.quit_action, SIGNAL('triggered(bool)'), self.quit)
self.connect(self.donate_action, SIGNAL('triggered(bool)'), self.donate)
self.connect(self.restore_action, SIGNAL('triggered(bool)'), lambda c : self.show())
def restart_app(c):
self.quit(None, restart=True)
self.connect(self.action_restart, SIGNAL('triggered(bool)'), restart_app)
def sta(r):
if r == QSystemTrayIcon.Trigger:
self.hide() if self.isVisible() else self.show()
@ -1275,8 +1281,9 @@ in which you want to store your books files. Any existing books will be automati
if self.device_connected:
self.memory_view.write_settings()
def quit(self, checked):
def quit(self, checked, restart=False):
if self.shutdown():
self.restart_after_quit = restart
QApplication.instance().quit()
def donate(self):
@ -1411,7 +1418,13 @@ def main(args=sys.argv):
sys.excepthook = main.unhandled_exception
if len(args) > 1:
main.add_filesystem_book(args[1])
return app.exec_()
ret = app.exec_()
if getattr(main, 'restart_after_quit', False):
e = sys.executable if getattr(sys, 'froze', False) else sys.argv[0]
print 'Restarting with:', e, sys.argv
os.execvp(e, sys.argv)
else:
return ret
return 0

View File

@ -129,7 +129,7 @@ msgid ""
"threshold number of chapters were detected."
msgstr ""
"Максимальное количество ссылок вставленных в TOC. Для блокировки, выставите "
"0 . По умолчанию : %default. \n"
"0. По умолчанию: %default. "
"Если будет вставлено в TOC значение ссылок больше, чем --toc-threshold, то "
"некоторое количество глав будет обнаруженно."

View File

@ -17,7 +17,7 @@ recipe_modules = [
'blic', 'novosti', 'danas', 'vreme', 'times_online', 'the_scotsman',
'nytimes_sub', 'security_watch', 'cyberpresse', 'st_petersburg_times',
'clarin', 'financial_times', 'heise', 'le_monde', 'harpers', 'science_aas',
'science_news', 'the_nation'
'science_news', 'the_nation', 'lrb'
]
import re, imp, inspect, time, os

View File

@ -0,0 +1,34 @@
#!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2008, Darko Miletic <darko.miletic at gmail.com>'
'''
lrb.co.uk
'''
from calibre.web.feeds.news import BasicNewsRecipe
class LondonReviewOfBooks(BasicNewsRecipe):
title = u'London Review of Books'
__author__ = u'Darko Miletic'
description = u'Literary review publishing essay-length book reviews and topical articles on politics, literature, history, philosophy, science and the arts by leading writers and thinkers'
oldest_article = 7
max_articles_per_feed = 100
no_stylesheets = True
use_embedded_content = False
encoding = 'cp1252'
remove_tags = [
dict(name='div' , attrs={'id' :'otherarticles'})
,dict(name='div' , attrs={'class':'pagetools' })
,dict(name='div' , attrs={'id' :'mainmenu' })
,dict(name='div' , attrs={'id' :'precontent' })
,dict(name='div' , attrs={'class':'nocss' })
,dict(name='span', attrs={'class':'inlineright' })
]
feeds = [(u'London Review of Books', u'http://www.lrb.co.uk/lrbrss.xml')]
def print_version(self, url):
main, split, rest = url.rpartition('/')
return main + '/print/' + rest

View File

@ -68,9 +68,10 @@ def save_soup(soup, target):
class response(str):
def __init__(self, *args):
str.__init__(self, *args)
self.newurl = None
def __new__(cls, *args):
obj = super(response, cls).__new__(cls, *args)
obj.newurl = None
return obj
class DummyLock(object):