1.下载相关工具:
calibre5.1 下载路径 : https://download.calibre-ebook.com/5.1.0
calibre5.1 src源代码下载路径: https://download.calibre-ebook.com
2.安装calibre5.1
3.修改源代码
修改backend.py文件
~/calibre-5.1.0/src/calibre-5.1.0/src/calibre/db/backend.py
修改替换以下两个函数
def construct_path_name( self , book_id, title, author):
'''
Construct the directory name for this book based on its metadata.
'''
book_id = ' (%d)' % book_id
l = self .PATH_LIMIT - ( len (book_id) / / 2 ) - 2
#author = ascii_filename(author)[:l]
#title = ascii_filename(title.lstrip())[:l].rstrip()
author = author[:l]
title = title.lstrip()[:l].rstrip()
if not title:
title = 'Unknown' [:l]
try :
while author[ - 1 ] in ( ' ' , '.' ):
author = author[: - 1 ]
except IndexError:
author = ''
if not author:
author = 'Unknown'
if author.upper() in WINDOWS_RESERVED_NAMES:
author + = 'w'
return '%s/%s%s' % (author, title, book_id)
def construct_file_name(self, book_id, title, author, extlen):
'''
Construct the file name for this book based on its metadata.
'''
extlen = max(extlen, 14) # 14 accounts for ORIGINAL_EPUB
# The PATH_LIMIT on windows already takes into account the doubling
# (it is used to enforce the total path length limit, individual path
# components can be much longer than the total path length would allow on
# windows).
l = (self.PATH_LIMIT - (extlen // 2) - 2) if iswindows else ((self.PATH_LIMIT - extlen - 2) // 2)
if l < 5:
raise ValueError('Extension length too long: %d' % extlen)
#author = ascii_filename(author)[:l]
#title = ascii_filename(title.lstrip())[:l].rstrip()
author = author[:l]
title = title.lstrip()[:l].rstrip()
if not title:
title = 'Unknown'[:l]
name = title + ' - ' + author
while name.endswith('.'):
name = name[:-1]
if not name:
name = 'Unknown'
return name
4.编译和文件替换
将修改过的backend.py进行编译,需要python3.8版本
~\Python38\python.exe -O -m py_compile src\calibre\db\backend.py
先备份原来的backend.pyc,然后将刚才编译的文件进行替换
D:\Program Files\Calibre2\app\pylib.zip\calibre\db\backend.pyc
重新运行calibre5.1,修改成功
5.修改文件下载地址
链接: https://pan.baidu.com/s/1AnVg42cJ7WrFAd8NaPbiUw
提取码: vh4s