diff --git a/calibre-plugin/ffdl_plugin.py b/calibre-plugin/ffdl_plugin.py index 95d97348..10660336 100644 --- a/calibre-plugin/ffdl_plugin.py +++ b/calibre-plugin/ffdl_plugin.py @@ -246,15 +246,16 @@ class FanFictionDownLoaderPlugin(InterfaceAction): d.exec_() if not d.status: return - print("get_urls_from_page URL:%s"%d.url.text()) + url = u"%s"%d.url.text() + print("get_urls_from_page URL:%s"%url) if 'archiveofourown.org' in url: configuration = Configuration(adapters.getConfigSectionFor(url),"EPUB") configuration.readfp(StringIO(get_resources("plugin-defaults.ini"))) - configuration.readfp(StringIO(options['personal.ini'])) + configuration.readfp(StringIO(prefs['personal.ini'])) else: configuration = None - url_list = get_urls_from_page("%s"%d.url.text(),configuration) + url_list = get_urls_from_page(url,configuration) if url_list: d = ViewLog(_("List of URLs"),"\n".join(url_list),parent=self.gui) @@ -966,7 +967,7 @@ make_firstimage_cover:true if "," in custcol: (custcol,flag) = map( lambda x: x.strip(), custcol.split(",") ) - #print("meta:(%s) => custcol:(%s), flag(%s) "%(meta,custcol,flag)) + print("meta:(%s) => custcol:(%s), flag(%s) "%(meta,custcol,flag)) if meta not in book['all_metadata']: print("No value for %s, skipping custom column(%s) update."%(meta,custcol)) @@ -979,18 +980,21 @@ make_firstimage_cover:true coldef = custom_columns[custcol] label = coldef['label'] - if flag == 'r' or book['added']: + if flag == 'r' or book['added']: # flag 'n' isn't actually needed--*always* set if configured and new book. db.set_custom(book_id, book['all_metadata'][meta], label=label, commit=False) if flag == 'a': + vallist = [] try: existing=db.get_custom(book_id,label=label,index_is_id=True) if isinstance(existing,list): vallist = existing - else : + elif existing: vallist = [existing] - vallist.append(book['all_metadata'][meta]) except: + pass + + if book['all_metadata'][meta]: vallist = [book['all_metadata'][meta]] db.set_custom(book_id, ", ".join(vallist), label=label, commit=False) diff --git a/fanficdownloader/geturls.py b/fanficdownloader/geturls.py index 08d7a252..93858a43 100644 --- a/fanficdownloader/geturls.py +++ b/fanficdownloader/geturls.py @@ -39,7 +39,7 @@ def get_urls_from_page(url,configuration=None): # them, AO3 doesn't even show them if not logged in. Only works # with saved user/pass--not going to prompt for list. if 'archiveofourown.org' in url: - ao3adapter = adapters.getAdapter(configuration,"http://www.archiveofourown.org/works/0","EPUB") + ao3adapter = adapters.getAdapter(configuration,"http://www.archiveofourown.org/works/0") if ao3adapter.getConfig("username"): if ao3adapter.getConfig("is_adult"): addurl = "?view_adult=true" @@ -55,7 +55,7 @@ def get_urls_from_page(url,configuration=None): if not data: opener = u2.build_opener(u2.HTTPCookieProcessor(),GZipProcessor()) data = opener.open(url).read() - + soup = BeautifulSoup(data) for a in soup.findAll('a'): @@ -72,7 +72,7 @@ def get_urls_from_page(url,configuration=None): try: href = href.replace('&index=1','') - adapter = adapters.getAdapter(configuration,href,"EPUB") + adapter = adapters.getAdapter(configuration,href) if adapter.story.getMetadata('storyUrl') not in normalized: normalized.add(adapter.story.getMetadata('storyUrl')) retlist.append(href)