mirror of
https://github.com/hect0x7/JMComic-Crawler-Python.git
synced 2025-09-26 22:31:30 +08:00
v1.9.1: 增加禁漫网站默认的下载路径规则,优化Github Actions工作流 (#27)
This commit is contained in:
parent
5f0243f369
commit
ec7b0879aa
28
.github/workflows/action_workflow.yml
vendored
28
.github/workflows/action_workflow.yml
vendored
@ -2,16 +2,15 @@ name: 下载JM本子
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "workflow" ]
|
||||
branches: [ 'workflow', 'workflow_local' ]
|
||||
paths:
|
||||
- '.github/workflows/*.yml' # 工作流定义
|
||||
- 'usage/**/*.py' # 工作流脚本
|
||||
- 'assets/config/*.yml' # 工作流配置
|
||||
pull_request:
|
||||
branches: [ "workflow" ]
|
||||
- 'assets/config/*.yml' # option配置文件
|
||||
- 'src/**/*.py' # 源码
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull_request:
|
||||
branches: [ 'workflow', 'workflow_local' ]
|
||||
|
||||
jobs:
|
||||
crawler:
|
||||
@ -23,12 +22,23 @@ jobs:
|
||||
with:
|
||||
python-version: "3.11"
|
||||
|
||||
- name: 安装依赖项
|
||||
- name: 安装依赖项(pip)
|
||||
if: ${{ github.ref == 'refs/heads/workflow' }}
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install jmcomic -i https://pypi.org/project --upgrade
|
||||
|
||||
- name: 安装依赖项(local)
|
||||
if: ${{ github.ref == 'refs/heads/workflow_local' }}
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install commonX -i https://pypi.org/project --upgrade
|
||||
pip install -e ./
|
||||
|
||||
- name: 运行下载脚本
|
||||
env:
|
||||
JM_USERNAME: ${{ secrets.JM_USERNAME }}
|
||||
JM_PASSWORD: ${{ secrets.JM_PASSWORD }}
|
||||
run: |
|
||||
cd ./usage/
|
||||
python jmcomic_workflows.py
|
||||
@ -41,11 +51,7 @@ jobs:
|
||||
- name: 上传结果
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
# Artifact name
|
||||
name: 下载完成的本子
|
||||
# A file, directory or wildcard pattern that describes what to upload
|
||||
path: /home/runner/work/jmcomic/下载完成的本子.tar.gz
|
||||
# The desired behavior if no files are found using the provided path.
|
||||
if-no-files-found: warn
|
||||
# Duration after which artifact will expire in days. 0 means using default retention.Minimum 1 day. Maximum 90 days unless changed from the repository settings page.
|
||||
retention-days: 90
|
61
.github/workflows/action_workflow_local.yml
vendored
61
.github/workflows/action_workflow_local.yml
vendored
@ -1,61 +0,0 @@
|
||||
# 这个工作流使用workflow_local分支的jmcomic模块。
|
||||
# 你可以在workflow_local分支修改jmcomic的源码,
|
||||
# 这样工作流就会使用你修改后的代码来下载禁漫本子。
|
||||
|
||||
name: 下载JM本子 (Local)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "workflow_local" ]
|
||||
paths:
|
||||
- '.github/workflows/*.yml' # 工作流定义
|
||||
- 'usage/**/*.py' # 工作流脚本
|
||||
- 'assets/config/*.yml' # 工作流配置
|
||||
- 'src/**/*.py' # 源码
|
||||
|
||||
pull_request:
|
||||
branches: [ "workflow_local" ]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
crawler:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Python 3.11
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.11"
|
||||
|
||||
- name: 安装依赖项
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install commonX -i https://pypi.org/project --upgrade
|
||||
pip install -e ./
|
||||
|
||||
- name: 运行下载脚本
|
||||
env:
|
||||
JM_USERNAME: ${{ secrets.JM_USERNAME }}
|
||||
JM_PASSWORD: ${{ secrets.JM_PASSWORD }}
|
||||
run: |
|
||||
cd ./usage/
|
||||
python jmcomic_workflows.py
|
||||
|
||||
- name: 压缩下载的漫画
|
||||
run: |
|
||||
cd /home/runner/work/jmcomic/download/
|
||||
tar -zcvf ../下载完成的本子.tar.gz ./
|
||||
|
||||
- name: 上传结果
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
# Artifact name
|
||||
name: 下载完成的本子
|
||||
# A file, directory or wildcard pattern that describes what to upload
|
||||
path: /home/runner/work/jmcomic/下载完成的本子.tar.gz
|
||||
# The desired behavior if no files are found using the provided path.
|
||||
if-no-files-found: warn
|
||||
# Duration after which artifact will expire in days. 0 means using default retention.Minimum 1 day. Maximum 90 days unless changed from the repository settings page.
|
||||
retention-days: 90
|
@ -21,3 +21,4 @@ client_config:
|
||||
- cffi_Session
|
||||
meta_data:
|
||||
cookies: null
|
||||
impersonate: chrome110
|
@ -2,6 +2,6 @@
|
||||
# 被依赖方 <--- 使用方
|
||||
# config <--- entity <--- toolkit <--- client <--- option
|
||||
|
||||
__version__ = '1.9.0'
|
||||
__version__ = '1.9.1'
|
||||
|
||||
from .api import *
|
||||
|
@ -80,6 +80,9 @@ class DownloadDirTree:
|
||||
# 根目录 / Photo号 / 图片文件
|
||||
Bd_Id_Image = 5
|
||||
|
||||
# 根目录 / AlbumId / Photo序号 / 图片文件
|
||||
Bd_Id_Index_image = 6 # 禁漫网站的默认下载方式
|
||||
|
||||
AdditionalHandler = Callable[
|
||||
['DownloadDirTree', Optional[JmAlbumDetail], JmPhotoDetail],
|
||||
str
|
||||
@ -163,6 +166,10 @@ class DownloadDirTree:
|
||||
|
||||
return dirpath(None, photo_dir(4))
|
||||
|
||||
elif flag == 6:
|
||||
# 根目录 / AlbumId / Photo序号 / 图片文件
|
||||
return dirpath(photo.album_id, str(photo.album_index))
|
||||
|
||||
else:
|
||||
if flag in self.additional_tree_flag_handler_mapping:
|
||||
return self.additional_tree_flag_handler_mapping[flag](self, album, photo)
|
||||
|
@ -1,8 +1,7 @@
|
||||
# 下方填入你要下载的本子的id,一行一个。
|
||||
# 每行的首尾可以有空白字符
|
||||
jm_albums = '''
|
||||
380460
|
||||
|
||||
438696
|
||||
|
||||
|
||||
'''
|
||||
@ -20,6 +19,12 @@ def main():
|
||||
client.enable_cache()
|
||||
|
||||
# 检查环境变量中是否有禁漫的用户名和密码,如果有则登录
|
||||
# 禁漫的大部分本子,下载是不需要登录的,少部分敏感题材需要登录
|
||||
# 如果你希望以登录状态下载本子,你需要自己配置一下Github Actions的 `secrets`
|
||||
# 配置的方式很简单,网页上点一点就可以了
|
||||
# 具体做法请去看官方教程:https://docs.github.com/en/actions/security-guides/encrypted-secrets
|
||||
|
||||
# 萌新注意!!!如果你想 `开源` 你的禁漫帐号,你也可以直接把账号密码写到下面的代码😅
|
||||
|
||||
def get_env(name):
|
||||
import os
|
||||
|
Loading…
Reference in New Issue
Block a user