Skip to content

Commit

Permalink
Merge pull request #25 from Zeal-L/develop
Browse files Browse the repository at this point in the history
Ready for 1.0.4
  • Loading branch information
Zeal-L authored Apr 24, 2023
2 parents 7fa63c0 + a9c0418 commit ff2b5c8
Show file tree
Hide file tree
Showing 28 changed files with 1,026 additions and 997 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
# ([String]). Block pull requests that introduce vulnerabilities in the scopes that match this list (optional)
# Possible values: "development", "runtime", "unknown"
fail-on-scopes: development, runtime
deny-licenses: LGPL-2.0, BSD-2-Clause
deny-licenses: BSD-2-Clause



4 changes: 2 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ pypdf2 = ">=3.0.1"
pyside6 = ">=6.4.2"
requests = ">=2.28.1"
retrying = ">=1.3.4"
pyinstaller = ">=5.8.0"
pillow = ">=9.4.0"
pypinyin = ">=0.48.0"

[dev-packages]
rich = "*"
pylint = "*"
auto-py-to-exe = "*"
pyinstaller = "*"

[requires]
python_version = "3.11"
800 changes: 277 additions & 523 deletions Pipfile.lock

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
6. 如果提示"Cookie有效!"那么就成功了!
7. 否则请再次确认上述步骤,检查是否正确复制内容不含空格,还有疑问的话欢迎联系作者或提Issues
- **搜索 / 选择章节 / 下载 的功能介绍我想已经不言而喻了,这就是图形化界面的好处!**
- **值得注意的是:本软件还未实现断点续传和下载任务缓存的功能 ~~(毕竟一章漫画太小了,好像也没什么必要,断了不如重下)~~,所以请确保不要在下载中途关闭!**
- **值得注意的是:本软件不支持断点续传和下载任务缓存的功能 ~~(毕竟一章漫画太小了,好像也没什么必要,断了不如重下)~~,所以请确保不要在下载中途关闭!**
- 如果程序意外中断,可以选择把下了一半的文件都删掉(一般在目标漫画文件夹的根目录下),重新下载
- **程序缓存和日志历史文件存在 `C:\Users\AppData\Roaming\BiliBili-Manga-Downloader\` 目录下,可以通过"清空用户数据"功能一键删除**
- **如果想用"本地库存"功能,需要注意的是:下载好的漫画的文件夹名以及章节名都不能更改,否则将会无法正确读取漫画数据**
Expand All @@ -78,7 +78,6 @@
- 🟦 添加不同的界面主题
- 🟦 添加一个启动程序加载进度条
- 🟦 添加我的追漫界面,以及追漫功能
- 🟦 下载任务的暂停和继续功能,断点续传。以及下载任务的持久化,本地缓存
- 🟦 对于有特典的漫画,提供特典下载界面
- **已解决**
-~~添加检测cookie无效或者过期功能,并且弹窗~~
Expand Down Expand Up @@ -127,6 +126,11 @@
- 是否更改依赖性

## ⚰️ 更新记录
### v1.0.4 - *2022-04-24*
- 优化使用体验:我的库存列表现在按照漫画名排序
- 优化项目结构: 重新分类了原始UI文件和资源文件,并更新了打包脚本
- 更新依赖项:更新了过去一个月积攒的 pyside6,pillow 等 python 库的新版本

### v1.0.3 - *2022-03-12*
- 修复bug:使用7z保存时可能会因为文件名特殊字符引起报错;添加针对“.”的正则过滤
- 优化配置:全局网络请求的 timeout 以及 max retry 值增大一倍
Expand Down
6 changes: 3 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
import sys
from ctypes import windll

sys.path.append(os.path.join(os.path.dirname(__file__), 'src', 'ui'))
sys.path.append(os.path.join(os.path.dirname(__file__), "src", "ui"))

from PySide6.QtWidgets import QApplication, QMessageBox

from src.ui.MainGUI import MainGUI
from src.utils import (__version__)
from src.utils import __version__

if __name__ == '__main__':
if __name__ == "__main__":
app = QApplication.instance() or QApplication(sys.argv)

if windll.user32.FindWindowW(None, f"哔哩哔哩漫画下载器 v{__version__}") != 0:
Expand Down
2 changes: 1 addition & 1 deletion app.spec
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ exe = EXE(
codesign_identity=None,
entitlements_file=None,
version='.\\version.txt',
icon=['.\\src\\ui\\imgs\\BiliBili_favicon.ico'],
icon=['.\\src\\ui\\PySide_src\\imgs\\BiliBili_favicon.ico'],
)
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pipenv run pyinstaller app.spec
echo -e "\033[34m\n pyinstaller 移动可执行文件到根目录 ... \n\033[0m"
cp -r dist/* ./
rm -rf dist
rm -rf build

echo -e "\033[32m\n 项目构建完成 ... \n\033[0m"

16 changes: 8 additions & 8 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ echo -e "\033[34m\n 安装pipenv(如果还没有安装)... \n\033[0m"
pip3 install pipenv

echo -e "\033[34m\n 安装所有依赖项 ... \n\033[0m"
pipenv install --dev
pipenv run pipenv install --dev

echo -e "\033[34m\n 重新编译UI文件 ... \n\033[0m"
pyside6-rcc src/ui/resource.qrc -o src/ui/resource_rc.py
pyside6-uic src/ui/mainWidget.ui -o src/ui/ui_mainWidget.py
pyside6-uic src/ui/myAbout.ui -o src/ui/ui_myAbout.py
pipenv run pyside6-rcc src/ui/PySide_src/resource.qrc -o src/ui/PySide_src/resource_rc.py
pipenv run pyside6-uic src/ui/PySide_src/mainWidget.ui -o src/ui/PySide_src/mainWidget_ui.py
pipenv run pyside6-uic src/ui/PySide_src/myAbout.ui -o src/ui/PySide_src/myAbout_ui.py

echo -e "\033[34m\n 修复UI文件中的导入问题 ... \n\033[0m"
sed -i 's/resource_rc/src.ui.resource_rc/' src/ui/ui_mainWidget.py
sed -i 's/resource_rc/src.ui.resource_rc/' src/ui/ui_myAbout.py
sed -i 's/resource_rc/src.ui.PySide_src.resource_rc/' src/ui/PySide_src/mainWidget_ui.py
sed -i 's/resource_rc/src.ui.PySide_src.resource_rc/' src/ui/PySide_src/myAbout_ui.py

echo -e "\033[34m\n 显示项目目录 ... \n\033[0m"
pipenv --where
pipenv run pipenv --where

echo -e "\033[34m\n 显示虚拟环境目录 ... \n\033[0m"
pipenv --venv
pipenv run pipenv --venv

echo -e "\033[32m\n 项目部署完成!(输入 pipenv shell 进入虚拟环境) \n\033[0m"

71 changes: 43 additions & 28 deletions src/Comic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from __future__ import annotations

import typing
Expand All @@ -8,30 +7,30 @@
import re

from src.Episode import Episode
from src.utils import (logger, MAX_RETRY_SMALL, RETRY_WAIT_EX, TIMEOUT_SMALL)
from src.utils import logger, MAX_RETRY_SMALL, RETRY_WAIT_EX, TIMEOUT_SMALL

if typing.TYPE_CHECKING:
from ui.MainGUI import MainGUI


class Comic:
"""单本漫画 综合信息类
"""
"""单本漫画 综合信息类"""

def __init__(self, comic_id: int, mainGUI: MainGUI) -> None:
self.mainGUI = mainGUI
self.comic_id = comic_id
self.sessdata = mainGUI.getConfig("cookie")
self.sessdata = mainGUI.getConfig("cookie")
self.save_path = mainGUI.getConfig("save_path")
self.num_thread = mainGUI.getConfig("num_thread")
self.num_downloaded = 0
self.episodes = []
self.data = None
self.detail_url = 'https://manga.bilibili.com/twirp/comic.v1.Comic/ComicDetail?device=pc&platform=web'
self.detail_url = "https://manga.bilibili.com/twirp/comic.v1.Comic/ComicDetail?device=pc&platform=web"
self.headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',
'origin': 'https://manga.bilibili.com',
'referer': f'https://manga.bilibili.com/detail/mc{comic_id}?from=manga_homepage',
'cookie': f'SESSDATA={self.sessdata}'
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36",
"origin": "https://manga.bilibili.com",
"referer": f"https://manga.bilibili.com/detail/mc{comic_id}?from=manga_homepage",
"cookie": f"SESSDATA={self.sessdata}",
}
self.payload = {"comic_id": self.comic_id}

Expand All @@ -43,33 +42,48 @@ def getComicInfo(self) -> dict:
dict: 漫画信息
"""

@retry(stop_max_delay=MAX_RETRY_SMALL, wait_exponential_multiplier=RETRY_WAIT_EX)
@retry(
stop_max_delay=MAX_RETRY_SMALL, wait_exponential_multiplier=RETRY_WAIT_EX
)
def _() -> dict:
try:
res = requests.post(self.detail_url, headers=self.headers, data=self.payload, timeout=TIMEOUT_SMALL)
res = requests.post(
self.detail_url,
headers=self.headers,
data=self.payload,
timeout=TIMEOUT_SMALL,
)
except requests.RequestException as e:
logger.warning(f"漫画id:{self.comic_id} 获取漫画信息失败! 重试中...\n{e}")
raise e
if res.status_code != 200:
logger.warning(f'漫画id:{self.comic_id} 爬取漫画信息失败! 状态码:{res.status_code}, 理由: {res.reason} 重试中...')
logger.warning(
f"漫画id:{self.comic_id} 爬取漫画信息失败! 状态码:{res.status_code}, 理由: {res.reason} 重试中..."
)
raise requests.HTTPError()
return res.json()['data']
return res.json()["data"]

try:
self.data = _()
except requests.RequestException as e:
logger.error(f'漫画id:{self.comic_id} 重复获取漫画信息多次后失败!\n{e}')
logger.error(f"漫画id:{self.comic_id} 重复获取漫画信息多次后失败!\n{e}")
logger.exception(e)
return {}

#?###########################################################
#? 解析漫画信息
self.data['author_name'] = ','.join(self.data['author_name'])
self.data['author_name'] = self.data['author_name'].replace('作者:', '').replace('出品:', '')
self.data['author_name'] = re.sub(r'[\\/:*?"<>|]', ' ', self.data['author_name'])
self.data['styles'] = ','.join(self.data['styles'])
self.data['save_path'] = f"{self.save_path}/《{self.data['title']}》 作者:{self.data['author_name']} ID-{self.comic_id}"
self.data['ID'] = self.comic_id
# ?###########################################################
# ? 解析漫画信息
self.data["author_name"] = ",".join(self.data["author_name"])
self.data["author_name"] = (
self.data["author_name"].replace("作者:", "").replace("出品:", "")
)
self.data["author_name"] = re.sub(
r'[\\/:*?"<>|]', " ", self.data["author_name"]
)
self.data["styles"] = ",".join(self.data["styles"])
self.data[
"save_path"
] = f"{self.save_path}/《{self.data['title']}》 作者:{self.data['author_name']} ID-{self.comic_id}"
self.data["ID"] = self.comic_id
return self.data

############################################################
Expand All @@ -84,11 +98,13 @@ def getEpisodesInfo(self) -> list[Episode]:
if not self.data:
return []

#?###########################################################
#? 解析章节
ep_list = self.data['ep_list']
# ?###########################################################
# ? 解析章节
ep_list = self.data["ep_list"]
for episode in reversed(ep_list):
epi = Episode(episode, self.sessdata, self.comic_id, self.data, self.mainGUI)
epi = Episode(
episode, self.sessdata, self.comic_id, self.data, self.mainGUI
)
self.episodes.append(epi)
if epi.isDownloaded():
self.num_downloaded += 1
Expand All @@ -102,4 +118,3 @@ def getNumDownloaded(self) -> int:
int: 已下载章节数
"""
return self.num_downloaded

Loading

0 comments on commit ff2b5c8

Please sign in to comment.