Fix get urls from web page and custom_column_settings 'a' when no data.

This commit is contained in:
Jim Miller 2012-09-22 13:42:54 -05:00
parent c270d3e689
commit c62f5f09c1
2 changed files with 14 additions and 10 deletions

View file

@ -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)

View file

@ -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)