mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
Fix #369
This commit is contained in:
parent
8a6f967645
commit
4cdd498f22
@ -29,8 +29,11 @@ from libprs500.ebooks.lrf.web.profiles.bbc import BBC
|
|||||||
from libprs500.ebooks.lrf.web.profiles.newsweek import Newsweek
|
from libprs500.ebooks.lrf.web.profiles.newsweek import Newsweek
|
||||||
from libprs500.ebooks.lrf.web.profiles.economist import Economist
|
from libprs500.ebooks.lrf.web.profiles.economist import Economist
|
||||||
from libprs500.ebooks.lrf.web.profiles.newyorkreview import NewYorkReviewOfBooks
|
from libprs500.ebooks.lrf.web.profiles.newyorkreview import NewYorkReviewOfBooks
|
||||||
|
from libprs500.ebooks.lrf.web.profiles.spiegelde import SpiegelOnline
|
||||||
|
from libprs500.ebooks.lrf.web.profiles.zeitde import ZeitNachrichten
|
||||||
|
|
||||||
builtin_profiles = [NYTimes, BBC, Newsweek, Economist, NewYorkReviewOfBooks]
|
builtin_profiles = [NYTimes, BBC, Newsweek, Economist, NewYorkReviewOfBooks, \
|
||||||
|
SpiegelOnline, ZeitNachrichten]
|
||||||
available_profiles = [i.__module__.rpartition('.')[2] for i in builtin_profiles]
|
available_profiles = [i.__module__.rpartition('.')[2] for i in builtin_profiles]
|
||||||
|
|
||||||
def option_parser():
|
def option_parser():
|
||||||
|
50
src/libprs500/ebooks/lrf/web/profiles/spiegelde.py
Normal file
50
src/libprs500/ebooks/lrf/web/profiles/spiegelde.py
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
## Copyright (C) 2007 Kovid Goyal kovid@kovidgoyal.net
|
||||||
|
## Costomized to spiegel.de by S. Dorscht stdoonline@googlemail.com
|
||||||
|
## Version 0.10
|
||||||
|
## This program is free software; you can redistribute it and/or modify
|
||||||
|
## it under the terms of the GNU General Public License as published by
|
||||||
|
## the Free Software Foundation; either version 2 of the License, or
|
||||||
|
## (at your option) any later version.
|
||||||
|
##
|
||||||
|
## This program is distributed in the hope that it will be useful,
|
||||||
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
## GNU General Public License for more details.
|
||||||
|
##
|
||||||
|
## You should have received a copy of the GNU General Public License along
|
||||||
|
## with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
'''
|
||||||
|
Fetch Spiegel Online.
|
||||||
|
'''
|
||||||
|
|
||||||
|
from libprs500.ebooks.lrf.web.profiles import DefaultProfile
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
|
class SpiegelOnline(DefaultProfile):
|
||||||
|
|
||||||
|
title = 'Spiegel Online'
|
||||||
|
timefmt = ' [ %Y-%m-%d %a]'
|
||||||
|
max_recursions = 2
|
||||||
|
max_articles_per_feed = 40
|
||||||
|
use_pubdate = False
|
||||||
|
no_stylesheets = True
|
||||||
|
|
||||||
|
preprocess_regexps = \
|
||||||
|
[ (re.compile(i[0], re.IGNORECASE | re.DOTALL), i[1]) for i in
|
||||||
|
[
|
||||||
|
# Remove Zum Thema footer
|
||||||
|
(r'<div class="spArticleCredit.*?</body>', lambda match: '</body>'),
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
def get_feeds(self):
|
||||||
|
return [ ('Spiegel Online', 'http://www.spiegel.de/schlagzeilen/rss/0,5291,,00.xml') ]
|
||||||
|
|
||||||
|
|
||||||
|
def print_version(self,url):
|
||||||
|
tokens = url.split(',')
|
||||||
|
tokens[-2:-2] = ['druck|']
|
||||||
|
return ','.join(tokens).replace('|,','-')
|
39
src/libprs500/ebooks/lrf/web/profiles/zeitde.py
Normal file
39
src/libprs500/ebooks/lrf/web/profiles/zeitde.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
## Copyright (C) 2007 Kovid Goyal kovid@kovidgoyal.net
|
||||||
|
## Costomized to Die Zeit by S. Dorscht stdoonline@googlemail.com
|
||||||
|
## Version 0.08
|
||||||
|
## This program is free software; you can redistribute it and/or modify
|
||||||
|
## it under the terms of the GNU General Public License as published by
|
||||||
|
## the Free Software Foundation; either version 2 of the License, or
|
||||||
|
## (at your option) any later version.
|
||||||
|
##
|
||||||
|
## This program is distributed in the hope that it will be useful,
|
||||||
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
## GNU General Public License for more details.
|
||||||
|
##
|
||||||
|
## You should have received a copy of the GNU General Public License along
|
||||||
|
## with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
'''
|
||||||
|
Fetch Die Zeit.
|
||||||
|
'''
|
||||||
|
|
||||||
|
from libprs500.ebooks.lrf.web.profiles import DefaultProfile
|
||||||
|
|
||||||
|
class ZeitNachrichten(DefaultProfile):
|
||||||
|
|
||||||
|
title = 'Die Zeit Nachrichten'
|
||||||
|
timefmt = ' [%d %b %Y]'
|
||||||
|
max_recursions = 2
|
||||||
|
max_articles_per_feed = 40
|
||||||
|
html_description = True
|
||||||
|
no_stylesheets = True
|
||||||
|
|
||||||
|
|
||||||
|
def get_feeds(self):
|
||||||
|
return [ ('Zeit.de', 'http://newsfeed.zeit.de/news/index') ]
|
||||||
|
|
||||||
|
def print_version(self,url):
|
||||||
|
return url.replace('http://www.zeit.de/', 'http://images.zeit.de/text/').replace('?from=rss', '')
|
||||||
|
|
@ -40,12 +40,12 @@ from libprs500.gui2.main_ui import Ui_MainWindow
|
|||||||
from libprs500.gui2.device import DeviceDetector, DeviceManager
|
from libprs500.gui2.device import DeviceDetector, DeviceManager
|
||||||
from libprs500.gui2.status import StatusBar
|
from libprs500.gui2.status import StatusBar
|
||||||
from libprs500.gui2.jobs import JobManager
|
from libprs500.gui2.jobs import JobManager
|
||||||
|
from libprs500.gui2.news import NewsMenu
|
||||||
from libprs500.gui2.dialogs.metadata_single import MetadataSingleDialog
|
from libprs500.gui2.dialogs.metadata_single import MetadataSingleDialog
|
||||||
from libprs500.gui2.dialogs.metadata_bulk import MetadataBulkDialog
|
from libprs500.gui2.dialogs.metadata_bulk import MetadataBulkDialog
|
||||||
from libprs500.gui2.dialogs.jobs import JobsDialog
|
from libprs500.gui2.dialogs.jobs import JobsDialog
|
||||||
from libprs500.gui2.dialogs.conversion_error import ConversionErrorDialog
|
from libprs500.gui2.dialogs.conversion_error import ConversionErrorDialog
|
||||||
from libprs500.gui2.dialogs.lrf_single import LRFSingleDialog
|
from libprs500.gui2.dialogs.lrf_single import LRFSingleDialog
|
||||||
from libprs500.gui2.dialogs.password import PasswordDialog
|
|
||||||
from libprs500.gui2.dialogs.config import ConfigDialog
|
from libprs500.gui2.dialogs.config import ConfigDialog
|
||||||
from libprs500.gui2.lrf_renderer.main import file_renderer
|
from libprs500.gui2.lrf_renderer.main import file_renderer
|
||||||
from libprs500.gui2.lrf_renderer.main import option_parser as lrfviewerop
|
from libprs500.gui2.lrf_renderer.main import option_parser as lrfviewerop
|
||||||
@ -126,21 +126,9 @@ class Main(MainWindow, Ui_MainWindow):
|
|||||||
QObject.connect(self.action_view, SIGNAL("triggered(bool)"), self.view_book)
|
QObject.connect(self.action_view, SIGNAL("triggered(bool)"), self.view_book)
|
||||||
self.action_sync.setMenu(sm)
|
self.action_sync.setMenu(sm)
|
||||||
self.action_edit.setMenu(md)
|
self.action_edit.setMenu(md)
|
||||||
nm = QMenu()
|
self.news_menu = NewsMenu()
|
||||||
nm.addAction(QIcon(':/images/news/bbc.png'), 'BBC')
|
self.action_news.setMenu(self.news_menu)
|
||||||
nm.addAction(QIcon(':/images/news/economist.png'), 'Economist')
|
QObject.connect(self.news_menu, SIGNAL('fetch_news(PyQt_PyObject)'), self.fetch_news)
|
||||||
nm.addAction(QIcon(':/images/news/newsweek.png'), 'Newsweek')
|
|
||||||
nm.addAction(QIcon(':/images/book.svg'), 'New York Review of Books')
|
|
||||||
nm.addAction(QIcon(':/images/news/nytimes.png'), 'New York Times')
|
|
||||||
|
|
||||||
QObject.connect(nm.actions()[0], SIGNAL('triggered(bool)'), self.fetch_news_bbc)
|
|
||||||
QObject.connect(nm.actions()[1], SIGNAL('triggered(bool)'), self.fetch_news_economist)
|
|
||||||
QObject.connect(nm.actions()[2], SIGNAL('triggered(bool)'), self.fetch_news_newsweek)
|
|
||||||
QObject.connect(nm.actions()[3], SIGNAL('triggered(bool)'), self.fetch_news_nyreview)
|
|
||||||
QObject.connect(nm.actions()[4], SIGNAL('triggered(bool)'), self.fetch_news_nytimes)
|
|
||||||
|
|
||||||
self.news_menu = nm
|
|
||||||
self.action_news.setMenu(nm)
|
|
||||||
cm = QMenu()
|
cm = QMenu()
|
||||||
cm.addAction(_('Convert individually'))
|
cm.addAction(_('Convert individually'))
|
||||||
cm.addAction(_('Bulk convert'))
|
cm.addAction(_('Bulk convert'))
|
||||||
@ -539,18 +527,18 @@ class Main(MainWindow, Ui_MainWindow):
|
|||||||
|
|
||||||
############################### Fetch news #################################
|
############################### Fetch news #################################
|
||||||
|
|
||||||
def fetch_news(self, profile, pretty, username=None, password=None):
|
def fetch_news(self, data):
|
||||||
pt = PersistentTemporaryFile(suffix='.lrf')
|
pt = PersistentTemporaryFile(suffix='.lrf')
|
||||||
pt.close()
|
pt.close()
|
||||||
args = ['web2lrf', '-o', pt.name, profile]
|
args = ['web2lrf', '-o', pt.name, data['profile']]
|
||||||
if username:
|
if data['username']:
|
||||||
args.extend(['--username', username])
|
args.extend(['--username', data['username']])
|
||||||
if password:
|
if data['password']:
|
||||||
args.extend(['--password', password])
|
args.extend(['--password', data['password']])
|
||||||
id = self.job_manager.run_conversion_job(self.news_fetched, web2lrf, args=args,
|
id = self.job_manager.run_conversion_job(self.news_fetched, web2lrf, args=args,
|
||||||
job_description='Fetch news from '+pretty)
|
job_description='Fetch news from '+data['title'])
|
||||||
self.conversion_jobs[id] = (pt, 'lrf')
|
self.conversion_jobs[id] = (pt, 'lrf')
|
||||||
self.status_bar.showMessage('Fetching news from '+pretty, 2000)
|
self.status_bar.showMessage('Fetching news from '+data['title'], 2000)
|
||||||
|
|
||||||
def news_fetched(self, id, description, result, exception, formatted_traceback, log):
|
def news_fetched(self, id, description, result, exception, formatted_traceback, log):
|
||||||
pt, fmt = self.conversion_jobs.pop(id)
|
pt, fmt = self.conversion_jobs.pop(id)
|
||||||
@ -563,26 +551,6 @@ class Main(MainWindow, Ui_MainWindow):
|
|||||||
self.status_bar.showMessage('News fetched. Uploading to device.', 2000)
|
self.status_bar.showMessage('News fetched. Uploading to device.', 2000)
|
||||||
self.persistent_files.append(pt)
|
self.persistent_files.append(pt)
|
||||||
|
|
||||||
def fetch_news_bbc(self, checked):
|
|
||||||
self.fetch_news('bbc', 'BBC')
|
|
||||||
|
|
||||||
def fetch_news_newsweek(self, checked):
|
|
||||||
self.fetch_news('newsweek', 'Newsweek')
|
|
||||||
|
|
||||||
def fetch_news_economist(self, checked):
|
|
||||||
self.fetch_news('economist', 'The Economist')
|
|
||||||
|
|
||||||
def fetch_news_nyreview(self, checked):
|
|
||||||
self.fetch_news('newyorkreview', 'New York Review of Books')
|
|
||||||
|
|
||||||
def fetch_news_nytimes(self, checked):
|
|
||||||
d = PasswordDialog(self, 'nytimes info dialog',
|
|
||||||
'<p>Please enter your username and password for nytimes.com<br>If you do not have an account, you can <a href="http://www.nytimes.com/gst/regi.html">register</a> for free.<br>Without a registration, some articles will not be downloaded correctly. Click OK to proceed.')
|
|
||||||
d.exec_()
|
|
||||||
if d.result() == QDialog.Accepted:
|
|
||||||
un, pw = d.username(), d.password()
|
|
||||||
self.fetch_news('nytimes', 'New York Times', username=un, password=pw)
|
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
############################### Convert ####################################
|
############################### Convert ####################################
|
||||||
|
65
src/libprs500/gui2/news.py
Normal file
65
src/libprs500/gui2/news.py
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
## Copyright (C) 2007 Kovid Goyal kovid@kovidgoyal.net
|
||||||
|
## This program is free software; you can redistribute it and/or modify
|
||||||
|
## it under the terms of the GNU General Public License as published by
|
||||||
|
## the Free Software Foundation; either version 2 of the License, or
|
||||||
|
## (at your option) any later version.
|
||||||
|
##
|
||||||
|
## This program is distributed in the hope that it will be useful,
|
||||||
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
## GNU General Public License for more details.
|
||||||
|
##
|
||||||
|
## You should have received a copy of the GNU General Public License along
|
||||||
|
## with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
from PyQt4.QtCore import QObject, SIGNAL
|
||||||
|
from PyQt4.QtGui import QMenu, QIcon, QDialog
|
||||||
|
|
||||||
|
from libprs500.gui2.dialogs.password import PasswordDialog
|
||||||
|
|
||||||
|
class NewsMenu(QMenu):
|
||||||
|
|
||||||
|
def add_menu_item(self, title, func, icon=':/images/news.svg'):
|
||||||
|
self.addAction(QIcon(icon), title)
|
||||||
|
QObject.connect(self.actions()[-1], SIGNAL('triggered(bool)'), func)
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
QMenu.__init__(self)
|
||||||
|
self.add_menu_item('BBC', self.fetch_news_bbc, ':/images/news/bbc.png')
|
||||||
|
self.add_menu_item('Economist', self.fetch_news_economist, ':/images/news/economist.png')
|
||||||
|
self.add_menu_item('Newsweek', self.fetch_news_newsweek, ':/images/news/newsweek.png')
|
||||||
|
self.add_menu_item('New York Review of Books', self.fetch_news_nyreview, ':/images/book.svg')
|
||||||
|
self.add_menu_item('New York Times', self.fetch_news_nytimes, ':/images/news/nytimes.png')
|
||||||
|
self.add_menu_item('Spiegel Online', self.fetch_news_spiegelde)
|
||||||
|
self.add_menu_item('Zeit Nachrichten', self.fetch_news_zeitde)
|
||||||
|
|
||||||
|
def fetch_news(self, profile, title, username=None, password=None):
|
||||||
|
data = dict(profile=profile, title=title, username=username, password=password)
|
||||||
|
self.emit(SIGNAL('fetch_news(PyQt_PyObject)'), data)
|
||||||
|
|
||||||
|
def fetch_news_spiegelde(self, checked):
|
||||||
|
self.fetch_news('speigelde', 'Spiegel Online')
|
||||||
|
|
||||||
|
def fetch_news_zeitde(self, checked):
|
||||||
|
self.fetch_news('zeitde', 'Zeit Nachrichten')
|
||||||
|
|
||||||
|
def fetch_news_bbc(self, checked):
|
||||||
|
self.fetch_news('bbc', 'BBC')
|
||||||
|
|
||||||
|
def fetch_news_newsweek(self, checked):
|
||||||
|
self.fetch_news('newsweek', 'Newsweek')
|
||||||
|
|
||||||
|
def fetch_news_economist(self, checked):
|
||||||
|
self.fetch_news('economist', 'The Economist')
|
||||||
|
|
||||||
|
def fetch_news_nyreview(self, checked):
|
||||||
|
self.fetch_news('newyorkreview', 'New York Review of Books')
|
||||||
|
|
||||||
|
def fetch_news_nytimes(self, checked):
|
||||||
|
d = PasswordDialog(self, 'nytimes info dialog',
|
||||||
|
'<p>Please enter your username and password for nytimes.com<br>If you do not have an account, you can <a href="http://www.nytimes.com/gst/regi.html">register</a> for free.<br>Without a registration, some articles will not be downloaded correctly. Click OK to proceed.')
|
||||||
|
d.exec_()
|
||||||
|
if d.result() == QDialog.Accepted:
|
||||||
|
un, pw = d.username(), d.password()
|
||||||
|
self.fetch_news('nytimes', 'New York Times', username=un, password=pw)
|
Loading…
x
Reference in New Issue
Block a user