mirror of
https://github.com/wassname/FanFicFare.git
synced 2026-09-10 11:40:24 +08:00
Need makezip.py for makeplugin.py.
This commit is contained in:
@@ -19,6 +19,7 @@ from calibre.ptempfile import PersistentTemporaryFile
|
||||
from calibre.ebooks.metadata import MetaInformation
|
||||
from calibre.ebooks.metadata.meta import get_metadata
|
||||
from calibre.gui2 import error_dialog, warning_dialog, question_dialog, info_dialog
|
||||
from calibre.gui2.tools import convert_single_ebook
|
||||
from calibre.gui2.actions import InterfaceAction
|
||||
from calibre.gui2.threaded_jobs import ThreadedJob
|
||||
|
||||
@@ -385,7 +386,7 @@ class FanFictionDownLoaderPlugin(InterfaceAction):
|
||||
mi.comments = story.getMetadata("description")
|
||||
|
||||
identicalbooks = self.db.find_identical_books(mi)
|
||||
print(identicalbooks)
|
||||
#print(identicalbooks)
|
||||
addedcount=0
|
||||
if identicalbooks and collision != ADDNEW:
|
||||
## more than one match? add to first off the list.
|
||||
@@ -436,6 +437,24 @@ class FanFictionDownLoaderPlugin(InterfaceAction):
|
||||
|
||||
db.add_format_with_hooks(book_id, fileform, tmp, index_is_id=True)
|
||||
|
||||
# get all formats.
|
||||
fmts = set([x.lower() for x in db.formats(book_id, index_is_id=True).split(',')])
|
||||
for fmt in fmts:
|
||||
if fmt != fileform:
|
||||
print("f:"+fmt)
|
||||
## calling convert doesn't work here because we're in a BG thread.
|
||||
# (jobs,changed,bad)=convert_single_ebook(self.gui,
|
||||
# db,
|
||||
# [book_id],
|
||||
# auto_conversion=True,
|
||||
# out_format=fmt)
|
||||
# print("jobs:%s changed:%s bad:%s"%(jobs,changed,bad))
|
||||
db.remove_format(book_id, fmt,index_is_id=True)#, notify=False
|
||||
|
||||
for a in self.gui.iactions: # ['Convert Books']
|
||||
print("a:%s"%a)
|
||||
|
||||
|
||||
if updatemeta or collision == CALIBREONLY:
|
||||
db.set_metadata(book_id,mi)
|
||||
|
||||
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# epubmerge.py 1.0
|
||||
|
||||
# Copyright 2011, Jim Miller
|
||||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import os, zipfile, sys
|
||||
from glob import glob
|
||||
|
||||
def addFolderToZip(myZipFile,folder,exclude=[]):
|
||||
folder = folder.encode('ascii') #convert path to ascii for ZipFile Method
|
||||
excludelist=[]
|
||||
for ex in exclude:
|
||||
excludelist.extend(glob(folder+"/"+ex))
|
||||
for file in glob(folder+"/*"):
|
||||
if file in excludelist:
|
||||
continue
|
||||
if os.path.isfile(file):
|
||||
#print file
|
||||
myZipFile.write(file, file, zipfile.ZIP_DEFLATED)
|
||||
elif os.path.isdir(file):
|
||||
addFolderToZip(myZipFile,file,exclude=exclude)
|
||||
|
||||
def createZipFile(filename,mode,files,exclude=[]):
|
||||
myZipFile = zipfile.ZipFile( filename, mode ) # Open the zip file for writing
|
||||
excludelist=[]
|
||||
for ex in exclude:
|
||||
excludelist.extend(glob(ex))
|
||||
for file in files:
|
||||
if file in excludelist:
|
||||
continue
|
||||
file = file.encode('ascii') #convert path to ascii for ZipFile Method
|
||||
if os.path.isfile(file):
|
||||
(filepath, filename) = os.path.split(file)
|
||||
#print file
|
||||
myZipFile.write( file, filename, zipfile.ZIP_DEFLATED )
|
||||
if os.path.isdir(file):
|
||||
addFolderToZip(myZipFile,file,exclude=exclude)
|
||||
myZipFile.close()
|
||||
return (1,filename)
|
||||
|
||||
Reference in New Issue
Block a user