mirror of
https://github.com/wassname/FanFicFare.git
synced 2026-09-14 11:14:10 +08:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fc9c2553db |
@@ -82,8 +82,8 @@ 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,
|
||||
reset_orig_chapters_epub)
|
||||
get_dcsource, get_dcsource_iscompleted, get_dcsource_chaptercount,
|
||||
get_story_url_from_html, reset_orig_chapters_epub)
|
||||
|
||||
from calibre_plugins.fanficfare_plugin.fanficfare.geturls import (
|
||||
get_urls_from_page, get_urls_from_html,get_urls_from_text,
|
||||
@@ -771,11 +771,14 @@ class FanFicFarePlugin(InterfaceAction):
|
||||
filenames = self.get_epubmerge_plugin().do_unmerge(bookepubio,tdir)
|
||||
urlmapfile = {}
|
||||
url_list = []
|
||||
completed_list = []
|
||||
for f in filenames:
|
||||
url = get_dcsource(f)
|
||||
(url,iscompleted) = get_dcsource_iscompleted(f)
|
||||
if url:
|
||||
urlmapfile[url]=f
|
||||
url_list.append(url)
|
||||
if iscompleted:
|
||||
completed_list.append(url)
|
||||
|
||||
if not filenames or len(filenames) != len (url_list):
|
||||
info_dialog(self.gui, _("Cannot Update Anthology"),
|
||||
@@ -800,6 +803,10 @@ class FanFicFarePlugin(InterfaceAction):
|
||||
self.restore_cursor()
|
||||
|
||||
#print("urlmapfile:%s"%urlmapfile)
|
||||
print("completed_list:%s"%completed_list)
|
||||
|
||||
# remove_dir(tdir)
|
||||
# return
|
||||
|
||||
# AddNewDialog collects URLs, format and presents buttons.
|
||||
# add_new_dialog is modeless and reused, both for new stories
|
||||
@@ -811,7 +818,8 @@ class FanFicFarePlugin(InterfaceAction):
|
||||
newmerge=False,
|
||||
extrapayload=urlmapfile,
|
||||
extraoptions={'tdir':tdir,
|
||||
'mergebook':mergebook})
|
||||
'mergebook':mergebook,
|
||||
'completed_list':completed_list})
|
||||
# Need to use AddNewDialog modal here because it's an update
|
||||
# of an existing book. Don't want the user deleting it or
|
||||
# switching libraries on us.
|
||||
@@ -1029,6 +1037,18 @@ class FanFicFarePlugin(InterfaceAction):
|
||||
logger.debug("url:%s"%url)
|
||||
mi = None
|
||||
|
||||
# if updating a merged book and it's complete, skip and reuse
|
||||
if merge and url in options['completed_list']:
|
||||
book['completed_skip'] = True
|
||||
book['outfile'] = book['epub_for_update']
|
||||
book['status'] = _('Reuse')
|
||||
book['author'] = []
|
||||
book['title'] = ''
|
||||
book['comment'] = _('Reuse existing Completed book in anthology as is.')
|
||||
book['tags'] = []
|
||||
book['all_metadata'] = {}
|
||||
return
|
||||
|
||||
## Check reject list. Redundant with below for when story URL
|
||||
## changes, but also kept here to avoid network hit in most
|
||||
## common case where given url is story url.
|
||||
|
||||
@@ -129,6 +129,9 @@ def do_download_for_worker(book,options,merge,notification=lambda x,y:x):
|
||||
|
||||
try:
|
||||
book['comment'] = _('Download started...')
|
||||
|
||||
if 'completed_skip' in book and book['completed_skip']:
|
||||
return book
|
||||
|
||||
configuration = get_fff_config(book['url'],
|
||||
options['fileform'],
|
||||
|
||||
+14
-1
@@ -18,6 +18,10 @@ import bs4 as bs
|
||||
def get_dcsource(inputio):
|
||||
return get_update_data(inputio,getfilecount=False,getsoups=False)[0]
|
||||
|
||||
def get_dcsource_iscompleted(inputio):
|
||||
result = get_update_data(inputio,getfilecount=False,getsoups=False)
|
||||
return (result[0],result[9])
|
||||
|
||||
def get_dcsource_chaptercount(inputio):
|
||||
return get_update_data(inputio,getfilecount=True,getsoups=False)[:2] # (source,filecount)
|
||||
|
||||
@@ -39,6 +43,14 @@ def get_update_data(inputio,
|
||||
except:
|
||||
source=None
|
||||
|
||||
# Look for 'Completed' in dc:subject tags.
|
||||
is_completed = False
|
||||
for subject in firstmetadom.getElementsByTagName("dc:subject"):
|
||||
tag = subject.firstChild.data.encode("utf-8")
|
||||
if tag == 'Completed':
|
||||
is_completed = True
|
||||
break
|
||||
|
||||
## Save the path to the .opf file--hrefs inside it are relative to it.
|
||||
relpath = get_path_part(rootfilename)
|
||||
|
||||
@@ -177,7 +189,8 @@ def get_update_data(inputio,
|
||||
#for k in images.keys():
|
||||
#print("\tlongdesc:%s\n\tData len:%s\n"%(k,len(images[k])))
|
||||
# print("datamaps:%s"%datamaps)
|
||||
return (source,filecount,soups,images,oldcover,calibrebookmark,logfile,urlsoups,datamaps)
|
||||
return (source,filecount,soups,images,oldcover,calibrebookmark,
|
||||
logfile,urlsoups,datamaps,is_completed)
|
||||
|
||||
def get_path_part(n):
|
||||
relpath = os.path.dirname(n)
|
||||
|
||||
Reference in New Issue
Block a user