Normalize Story URLs for Reject URL list. Plugin only.

This commit is contained in:
Jim Miller
2012-11-20 22:02:39 -06:00
parent 6fb5701197
commit 46e3b50ead
3 changed files with 26 additions and 19 deletions
+8 -5
View File
@@ -22,8 +22,9 @@ from calibre.gui2.ui import get_gui
from calibre_plugins.fanfictiondownloader_plugin.dialogs \
import (UPDATE, UPDATEALWAYS, OVERWRITE, collision_order, RejectListDialog,
EditTextDialog)
from calibre_plugins.fanfictiondownloader_plugin.fanficdownloader.adapters import getConfigSections
from calibre_plugins.fanfictiondownloader_plugin.fanficdownloader.adapters \
import (getConfigSections, getNormalStoryURL)
from calibre_plugins.fanfictiondownloader_plugin.common_utils \
import ( get_library_uuid, KeyboardConfigDialog, PrefsViewerDialog )
@@ -159,7 +160,9 @@ class RejectURLList:
(rejurl,note) = line.split(',',1)
else:
(rejurl,note) = (line,'')
cache[rejurl] = note
rejurl = getNormalStoryURL(rejurl)
if rejurl:
cache[rejurl] = note
return cache
@@ -549,8 +552,8 @@ class BasicTab(QWidget):
"",
icon=self.windowIcon(),
title="Add Reject URLs",
label="Add Reject URLs. Use: 'http://...,note'",
tooltip="One URL per line, everything after ',' will be put in the note.")
label="Add Reject URLs. Use: <b>http://...,note</b>",
tooltip="One URL per line, everything after <b>,</b> will be put in the note.")
d.exec_()
if d.result() == d.Accepted:
rejecturllist.add_text(d.get_plain_text())
+1 -14
View File
@@ -1408,20 +1408,7 @@ make_firstimage_cover:true
return None
def _is_good_downloader_url(self,url):
# this is the accepted way to 'check for existance of a class variable'? really?
try:
self.dummyconfig
except AttributeError:
self.dummyconfig = Configuration("test1.com","EPUB")
# pulling up an adapter is pretty low over-head. If
# it fails, it's a bad url.
try:
adapter = adapters.getAdapter(self.dummyconfig,url)
url = adapter.url
del adapter
return url
except:
return None;
return adapters.getNormalStoryURL(url)
def get_url_list(urls):
def f(x):
+17
View File
@@ -23,6 +23,7 @@ import urlparse as up
logger = logging.getLogger(__name__)
from .. import exceptions as exceptions
from ..configurable import Configuration
## must import each adapter here.
@@ -125,6 +126,22 @@ for x in imports():
#print x
__class_list.append(sys.modules[x].getClass())
def getNormalStoryURL(url):
if not getNormalStoryURL.__dummyconfig:
getNormalStoryURL.__dummyconfig = Configuration("test1.com","EPUB")
# pulling up an adapter is pretty low over-head. If
# it fails, it's a bad url.
try:
adapter = getAdapter(getNormalStoryURL.__dummyconfig,url)
url = adapter.url
del adapter
return url
except:
return None;
# kludgey function static/singleton
getNormalStoryURL.__dummyconfig = None
def getAdapter(config,url):
logger.debug("trying url:"+url)