mirror of
https://github.com/yihong0618/Kindle_download_helper.git
synced 2025-11-22 07:59:04 +08:00
fix: #132
This commit is contained in:
@@ -36,7 +36,7 @@ from kindle_download_helper.config import (
|
||||
MY_KINDLE_STATS_INFO_HEAD,
|
||||
)
|
||||
from kindle_download_helper.dedrm import MobiBook, get_pid_list
|
||||
from kindle_download_helper.utils import replace_readme_comments
|
||||
from kindle_download_helper.utils import replace_readme_comments, trim_title_suffix
|
||||
|
||||
try:
|
||||
import browser_cookie3
|
||||
@@ -490,7 +490,7 @@ class Kindle:
|
||||
pathlib.Path(out).touch()
|
||||
except OSError as e:
|
||||
if e.errno == 36: # means file name too long
|
||||
name = self.trim_title_suffix(title) + extname
|
||||
name = trim_title_suffix(title) + extname
|
||||
logger.info(f"Original filename too long, trim to {name}")
|
||||
out = os.path.join(self.out_dir, name)
|
||||
out_dedrm = os.path.join(self.out_dedrm_dir, name)
|
||||
@@ -559,6 +559,3 @@ class Kindle:
|
||||
os.path.join(self.out_dir, "key.txt")
|
||||
)
|
||||
)
|
||||
|
||||
def trim_title_suffix(self, title):
|
||||
return re.sub(r"(([^)]+)?|【[^】]+】?)", "", title)
|
||||
|
||||
@@ -24,6 +24,7 @@ from kindle_download_helper.config import (
|
||||
DEFAULT_OUT_EPUB_DIR,
|
||||
)
|
||||
from kindle_download_helper.dedrm import MobiBook, get_pid_list
|
||||
from kindle_download_helper.utils import trim_title_suffix
|
||||
from kindle_download_helper.dedrm.kfxdedrm import KFXZipBook
|
||||
from kindle_download_helper.third_party.ion import DrmIon, DrmIonVoucher
|
||||
from kindle_download_helper.third_party.kfxlib import YJ_Book
|
||||
@@ -282,7 +283,10 @@ class NoKindle:
|
||||
tokens=self.tokens,
|
||||
)
|
||||
)
|
||||
book_name = self.library_dict.get(asin)
|
||||
|
||||
book_name = trim_title_suffix(
|
||||
self.library_dict.get(asin, "").encode("utf8").decode()
|
||||
)
|
||||
# we should support the dup name here
|
||||
name = book_name
|
||||
if book_name in self.book_name_set:
|
||||
@@ -393,7 +397,9 @@ class NoKindle:
|
||||
manifest_json_data = json.dumps(manifest)
|
||||
manifest_file.write_text(manifest_json_data)
|
||||
files.append(manifest_file)
|
||||
name = self.library_dict.get(asin)
|
||||
name = trim_title_suffix(
|
||||
self.library_dict.get(asin, "").encode("utf8").decode()
|
||||
)
|
||||
if len(name) > self.cut_length:
|
||||
name = name[: self.cut_length - 10]
|
||||
fn = name + "_" + asin + "_EBOK.kfx-zip"
|
||||
@@ -427,7 +433,9 @@ class NoKindle:
|
||||
tokens=self.tokens,
|
||||
)
|
||||
)
|
||||
name = self.library_dict.get(asin)
|
||||
name = trim_title_suffix(
|
||||
self.library_dict.get(asin, "").encode("utf8").decode()
|
||||
)
|
||||
if len(name) > self.cut_length:
|
||||
name = name[: self.cut_length - 10]
|
||||
out = Path(self.out_dir) / Path(name + ".azw3")
|
||||
|
||||
@@ -16,3 +16,7 @@ def replace_readme_comments(file_name, comment_str, comments_name):
|
||||
f.seek(0)
|
||||
f.write(text)
|
||||
f.truncate()
|
||||
|
||||
|
||||
def trim_title_suffix(title):
|
||||
return re.sub(r"(([^)]+)?|【[^】]+】?)", "", title)
|
||||
|
||||
Reference in New Issue
Block a user