mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Support for old custom Profiles in the GUI using the new feeds2disk infrastructure.
This commit is contained in:
parent
74accb9d04
commit
dad3dabd83
@ -623,7 +623,7 @@ class Main(MainWindow, Ui_MainWindow):
|
||||
args.extend(['--username', data['username']])
|
||||
if data['password']:
|
||||
args.extend(['--password', data['password']])
|
||||
args.append(data['title'])
|
||||
args.append(data['script'] if data['script'] else data['title'])
|
||||
id = self.job_manager.run_conversion_job(self.news_fetched, 'feeds2lrf', args=[args],
|
||||
job_description=_('Fetch news from ')+data['title'])
|
||||
self.conversion_jobs[id] = (pt, 'lrf')
|
||||
|
@ -16,7 +16,7 @@ from PyQt4.QtCore import QObject, SIGNAL, QFile
|
||||
from PyQt4.QtGui import QMenu, QIcon, QDialog, QAction
|
||||
|
||||
from libprs500.gui2.dialogs.password import PasswordDialog
|
||||
from libprs500.web.feeds.recipes import titles, get_builtin_recipe
|
||||
from libprs500.web.feeds.recipes import titles, get_builtin_recipe, compile_recipe
|
||||
|
||||
class NewsAction(QAction):
|
||||
|
||||
@ -60,7 +60,8 @@ class NewsMenu(QMenu):
|
||||
fetch = True
|
||||
|
||||
if recipe.needs_subscription:
|
||||
d = PasswordDialog(self, module + ' info dialog',
|
||||
name = module if module else recipe.title
|
||||
d = PasswordDialog(self, name + ' info dialog',
|
||||
_('<p>Please enter your username and password for %s<br>If you do not have one, please subscribe to get access to the articles.<br/> Click OK to proceed.')%(recipe.title,))
|
||||
d.exec_()
|
||||
if d.result() == QDialog.Accepted:
|
||||
@ -68,7 +69,8 @@ class NewsMenu(QMenu):
|
||||
else:
|
||||
fetch = False
|
||||
if fetch:
|
||||
data = dict(title=recipe.title, username=username, password=password)
|
||||
data = dict(title=recipe.title, username=username, password=password,
|
||||
script=getattr(recipe, 'gui_recipe_script', None))
|
||||
self.emit(SIGNAL('fetch_news(PyQt_PyObject)'), data)
|
||||
|
||||
def set_custom_feeds(self, feeds):
|
||||
@ -79,8 +81,8 @@ class CustomNewMenuItem(QAction):
|
||||
def __init__(self, title, script, parent):
|
||||
QAction.__init__(self, QIcon(':/images/user_profile.svg'), title, parent)
|
||||
self.title = title
|
||||
self.script = script
|
||||
|
||||
self.recipe = compile_recipe(script)
|
||||
self.recipe.gui_recipe_script = script
|
||||
|
||||
class CustomNewsMenu(QMenu):
|
||||
|
||||
@ -90,9 +92,8 @@ class CustomNewsMenu(QMenu):
|
||||
self.connect(self, SIGNAL('triggered(QAction*)'), self.launch)
|
||||
|
||||
def launch(self, action):
|
||||
profile = action.script
|
||||
self.emit(SIGNAL('start_news_fetch(PyQt_PyObject, PyQt_PyObject)'),
|
||||
profile, None)
|
||||
action.recipe, None)
|
||||
|
||||
def set_feeds(self, feeds):
|
||||
self.clear()
|
||||
|
@ -1,6 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
from libprs500.web.feeds.news import BasicNewsRecipe
|
||||
|
||||
## Copyright (C) 2008 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
|
||||
@ -20,8 +18,8 @@ from libprs500.web.feeds.news import BasicNewsRecipe
|
||||
import sys, os, logging
|
||||
from libprs500.web.feeds.recipes import get_builtin_recipe, compile_recipe, titles
|
||||
from libprs500.web.fetch.simple import option_parser as _option_parser
|
||||
from libprs500.web.feeds.news import Profile2Recipe
|
||||
from libprs500.ebooks.lrf.web.profiles import DefaultProfile
|
||||
from libprs500.web.feeds.news import Profile2Recipe, BasicNewsRecipe
|
||||
from libprs500.ebooks.lrf.web.profiles import DefaultProfile, FullContentProfile
|
||||
|
||||
|
||||
def option_parser(usage='''\
|
||||
@ -107,7 +105,8 @@ def run_recipe(opts, recipe_arg, parser, notification=None, handler=None):
|
||||
if os.access(recipe_arg, os.R_OK):
|
||||
try:
|
||||
recipe = compile_recipe(open(recipe_arg).read())
|
||||
is_profile = DefaultProfile in recipe.__bases__
|
||||
is_profile = DefaultProfile in recipe.__bases__ or \
|
||||
FullContentProfile in recipe.__bases__
|
||||
except:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
@ -118,7 +117,8 @@ def run_recipe(opts, recipe_arg, parser, notification=None, handler=None):
|
||||
recipe, is_profile = get_builtin_recipe(recipe_arg)
|
||||
if recipe is None:
|
||||
recipe = compile_recipe(recipe_arg)
|
||||
is_profile = DefaultProfile in recipe.__bases__
|
||||
is_profile = DefaultProfile in recipe.__bases__ or \
|
||||
FullContentProfile in recipe.__bases__
|
||||
|
||||
if recipe is None:
|
||||
raise RecipeError(recipe_arg+ ' is an invalid recipe')
|
||||
@ -135,6 +135,9 @@ def run_recipe(opts, recipe_arg, parser, notification=None, handler=None):
|
||||
recipe = Profile2Recipe(recipe, opts, parser, notification)
|
||||
else:
|
||||
recipe = recipe(opts, parser, notification)
|
||||
print
|
||||
print recipe
|
||||
print
|
||||
if not os.path.exists(recipe.output_dir):
|
||||
os.makedirs(recipe.output_dir)
|
||||
recipe.download()
|
||||
|
Loading…
x
Reference in New Issue
Block a user