-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 将设置移动到单文件上 * 将epub/cbz/login功能分离并格式化代码 * 尽可能向前支持配置文件 * 进一步拆分,修复范围下载不会下载结束话数 * 删除cbz使用的Pinyin库(bug多) * 增加请求502停止重试以及调整cbz功能 * Update README.md * 完成合并要求
- Loading branch information
1 parent
f7b4d65
commit b070e3f
Showing
17 changed files
with
882 additions
and
775 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# These are supported funding model platforms | ||
|
||
custom: ['https://afdian.net/@sakura_society'] | ||
custom: [ 'https://afdian.net/@sakura_society' ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,40 @@ | ||
# -*- coding:utf-8 -*- | ||
|
||
|
||
from PIL import Image | ||
|
||
|
||
import os | ||
|
||
|
||
|
||
from PIL import Image | ||
|
||
|
||
def file_name(file_dir): | ||
L = [] | ||
for root, dirs, files in os.walk(file_dir): | ||
for file in files: | ||
if os.path.splitext(file)[1] == '.png': # 假设漫画全部都是png格式 | ||
L.append(os.path.join(root, file)) # 输出为数组 | ||
return L | ||
|
||
|
||
def join(png1, png2, NewImageName, SavePath): | ||
img1, img2 = Image.open(png1), Image.open(png2) | ||
size1, size2 = img1.size, img2.size # 获取两个图片长宽 | ||
joint = Image.new('RGB', (size1[0]+size2[0], size1[1])) | ||
joint = Image.new('RGB', (size1[0] + size2[0], size1[1])) | ||
loc1, loc2 = (0, 0), (size1[0], 0) | ||
joint.paste(img2, loc1) #如需要左到右拼接,只要将img2改成img1,img1改成img2即可 | ||
joint.paste(img2, loc1) # 如需要左到右拼接,只要将img2改成img1,img1改成img2即可 | ||
joint.paste(img1, loc2) | ||
joint.save('%s%s.png' % (SavePath,NewImageName)) # 输出 | ||
joint.save('%s%s.png' % (SavePath, NewImageName)) # 输出 | ||
|
||
|
||
def main(): | ||
ImgPath = input("图片文件夹位置(以/结尾):") | ||
SavePath = input("拼接后图片存放的位置(以/结尾):") | ||
image = file_name("ImgPath") # 获取当前目录下指定文件 | ||
j = 0 | ||
for i in image: | ||
NewImage = "%s-%s"%(j+1,j) #拼接之后的图片的文件名 | ||
join(image[j], image[j+1],NewImage,SavePath) # 如果是第一次就直接两图合并 | ||
j = j + 1 | ||
NewImage = "%s-%s" % (j + 1, j) # 拼接之后的图片的文件名 | ||
join(image[j], image[j + 1], NewImage, SavePath) # 如果是第一次就直接两图合并 | ||
j = j + 1 | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import os | ||
import zipfile | ||
|
||
import config | ||
|
||
|
||
def create_cbz(index, title, manga_name, save_dir, cbz_dir, path_word): | ||
xml_data = f'<?xml version="1.0"?>' \ | ||
'<ComicInfo xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' \ | ||
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' \ | ||
f'<Title>{title}</Title>' \ | ||
f'<Series>{manga_name}</Series>' \ | ||
f'<Number>{index}</Number>' \ | ||
f'</ComicInfo>' | ||
with open(os.path.join(os.path.join(config.SETTINGS['download_path'], save_dir), "ComicInfo.xml"), "w", | ||
encoding='utf8') as file: | ||
file.write(xml_data) | ||
|
||
start_dir = os.path.join(config.SETTINGS['download_path'], save_dir) | ||
file_name = f"{manga_name}-{title}.cbz" | ||
cbz_dir = os.path.join(cbz_dir, path_word) | ||
file_path = os.path.join(cbz_dir, file_name) | ||
|
||
# 检测漫画保存目录是否存在 | ||
if not os.path.exists(cbz_dir): | ||
os.makedirs(cbz_dir) | ||
|
||
# 只添加指定类型的文件到zip文件中 | ||
allowed_ext = ['.xml', '.jpg', '.png', '.jpeg', '.webp'] | ||
with zipfile.ZipFile(file_path, 'w', zipfile.ZIP_DEFLATED) as zip_file: | ||
for dir_path, dir_names, filenames in os.walk(start_dir): | ||
fpath = dir_path.replace(start_dir, '') | ||
fpath = fpath and fpath + os.sep or '' | ||
for filename in filenames: | ||
ext = os.path.splitext(filename)[1].lower() | ||
if ext in allowed_ext: | ||
zip_file.write(os.path.join(dir_path, filename), fpath + filename) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import datetime | ||
|
||
SETTINGS = { | ||
"download_path": None, | ||
"authorization": None, | ||
"use_oversea_cdn": None, | ||
"use_webp": None, | ||
"proxies": None, | ||
"api_url": None, | ||
"HC": None, | ||
"CBZ": None, | ||
"cbz_path": None, | ||
"api_time": 0.0, | ||
"API_COUNTER": 0, | ||
"loginPattern": "0", | ||
"salt": None, | ||
"username": None, | ||
"password": None, | ||
"send_to_kindle": None, | ||
"kcc_cmd": None, | ||
"email_address": None, | ||
"email_passwd": None, | ||
"kindle_address": None, | ||
"email_smtp_address": None | ||
} | ||
|
||
# ''' | ||
# "epub_and_mail_to_kindle": None, | ||
# "kcc_cmd": None, | ||
# "email_address": None, | ||
# "email_passwd": None, | ||
# "kindle_address": None, | ||
# ''' | ||
|
||
# 全局化设置,备份,防止命令行参数导致设置错位 | ||
OG_SETTINGS = { | ||
"download_path": None, | ||
"authorization": None, | ||
"use_oversea_cdn": None, | ||
"use_webp": None, | ||
"proxies": None, | ||
"api_url": None, | ||
"HC": None, | ||
"CBZ": None, | ||
"cbz_path": None, | ||
"api_time": 0.0, | ||
"API_COUNTER": 0, | ||
"loginPattern": "0", | ||
"salt": None, | ||
"username": None, | ||
"password": None, | ||
"send_to_kindle": None, | ||
"kcc_cmd": None, | ||
"email_address": None, | ||
"email_passwd": None, | ||
"kindle_address": None, | ||
"email_smtp_address": None | ||
} | ||
|
||
# 全局化headers,节省空间 | ||
|
||
API_HEADER = { | ||
'User-Agent': '"User-Agent" to "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, ' | ||
'like Gecko) Chrome/102.0.5005.124 Safari/537.36 Edg/102.0.1245.44"', | ||
'version': datetime.datetime.now().strftime("%Y.%m.%d"), | ||
'region': '0', | ||
'webp': '0', | ||
"platform": "1", | ||
"referer": "https://www.copymanga.site/" | ||
} | ||
|
||
PROXIES = {} | ||
|
||
API_COUNTER = 0 | ||
IMG_API_COUNTER = 0 | ||
IMG_CURRENT_TIME = 0 |
Oops, something went wrong.