diff --git a/calibre-plugin/ffdl_plugin.py b/calibre-plugin/ffdl_plugin.py index 5d65cc9..490bc86 100644 --- a/calibre-plugin/ffdl_plugin.py +++ b/calibre-plugin/ffdl_plugin.py @@ -193,10 +193,10 @@ class FanFictionDownLoaderPlugin(InterfaceAction): shortcut_name='Get URLs from Selected Books', triggered=self.get_list_urls) - self.get_list_action = self.create_menu_item_ex(self.menu, 'Get Story URLs from Web Page', image='view.png', - unique_name='Get Story URLs from Web Page', - shortcut_name='Get Story URLs from Web Page', - triggered=self.get_urls_from_page) + self.get_list_url_action = self.create_menu_item_ex(self.menu, 'Get Story URLs from Web Page', image='view.png', + unique_name='Get Story URLs from Web Page', + shortcut_name='Get Story URLs from Web Page', + triggered=self.get_urls_from_page) self.menu.addSeparator() self.config_action = create_menu_action_unique(self, self.menu, '&Configure Plugin', shortcut=False, @@ -205,11 +205,11 @@ class FanFictionDownLoaderPlugin(InterfaceAction): shortcut_name='Configure FanFictionDownLoader', triggered=partial(do_user_config,parent=self.gui)) - self.config_action = create_menu_action_unique(self, self.menu, '&About Plugin', shortcut=False, - image= 'images/icon.png', - unique_name='About FanFictionDownLoader', - shortcut_name='About FanFictionDownLoader', - triggered=self.about) + self.about_action = create_menu_action_unique(self, self.menu, '&About Plugin', shortcut=False, + image= 'images/icon.png', + unique_name='About FanFictionDownLoader', + shortcut_name='About FanFictionDownLoader', + triggered=self.about) # Before we finalize, make sure we delete any actions for menus that are no longer displayed for menu_id, unique_name in self.old_actions_unique_map.iteritems(): diff --git a/fanficdownloader/adapters/adapter_ksarchivecom.py b/fanficdownloader/adapters/adapter_ksarchivecom.py index 5a38899..10685ff 100644 --- a/fanficdownloader/adapters/adapter_ksarchivecom.py +++ b/fanficdownloader/adapters/adapter_ksarchivecom.py @@ -211,7 +211,9 @@ class KSArchiveComAdapter(BaseSiteAdapter): # XXX cats = labelspan.parent.findAll('a',href=re.compile(r'browse.php\?type=categories')) catstext = [cat.string for cat in cats] for cat in catstext: - if cat.string.strip() in ('Poetry','Essays'): + # ran across one story with an empty + # tag in the desc once. + if cat and cat.strip() in ('Poetry','Essays'): self.story.addToList('category',cat.string) if 'Characters' in label: diff --git a/fanficdownloader/geturls.py b/fanficdownloader/geturls.py index fc7171e..292e4aa 100644 --- a/fanficdownloader/geturls.py +++ b/fanficdownloader/geturls.py @@ -37,11 +37,15 @@ def get_urls_from_page(url): for a in soup.findAll('a'): if a.has_key('href'): href = form_url(url,a['href']) - # lots of eFiction sites use similar 'are you old enough' javascript links. - if 'javascript' in a['href'] and 'viewstory.php' in a['href']: - m = re.search(r"'(?P(view)?story\.php\?(sid|psid|no|story|stid)=\d+)",a['href']) + # this (should) catch normal story links, some javascript + # 'are you old enough' links, and 'Report This' links. + # The 'normalized' set prevents duplicates. + if 'story.php' in a['href']: + #print("trying:%s"%a['href']) + m = re.search(r"(?P(view)?story\.php\?(sid|psid|no|story|stid)=\d+)",a['href']) if m != None: href = form_url(url,m.group('sid')) + try: href = href.replace('&index=1','') adapter = adapters.getAdapter(config,href,"EPUB")