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