, 2015, Jim Miller'
__docformat__ = 'restructuredtext en'
import os
diff --git a/calibre-plugin/config.py b/calibre-plugin/config.py
index 2b3f267..891cfe3 100644
--- a/calibre-plugin/config.py
+++ b/calibre-plugin/config.py
@@ -81,7 +81,7 @@ from calibre_plugins.fanficfare_plugin.fanficfare.adapters \
from calibre_plugins.fanficfare_plugin.common_utils \
import ( KeyboardConfigDialog, PrefsViewerDialog )
-from calibre_plugins.fanficfare_plugin.ffdl_util \
+from calibre_plugins.fanficfare_plugin.fff_util \
import (test_config)
from calibre.gui2.complete2 import EditWithComplete #MultiCompleteLineEdit
@@ -176,7 +176,12 @@ class ConfigWidget(QWidget):
self.l = QVBoxLayout()
self.setLayout(self.l)
- label = QLabel(''+_('List of Supported Sites')+' -- '+_('FAQs')+'')
+ label = QLabel(''\
+ +_('List of Supported Sites')+' -- '\
+ +_('FAQs')+'')
+
label.setOpenExternalLinks(True)
self.l.addWidget(label)
@@ -452,12 +457,12 @@ class BasicTab(QWidget):
self.l.addWidget(self.lookforurlinhtml)
self.mark = QCheckBox(_("Mark added/updated books when finished?"),self)
- self.mark.setToolTip(_("Mark added/updated books when finished. Use with option below.\nYou can also manually search for 'marked:ffdl_success'.\n'marked:ffdl_failed' is also available, or search 'marked:ffdl' for both."))
+ self.mark.setToolTip(_("Mark added/updated books when finished. Use with option below.\nYou can also manually search for 'marked:fff_success'.\n'marked:fff_failed' is also available, or search 'marked:fff' for both."))
self.mark.setChecked(prefs['mark'])
self.l.addWidget(self.mark)
self.showmarked = QCheckBox(_("Show Marked books when finished?"),self)
- self.showmarked.setToolTip(_("Show Marked added/updated books only when finished.\nYou can also manually search for 'marked:ffdl_success'.\n'marked:ffdl_failed' is also available, or search 'marked:ffdl' for both."))
+ self.showmarked.setToolTip(_("Show Marked added/updated books only when finished.\nYou can also manually search for 'marked:fff_success'.\n'marked:fff_failed' is also available, or search 'marked:fff' for both."))
self.showmarked.setChecked(prefs['showmarked'])
self.l.addWidget(self.showmarked)
@@ -481,7 +486,7 @@ class BasicTab(QWidget):
self.l.addWidget(self.urlsfromclip)
self.updatedefault = QCheckBox(_('Default to Update when books selected?'),self)
- self.updatedefault.setToolTip(_('The top FanFictionDownLoader plugin button will start Update if\nbooks are selected. If unchecked, it will always bring up \'Add New\'.'))
+ self.updatedefault.setToolTip(_('The top FanFicFare plugin button will start Update if\nbooks are selected. If unchecked, it will always bring up \'Add New\'.'))
self.updatedefault.setChecked(prefs['updatedefault'])
self.l.addWidget(self.updatedefault)
@@ -576,7 +581,7 @@ class BasicTab(QWidget):
title=_("Reject Reasons"),
label=_("Customize Reject List Reasons"),
tooltip=_("Customize the Reasons presented when Rejecting URLs"),
- save_size_name='ffdl:Reject List Reasons')
+ save_size_name='fff:Reject List Reasons')
d.exec_()
if d.result() == d.Accepted:
prefs['rejectreasons'] = d.get_plain_text()
@@ -590,7 +595,7 @@ class BasicTab(QWidget):
tooltip=_("One URL per line:\nhttp://...,note\nhttp://...,title by author - note"),
rejectreasons=rejecturllist.get_reject_reasons(),
reasonslabel=_('Add this reason to all URLs added:'),
- save_size_name='ffdl:Add Reject List')
+ save_size_name='fff:Add Reject List')
d.exec_()
if d.result() == d.Accepted:
rejecturllist.add_text(d.get_plain_text(),d.get_reason_text())
@@ -654,7 +659,7 @@ class PersonalIniTab(QWidget):
label=_("Plugin Defaults (%s) (Read-Only)")%'plugin-defaults.ini',
use_find=True,
read_only=True,
- save_size_name='ffdl:defaults.ini').exec_()
+ save_size_name='fff:defaults.ini').exec_()
def add_ini_button(self):
d = IniTextDialog(self,
@@ -663,7 +668,7 @@ class PersonalIniTab(QWidget):
title=_("Edit personal.ini"),
label=_("Edit personal.ini"),
use_find=True,
- save_size_name='ffdl:personal.ini')
+ save_size_name='fff:personal.ini')
d.exec_()
if d.result() == d.Accepted:
self.personalini = d.get_plain_text()
@@ -880,7 +885,7 @@ class OtherTab(QWidget):
self.l = QVBoxLayout()
self.setLayout(self.l)
- label = QLabel(_("These controls aren't plugin settings as such, but convenience buttons for setting Keyboard shortcuts and getting all the FanFictionDownLoader confirmation dialogs back again."))
+ label = QLabel(_("These controls aren't plugin settings as such, but convenience buttons for setting Keyboard shortcuts and getting all the FanFicFare confirmation dialogs back again."))
label.setWordWrap(True)
self.l.addWidget(label)
self.l.addSpacing(5)
@@ -891,7 +896,7 @@ class OtherTab(QWidget):
self.l.addWidget(keyboard_shortcuts_button)
reset_confirmation_button = QPushButton(_('Reset disabled &confirmation dialogs'), self)
- reset_confirmation_button.setToolTip(_('Reset all show me again dialogs for the FanFictionDownLoader plugin'))
+ reset_confirmation_button.setToolTip(_('Reset all show me again dialogs for the FanFicFare plugin'))
reset_confirmation_button.clicked.connect(self.reset_dialogs)
self.l.addWidget(reset_confirmation_button)
diff --git a/calibre-plugin/dialogs.py b/calibre-plugin/dialogs.py
index c16733a..f3332e6 100644
--- a/calibre-plugin/dialogs.py
+++ b/calibre-plugin/dialogs.py
@@ -236,7 +236,7 @@ class AddNewDialog(SizePersistedDialog):
go_signal = pyqtSignal(object, object, object, object)
def __init__(self, gui, prefs, icon):
- SizePersistedDialog.__init__(self, gui, 'FanFictionDownLoader plugin:add new dialog')
+ SizePersistedDialog.__init__(self, gui, 'fff:add new dialog')
self.prefs = prefs
self.setMinimumWidth(300)
@@ -339,7 +339,7 @@ class AddNewDialog(SizePersistedDialog):
def ok_clicked(self):
self.dialog_closing(None) # save persistent size.
self.hide()
- self.go_signal.emit( self.get_ffdl_options(),
+ self.go_signal.emit( self.get_fff_options(),
self.get_urlstext(),
self.merge,
self.extrapayload )
@@ -352,7 +352,7 @@ class AddNewDialog(SizePersistedDialog):
newmerge=True,
extraoptions={},
extrapayload=None):
- # rather than mutex in ffdl_plugin, just bail here if it's
+ # rather than mutex in fff_plugin, just bail here if it's
# already in use.
if self.isVisible(): return
@@ -434,7 +434,7 @@ class AddNewDialog(SizePersistedDialog):
if i > -1:
self.collision.setCurrentIndex(i)
- def get_ffdl_options(self):
+ def get_fff_options(self):
retval = {
'fileform': unicode(self.fileform.currentText()),
'collision': unicode(self.collision.currentText()),
@@ -468,7 +468,7 @@ class CollectURLDialog(SizePersistedDialog):
Collect single url for get urls.
'''
def __init__(self, gui, title, url_text, epubmerge_plugin=None):
- SizePersistedDialog.__init__(self, gui, 'FanFictionDownLoader plugin:get story urls')
+ SizePersistedDialog.__init__(self, gui, 'fff:get story urls')
self.status=False
self.anthology=False
@@ -614,7 +614,7 @@ class LoopProgressDialog(QProgressDialog):
book = self.book_list[self.i]
try:
- ## collision spec passed into getadapter by partial from ffdl_plugin
+ ## collision spec passed into getadapter by partial from fff_plugin
## no retval only if it exists, but collision is SKIP
self.foreach_function(book)
@@ -716,7 +716,7 @@ class AuthorTableWidgetItem(ReadOnlyTableWidgetItem):
class UpdateExistingDialog(SizePersistedDialog):
def __init__(self, gui, header, prefs, icon, books,
- save_size_name='fanfictiondownloader_plugin:update list dialog'):
+ save_size_name='fff:update list dialog'):
SizePersistedDialog.__init__(self, gui, save_size_name)
self.prefs = prefs
@@ -831,7 +831,7 @@ class UpdateExistingDialog(SizePersistedDialog):
def get_books(self):
return self.books_table.get_books()
- def get_ffdl_options(self):
+ def get_fff_options(self):
return {
'fileform': unicode(self.fileform.currentText()),
'collision': unicode(self.collision.currentText()),
@@ -921,7 +921,7 @@ class StoryListTableWidget(QTableWidget):
message = ''+_('Are you sure you want to remove this book from the list?')
if len(rows) > 1:
message = '
'+_('Are you sure you want to remove the selected %d books from the list?')%len(rows)
- if not confirm(message,'fanfictiondownloader_delete_item', self):
+ if not confirm(message,'fff_delete_item', self):
return
first_sel_row = self.currentRow()
for selrow in reversed(rows):
@@ -996,7 +996,7 @@ class RejectListTableWidget(QTableWidget):
message = '
'+_('Are you sure you want to remove this URL from the list?')
if len(rows) > 1:
message = '
'+_('Are you sure you want to remove the %d selected URLs from the list?')%len(rows)
- if not confirm(message,'ffdl_rejectlist_delete_item_again', self):
+ if not confirm(message,'fff_rejectlist_delete_item_again', self):
return
first_sel_row = self.currentRow()
for selrow in reversed(rows):
@@ -1017,7 +1017,7 @@ class RejectListDialog(SizePersistedDialog):
icon='rotate-right.png',
show_delete=True,
show_all_reasons=True,
- save_size_name='ffdl:reject list dialog'):
+ save_size_name='fff:reject list dialog'):
SizePersistedDialog.__init__(self, gui, save_size_name)
self.setWindowTitle(header)
@@ -1121,7 +1121,7 @@ class EditTextDialog(SizePersistedDialog):
def __init__(self, parent, text,
icon=None, title=None, label=None, tooltip=None,
rejectreasons=[],reasonslabel=None,
- save_size_name='ffdl:edit text dialog',
+ save_size_name='fff:edit text dialog',
):
SizePersistedDialog.__init__(self, parent, save_size_name)
@@ -1182,7 +1182,7 @@ class IniTextDialog(SizePersistedDialog):
icon=None, title=None, label=None,
use_find=False,
read_only=False,
- save_size_name='ffdl:ini text dialog',
+ save_size_name='fff:ini text dialog',
):
SizePersistedDialog.__init__(self, parent, save_size_name)
@@ -1262,7 +1262,7 @@ class IniTextDialog(SizePersistedDialog):
self.resize_dialog()
def accept(self):
- from ffdl_util import test_config
+ from fff_util import test_config
# print("in accept")
errors = test_config(self.get_plain_text())
@@ -1377,7 +1377,7 @@ class ViewLog(SizePersistedDialog):
return self.lineno
def __init__(self, parent, title, errors,
- save_size_name='ffdl:view log dialog',):
+ save_size_name='fff:view log dialog',):
SizePersistedDialog.__init__(self, parent,save_size_name)
self.l = l = QVBoxLayout()
self.setLayout(l)
diff --git a/calibre-plugin/ffdl_plugin.py b/calibre-plugin/fff_plugin.py
similarity index 98%
rename from calibre-plugin/ffdl_plugin.py
rename to calibre-plugin/fff_plugin.py
index d25431a..3a5f115 100644
--- a/calibre-plugin/ffdl_plugin.py
+++ b/calibre-plugin/fff_plugin.py
@@ -55,7 +55,7 @@ from calibre_plugins.fanficfare_plugin.fanficfare import adapters, exceptions
from calibre_plugins.fanficfare_plugin.fanficfare.epubutils import get_dcsource, get_dcsource_chaptercount, get_story_url_from_html
from calibre_plugins.fanficfare_plugin.fanficfare.geturls import get_urls_from_page, get_urls_from_html, get_urls_from_text, get_urls_from_imap
-from calibre_plugins.fanficfare_plugin.ffdl_util import (get_ffdl_adapter, get_ffdl_config, get_ffdl_personalini)
+from calibre_plugins.fanficfare_plugin.fff_util import (get_fff_adapter, get_fff_config, get_fff_personalini)
from calibre_plugins.fanficfare_plugin.config import (permitted_values, rejecturllist)
from calibre_plugins.fanficfare_plugin.prefs import prefs
from calibre_plugins.fanficfare_plugin.dialogs import (
@@ -154,7 +154,7 @@ class FanFicFarePlugin(InterfaceAction):
return self.macmenuhack
except:
file_path = os.path.join(calibre_config_dir,
- *("plugins/fanfictiondownloader_macmenuhack.txt".split('/')))
+ *("plugins/fanficfare_macmenuhack.txt".split('/')))
file_path = os.path.abspath(file_path)
logger.debug("Plugin %s macmenuhack file_path:%s"%(self.name,file_path))
self.macmenuhack = os.access(file_path, os.F_OK)
@@ -461,7 +461,7 @@ class FanFicFarePlugin(InterfaceAction):
def get_urls_from_page(self,url):
logger.debug("get_urls_from_page URL:%s"%url)
if 'archiveofourown.org' in url:
- configuration = get_ffdl_config(url)
+ configuration = get_fff_config(url)
else:
configuration = None
return get_urls_from_page(url,configuration)
@@ -571,7 +571,7 @@ class FanFicFarePlugin(InterfaceAction):
else:
message="
"+_("Rejecting FFF URLs: None of the books selected have FanFiction URLs.")+"
"+_("Proceed to Remove?")+"
"
- if confirm(message,'fanfictiondownloader_reject_non_fanfiction', self.gui):
+ if confirm(message,'fff_reject_non_fanfiction', self.gui):
self.gui.iactions['Remove Books'].delete_books()
def add_dialog(self,url_list_text=None,merge=False,anthology_url=None):
@@ -612,7 +612,7 @@ class FanFicFarePlugin(InterfaceAction):
self.gui.status_bar.show_message(_('Can only Update Epub Anthologies'), 3000)
return
- tdir = PersistentTemporaryDirectory(prefix='ffdl_anthology_')
+ tdir = PersistentTemporaryDirectory(prefix='fff_anthology_')
logger.debug("tdir:\n%s"%tdir)
bookepubio = StringIO(db.format(book_id,'EPUB',index_is_id=True))
@@ -744,10 +744,10 @@ class FanFicFarePlugin(InterfaceAction):
update_books = d.get_books()
#print("update_books:%s"%update_books)
- #print("options:%s"%d.get_ffdl_options())
+ #print("options:%s"%d.get_fff_options())
# only if there's some good ones.
if 0 < len(filter(lambda x : x['good'], update_books)):
- options = d.get_ffdl_options()
+ options = d.get_fff_options()
self.prep_downloads( options, update_books )
def get_urls_clip(self,storyurls=True):
@@ -780,13 +780,13 @@ class FanFicFarePlugin(InterfaceAction):
options['version'] = self.version
logger.debug(self.version)
- options['personal.ini'] = get_ffdl_personalini()
+ options['personal.ini'] = get_fff_personalini()
#print("prep_downloads:%s"%books)
if 'tdir' not in options: # if merging an anthology, there's alread a tdir.
# create and pass temp dir.
- tdir = PersistentTemporaryDirectory(prefix='fanfictiondownloader_')
+ tdir = PersistentTemporaryDirectory(prefix='fanficfare_')
options['tdir']=tdir
if 0 < len(filter(lambda x : x['good'], books)):
@@ -874,7 +874,7 @@ class FanFicFarePlugin(InterfaceAction):
skip_date_update = False
- adapter = get_ffdl_adapter(url,fileform)
+ adapter = get_fff_adapter(url,fileform)
## save and share cookiejar and pagecache between all
## downloads.
if 'pagecache' not in options:
@@ -1237,7 +1237,7 @@ class FanFicFarePlugin(InterfaceAction):
description=desc)
self.gui.jobs_pointer.start()
- self.gui.status_bar.show_message(_('Starting %d FanFictionDownLoads')%len(book_list),3000)
+ self.gui.status_bar.show_message(_('Starting %d FanFicFare Downloads')%len(book_list),3000)
def update_books_loop(self,book,db=None,
options={'fileform':'epub',
@@ -1310,11 +1310,11 @@ class FanFicFarePlugin(InterfaceAction):
if showlist and prefs['mark']: # don't use with anthology
db = self.gui.current_db
marked_ids = dict()
- marked_text = "ffdl_success"
+ marked_text = "fff_success"
for index, book_id in enumerate(all_ids):
marked_ids[book_id] = '%s_%04d' % (marked_text, index)
for index, book_id in enumerate(failed_ids):
- marked_ids[book_id] = 'ffdl_failed_%04d' % index
+ marked_ids[book_id] = 'fff_failed_%04d' % index
# Mark the results in our database
db.set_marked_ids(marked_ids)
@@ -1677,7 +1677,7 @@ class FanFicFarePlugin(InterfaceAction):
configuration = None
if prefs['allow_custcol_from_ini']:
- configuration = get_ffdl_config(book['url'],options['fileform'])
+ configuration = get_fff_config(book['url'],options['fileform'])
# meta => custcol[,a|n|r]
# cliches=>\#acolumn,r
for line in configuration.getConfig('custom_columns_settings').splitlines():
@@ -1773,7 +1773,7 @@ class FanFicFarePlugin(InterfaceAction):
setting_name = None
if prefs['allow_gc_from_ini']:
if not configuration: # might already have it from allow_custcol_from_ini
- configuration = get_ffdl_config(book['url'],options['fileform'])
+ configuration = get_fff_config(book['url'],options['fileform'])
# template => regexp to match => GC Setting to use.
# generate_cover_settings:
@@ -1841,7 +1841,7 @@ class FanFicFarePlugin(InterfaceAction):
except:
if prefs['addtolists'] or prefs['addtoreadlists']:
message=""+_("You configured FanFicFare to automatically update Reading Lists, but you don't have the %s plugin installed anymore?")%'Reading List'+"
"
- confirm(message,'fanfictiondownloader_no_reading_list_plugin', self.gui)
+ confirm(message,'fff_no_reading_list_plugin', self.gui)
return
if prefs['addtoreadlists']:
@@ -1853,7 +1853,7 @@ class FanFicFarePlugin(InterfaceAction):
lists = self.get_clean_reading_lists(prefs['read_lists'])
if len(lists) < 1 :
message=""+_("You configured FanFicFare to automatically update \"To Read\" Reading Lists, but you don't have any lists set?")+"
"
- confirm(message,'fanfictiondownloader_no_read_lists', self.gui)
+ confirm(message,'fff_no_read_lists', self.gui)
for l in lists:
if l in rl_plugin.get_list_names():
#print("add good read l:(%s)"%l)
@@ -1863,13 +1863,13 @@ class FanFicFarePlugin(InterfaceAction):
else:
if l != '':
message=""+_("You configured FanFicFare to automatically update Reading List '%s', but you don't have a list of that name?")%l+"
"
- confirm(message,'fanfictiondownloader_no_reading_list_%s'%l, self.gui)
+ confirm(message,'fff_no_reading_list_%s'%l, self.gui)
if prefs['addtolists'] and (add or (prefs['addtolistsonread'] and prefs['addtoreadlists']) ):
lists = self.get_clean_reading_lists(prefs['send_lists'])
if len(lists) < 1 :
message=""+_("You configured FanFicFare to automatically update \"Send to Device\" Reading Lists, but you don't have any lists set?")+"
"
- confirm(message,'fanfictiondownloader_no_send_lists', self.gui)
+ confirm(message,'fff_no_send_lists', self.gui)
for l in lists:
if l in rl_plugin.get_list_names():
@@ -1881,7 +1881,7 @@ class FanFicFarePlugin(InterfaceAction):
else:
if l != '':
message=""+_("You configured FanFicFare to automatically update Reading List '%s', but you don't have a list of that name?")%l+"
"
- confirm(message,'fanfictiondownloader_no_reading_list_%s'%l, self.gui)
+ confirm(message,'fff_no_reading_list_%s'%l, self.gui)
def make_mi_from_book(self,book):
mi = MetaInformation(book['title'],book['author']) # author is a list.
@@ -2133,7 +2133,7 @@ class FanFicFarePlugin(InterfaceAction):
book['anthology_meta_list'][k]=True
logger.debug("book['url']:%s"%book['url'])
- configuration = get_ffdl_config(book['url'],fileform)
+ configuration = get_fff_config(book['url'],fileform)
if existingbook:
book['title'] = deftitle = existingbook['title']
book['comments'] = existingbook['comments']
diff --git a/calibre-plugin/ffdl_util.py b/calibre-plugin/fff_util.py
similarity index 78%
rename from calibre-plugin/ffdl_util.py
rename to calibre-plugin/fff_util.py
index 7a161de..d7b0433 100644
--- a/calibre-plugin/ffdl_util.py
+++ b/calibre-plugin/fff_util.py
@@ -4,7 +4,7 @@ from __future__ import (unicode_literals, division, absolute_import,
print_function)
__license__ = 'GPL v3'
-__copyright__ = '2013, Jim Miller'
+__copyright__ = '2015, Jim Miller'
__docformat__ = 'restructuredtext en'
from StringIO import StringIO
@@ -17,7 +17,7 @@ from calibre_plugins.fanficfare_plugin.fanficfare import adapters, exceptions
from calibre_plugins.fanficfare_plugin.fanficfare.configurable import Configuration
from calibre_plugins.fanficfare_plugin.prefs import prefs
-def get_ffdl_personalini():
+def get_fff_personalini():
if prefs['includeimages']:
# this is a cheat to make it easier for users.
return '''[epub]
@@ -28,9 +28,9 @@ make_firstimage_cover:true
else:
return prefs['personal.ini']
-def get_ffdl_config(url,fileform="epub",personalini=None):
+def get_fff_config(url,fileform="epub",personalini=None):
if not personalini:
- personalini = get_ffdl_personalini()
+ personalini = get_fff_personalini()
site='unknown'
try:
site = adapters.getConfigSectionFor(url)
@@ -42,12 +42,12 @@ def get_ffdl_config(url,fileform="epub",personalini=None):
return configuration
-def get_ffdl_adapter(url,fileform="epub",personalini=None):
- return adapters.getAdapter(get_ffdl_config(url,fileform,personalini),url)
+def get_fff_adapter(url,fileform="epub",personalini=None):
+ return adapters.getAdapter(get_fff_config(url,fileform,personalini),url)
def test_config(initext):
try:
- configini = get_ffdl_config("test1.com?sid=555",
+ configini = get_fff_config("test1.com?sid=555",
personalini=initext)
errors = configini.test_config()
except ParsingError as pe:
diff --git a/calibre-plugin/inihighlighter.py b/calibre-plugin/inihighlighter.py
index 8be745c..2f34198 100644
--- a/calibre-plugin/inihighlighter.py
+++ b/calibre-plugin/inihighlighter.py
@@ -4,7 +4,7 @@ from __future__ import (unicode_literals, division,
print_function)
__license__ = 'GPL v3'
-__copyright__ = '2014, Jim Miller'
+__copyright__ = '2015, Jim Miller'
__docformat__ = 'restructuredtext en'
import re
diff --git a/calibre-plugin/jobs.py b/calibre-plugin/jobs.py
index 2805df3..c5d4a29 100644
--- a/calibre-plugin/jobs.py
+++ b/calibre-plugin/jobs.py
@@ -4,8 +4,7 @@ from __future__ import (unicode_literals, division, absolute_import,
print_function)
__license__ = 'GPL v3'
-__copyright__ = '2015, Jim Miller'
-__copyright__ = '2011, Grant Drake '
+__copyright__ = '2015, Jim Miller, 2011, Grant Drake '
__docformat__ = 'restructuredtext en'
import logging
@@ -96,26 +95,26 @@ def do_download_for_worker(book,options,notification=lambda x,y:x):
'''
from calibre_plugins.fanficfare_plugin import FanFicFareBase
- ffdlbase = FanFicFareBase(options['plugin_path'])
- with ffdlbase:
+ fffbase = FanFicFareBase(options['plugin_path'])
+ with fffbase:
from calibre_plugins.fanficfare_plugin.dialogs import (NotGoingToDownload,
OVERWRITE, OVERWRITEALWAYS, UPDATE, UPDATEALWAYS, ADDNEW, SKIP, CALIBREONLY)
from calibre_plugins.fanficfare_plugin.fanficfare import adapters, writers, exceptions
from calibre_plugins.fanficfare_plugin.fanficfare.epubutils import get_update_data
- from calibre_plugins.fanficfare_plugin.ffdl_util import (get_ffdl_adapter, get_ffdl_config)
+ from calibre_plugins.fanficfare_plugin.fff_util import (get_fff_adapter, get_fff_config)
try:
book['comment'] = _('Download started...')
- configuration = get_ffdl_config(book['url'],
+ configuration = get_fff_config(book['url'],
options['fileform'],
options['personal.ini'])
if configuration.getConfig('use_ssl_unverified_context'):
## monkey patch to avoid SSL bug. dupliated from
- ## ffdl_plugin.py because bg jobs run in own process
+ ## fff_plugin.py because bg jobs run in own process
## space.
import ssl
if hasattr(ssl, '_create_unverified_context'):
@@ -194,14 +193,14 @@ def do_download_for_worker(book,options,notification=lambda x,y:x):
adapter.calibrebookmark,
adapter.logfile) = get_update_data(book['epub_for_update'])
- # dup handling from ffdl_plugin needed for anthology updates.
+ # dup handling from fff_plugin needed for anthology updates.
if options['collision'] == UPDATE:
if chaptercount == urlchaptercount:
book['comment']=_("Already contains %d chapters. Reuse as is.")%chaptercount
book['outfile'] = book['epub_for_update'] # for anthology merge ops.
return book
- # dup handling from ffdl_plugin needed for anthology updates.
+ # dup handling from fff_plugin needed for anthology updates.
if chaptercount > urlchaptercount:
raise NotGoingToDownload(_("Existing epub contains %d chapters, web site only has %d. Use Overwrite to force update.") % (chaptercount,urlchaptercount),'dialog_error.png')
diff --git a/calibre-plugin/prefs.py b/calibre-plugin/prefs.py
index 0cc988b..f832f2c 100644
--- a/calibre-plugin/prefs.py
+++ b/calibre-plugin/prefs.py
@@ -7,14 +7,21 @@ __license__ = 'GPL v3'
__copyright__ = '2015, Jim Miller'
__docformat__ = 'restructuredtext en'
+import logging
+logger = logging.getLogger(__name__)
+
import copy
from calibre.utils.config import JSONConfig
from calibre.gui2.ui import get_gui
-from calibre_plugins.fanficfare_plugin.dialogs import OVERWRITE
+from calibre_plugins.fanficfare_plugin.dialogs import UPDATE
from calibre_plugins.fanficfare_plugin.common_utils import get_library_uuid
-PREFS_NAMESPACE = 'FanFictionDownLoaderPlugin'
+
+# if don't have any settings for FanFicFarePlugin, copy from
+# predecessor FanFictionDownLoaderPlugin.
+FFDL_PREFS_NAMESPACE = 'FanFictionDownLoaderPlugin'
+PREFS_NAMESPACE = 'FanFicFarePlugin'
PREFS_KEY_SETTINGS = 'settings'
# Set defaults used by all. Library specific settings continue to
@@ -39,7 +46,7 @@ default_prefs['autoconvert'] = False
default_prefs['urlsfromclip'] = True
default_prefs['updatedefault'] = True
default_prefs['fileform'] = 'epub'
-default_prefs['collision'] = OVERWRITE
+default_prefs['collision'] = UPDATE
default_prefs['deleteotherforms'] = False
default_prefs['adddialogstaysontop'] = False
default_prefs['includeimages'] = False
@@ -78,13 +85,6 @@ default_prefs['imapsessionpass'] = False
default_prefs['imapfolder'] = 'INBOX'
default_prefs['imapmarkread'] = True
-# This is where all preferences for this plugin *were* stored
-# Remember that this name (i.e. plugins/fanfictiondownloader_plugin) is also
-# in a global namespace, so make it as unique as possible.
-# You should always prefix your config file name with plugins/,
-# so as to ensure you dont accidentally clobber a calibre config file
-old_prefs = JSONConfig('plugins/fanfictiondownloader_plugin')
-
def set_library_config(library_config,db):
db.prefs.set_namespaced(PREFS_NAMESPACE,
PREFS_KEY_SETTINGS,
@@ -93,19 +93,23 @@ def set_library_config(library_config,db):
def get_library_config(db):
library_id = get_library_uuid(db)
library_config = None
- # Check whether this is a configuration needing to be migrated
- # from json into database. If so: get it, set it, rename it in json.
- if library_id in old_prefs:
- #print("get prefs from old_prefs")
- library_config = old_prefs[library_id]
- set_library_config(library_config,db)
- old_prefs["migrated to library db %s"%library_id] = old_prefs[library_id]
- del old_prefs[library_id]
if library_config is None:
#print("get prefs from db")
- library_config = db.prefs.get_namespaced(PREFS_NAMESPACE, PREFS_KEY_SETTINGS,
- copy.deepcopy(default_prefs))
+ library_config = db.prefs.get_namespaced(PREFS_NAMESPACE,
+ PREFS_KEY_SETTINGS)
+
+ # if don't have any settings for FanFicFarePlugin, copy from
+ # predecessor FanFictionDownLoaderPlugin.
+ if library_config is None:
+ logger.info("Attempting to read settings from predecessor--FFDL")
+ library_config = db.prefs.get_namespaced(FFDL_PREFS_NAMESPACE,
+ PREFS_KEY_SETTINGS)
+ if library_config is None:
+ # defaults.
+ logger.info("Using default settings")
+ library_config = copy.deepcopy(default_prefs)
+
return library_config
# fake out so I don't have to change the prefs calls anywhere. The