mirror of
https://github.com/ciromattia/kcc
synced 2025-12-13 01:36:27 +00:00
pdf metadata
This commit is contained in:
@@ -590,6 +590,7 @@ def buildPDF(path, title, cover=None, output_file=None):
|
|||||||
start = perf_counter()
|
start = perf_counter()
|
||||||
# open empty PDF
|
# open empty PDF
|
||||||
with pymupdf.open() as doc:
|
with pymupdf.open() as doc:
|
||||||
|
doc.set_metadata({'title': title, 'author': options.authors[0]})
|
||||||
# Stream images to PDF
|
# Stream images to PDF
|
||||||
for root, dirs, files in os.walk(os.path.join(path, "OEBPS", "Images")):
|
for root, dirs, files in os.walk(os.path.join(path, "OEBPS", "Images")):
|
||||||
files.sort(key=OS_SORT_KEY)
|
files.sort(key=OS_SORT_KEY)
|
||||||
@@ -920,7 +921,7 @@ def getOutputFilename(srcpath, wantedname, ext, tomenumber):
|
|||||||
return filename
|
return filename
|
||||||
|
|
||||||
|
|
||||||
def getComicInfo(path, originalpath):
|
def getMetadata(path, originalpath):
|
||||||
xmlPath = os.path.join(path, 'ComicInfo.xml')
|
xmlPath = os.path.join(path, 'ComicInfo.xml')
|
||||||
options.comicinfo_chapters = []
|
options.comicinfo_chapters = []
|
||||||
options.summary = ''
|
options.summary = ''
|
||||||
@@ -939,6 +940,7 @@ def getComicInfo(path, originalpath):
|
|||||||
else:
|
else:
|
||||||
defaultAuthor = False
|
defaultAuthor = False
|
||||||
options.authors = [options.author]
|
options.authors = [options.author]
|
||||||
|
|
||||||
if os.path.exists(xmlPath):
|
if os.path.exists(xmlPath):
|
||||||
try:
|
try:
|
||||||
xml = metadata.MetadataParser(xmlPath)
|
xml = metadata.MetadataParser(xmlPath)
|
||||||
@@ -971,6 +973,13 @@ def getComicInfo(path, originalpath):
|
|||||||
options.summary = xml.data['Summary']
|
options.summary = xml.data['Summary']
|
||||||
os.remove(xmlPath)
|
os.remove(xmlPath)
|
||||||
|
|
||||||
|
if originalpath.lower().endswith('.pdf'):
|
||||||
|
with pymupdf.open(originalpath) as doc:
|
||||||
|
if options.metadatatitle and doc.metadata['title']:
|
||||||
|
options.title = doc.metadata['title']
|
||||||
|
if defaultAuthor and doc.metadata['author']:
|
||||||
|
options.authors = [doc.metadata['author']]
|
||||||
|
|
||||||
|
|
||||||
def getDirectorySize(start_path='.'):
|
def getDirectorySize(start_path='.'):
|
||||||
total_size = 0
|
total_size = 0
|
||||||
@@ -1503,7 +1512,7 @@ def makeBook(source, qtgui=None):
|
|||||||
print("Preparing source images...")
|
print("Preparing source images...")
|
||||||
path = getWorkFolder(source)
|
path = getWorkFolder(source)
|
||||||
print("Checking images...")
|
print("Checking images...")
|
||||||
getComicInfo(os.path.join(path, "OEBPS", "Images"), source)
|
getMetadata(os.path.join(path, "OEBPS", "Images"), source)
|
||||||
removeNonImages(os.path.join(path, "OEBPS", "Images"))
|
removeNonImages(os.path.join(path, "OEBPS", "Images"))
|
||||||
detectSuboptimalProcessing(os.path.join(path, "OEBPS", "Images"), source)
|
detectSuboptimalProcessing(os.path.join(path, "OEBPS", "Images"), source)
|
||||||
chapterNames, cover_path = sanitizeTree(os.path.join(path, 'OEBPS', 'Images'))
|
chapterNames, cover_path = sanitizeTree(os.path.join(path, 'OEBPS', 'Images'))
|
||||||
|
|||||||
Reference in New Issue
Block a user