Skip to content

异步化AutoBangumi,实现部分功能 #825

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 76 commits into
base: aio-refactor
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
4d7f9f5
update api to compalited aio
shininome Aug 3, 2024
196ba45
add aggeagted to bangumi match
shininome Aug 3, 2024
79eba48
add __all__ to conf
shininome Aug 3, 2024
1b4de1e
update qbdownloader
shininome Aug 3, 2024
f5319a4
change bangumi match_list
shininome Aug 3, 2024
8a7452b
try to add new rawparser
shininome Aug 3, 2024
04c3a6f
Asynchronous RSS Module
shininome Aug 3, 2024
5bb39c1
Asynchronous Searcher
shininome Aug 3, 2024
2727bc3
change load_image, Load Images on Demand (Lazy Loading)
shininome Aug 3, 2024
4dfb97b
Simple implementation of asynchronous core
shininome Aug 3, 2024
6106f31
notification could send any message you want
shininome Aug 3, 2024
92a7942
Fix asynchronous program test cases
shininome Aug 3, 2024
11abab0
Change bangumi matching logic
shininome Aug 3, 2024
24e6051
add proxy test
shininome Aug 3, 2024
7ecc900
change load img and block httpx info notification
shininome Aug 3, 2024
0cce358
Asynchronous manger
shininome Aug 3, 2024
4d68395
fix offset ineffective
shininome Aug 3, 2024
a2ea19e
fix bangumi save path not save in database
shininome Aug 4, 2024
db7b4e4
add eps
shininome Aug 4, 2024
feda573
fix notification title error
shininome Aug 4, 2024
c1566c5
add download queue
shininome Aug 29, 2024
77c36e0
fix test error
shininome Aug 29, 2024
ed0548b
add multi-account notifications
shininome Aug 29, 2024
90eaa6f
fix parser error
shininome Aug 29, 2024
41d027a
update WebUI to the latest
shininome Aug 29, 2024
8efb165
fix startup error
shininome Aug 29, 2024
a11ebef
fix update module to async
shininome Aug 29, 2024
c352b72
support episode .5
shininome Aug 30, 2024
c4c4227
fix offset error and updata collect and eps
shininome Aug 30, 2024
3da0e58
fix renamer error
shininome Aug 30, 2024
240ba2f
fix renamer task cancel error
shininome Sep 1, 2024
8656994
add delete torrent
shininome Sep 1, 2024
db7aa46
fix log
shininome Sep 1, 2024
1225eb7
pass magnet replace of file to download
shininome Sep 1, 2024
7b8c0cc
fix eps failed
shininome Sep 1, 2024
da3b6dd
fix eps not follow bangumi filter
shininome Sep 1, 2024
dcb0bea
update config to fit plugins
shininome Oct 23, 2024
919e978
update config
shininome Oct 23, 2024
f3bae9f
update enging
shininome Oct 23, 2024
dac1b60
update engine
shininome Oct 23, 2024
6585190
update to fit newest rule
shininome Oct 24, 2024
3bd514c
update to fie engine
shininome Oct 24, 2024
7e1f6f0
update renamer
shininome Oct 24, 2024
805e7bd
fix test error
shininome Oct 24, 2024
17ab918
fix path error
shininome Oct 24, 2024
fe42e11
add rust support
shininome Oct 24, 2024
6628981
fix rust
shininome Oct 24, 2024
e458e37
fix rust
shininome Oct 24, 2024
291820e
fix rust
shininome Oct 24, 2024
d1f064e
fix
shininome Oct 24, 2024
3b58cc3
fix
shininome Oct 24, 2024
d9b0a33
fix
shininome Oct 24, 2024
838aab2
update pydantic
shininome Oct 25, 2024
58e3e27
update config
shininome Oct 25, 2024
53f9f30
update renamer
shininome Oct 25, 2024
ffaf73e
fix requirement
shininome Oct 25, 2024
fe81475
fix config error
shininome Oct 25, 2024
a5577dc
fix renamer fail and remove httpx log
shininome Oct 26, 2024
47dc0c1
fix engine get all rss
shininome Oct 26, 2024
d287cf5
fix dmhy torrent hash
shininome Oct 27, 2024
7e56218
fix dmhy hash
shininome Oct 27, 2024
153350f
fix conf update error: plugin config will cover settings
shininome Jan 21, 2025
7ad63e2
update download client: could auto reconnect
shininome Jan 21, 2025
859fc26
update download client and fix renamer
shininome Feb 22, 2025
8e54ba2
update notification format and fix parser error
shininome Feb 22, 2025
54196ff
fix download queue event error set
shininome Feb 22, 2025
a31f53d
fix test error
shininome Feb 22, 2025
2cf1e46
update build v3 to v4
shininome Feb 22, 2025
6236c7e
remove old version mirgrate support,and fix download reload error
shininome Feb 22, 2025
f484713
refactor: improve parser and downloader modulesEE- Removed unnecessar…
shininome Feb 24, 2025
a47bb12
promImproved network requests and error handling on failure Optimize…
shininome Feb 24, 2025
76dc45f
fix raw parser error
shininome Feb 25, 2025
9637f69
fix bangumi will not be inserted when bangumi parser error
shininome Feb 25, 2025
c668f07
fix postlink type error
shininome Feb 25, 2025
bf007d5
renamer optimization
shininome Mar 6, 2025
bfce269
fix redirect error
shininome Mar 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 78 additions & 48 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ on:
types:
- closed
branches:
- main
- aio_test
push:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: '3.11'
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -28,11 +28,48 @@ jobs:
mkdir -p config
pytest

webui-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 9
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: cd webui && pnpm install

- name: build test
run: |
cd webui && pnpm test:build

version-info:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: If release
id: release
run: |
Expand Down Expand Up @@ -79,25 +116,33 @@ jobs:

build-webui:
runs-on: ubuntu-latest
needs: [ test, version-info ]
needs: [test, webui-test, version-info]
if: ${{ needs.version-info.outputs.release == 1 || needs.version-info.outputs.dev == 1 }}
strategy:
matrix:
node-version: [ 18 ]
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: pnpm/action-setup@v2
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
version: 8
node-version: 20
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 9
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
- uses: actions/cache@v4
name: Setup pnpm cache
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
cache-dependency-path: webui/pnpm-lock.yaml
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: cd webui && pnpm install
Expand All @@ -107,17 +152,17 @@ jobs:
cd webui && pnpm build

- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: dist
path: webui/dist

build-docker:
runs-on: ubuntu-latest
needs: [ build-webui, version-info ]
needs: [build-webui, version-info]
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Create Version info via tag
working-directory: ./backend/src
Expand All @@ -138,7 +183,7 @@ jobs:
uses: docker/metadata-action@v4
with:
images: |
estrellaxd/auto_bangumi
shinonomeow/auto_bangumi
ghcr.io/${{ github.repository }}
tags: |
type=raw,value=${{ needs.version-info.outputs.version }}
Expand All @@ -150,7 +195,7 @@ jobs:
uses: docker/metadata-action@v4
with:
images: |
estrellaxd/auto_bangumi
shinonomeow/auto_bangumi
ghcr.io/${{ github.repository }}
tags: |
type=raw,value=${{ needs.version-info.outputs.version }}
Expand All @@ -172,7 +217,7 @@ jobs:
password: ${{ secrets.ACCESS_TOKEN }}

- name: Download artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: dist
path: backend/src/dist
Expand Down Expand Up @@ -211,23 +256,23 @@ jobs:
builder: ${{ steps.buildx.output.name }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: false
tags: estrellaxd/auto_bangumi:test
tags: shinonomeow/auto_bangumi:test
cache-from: type=gha, scope=${{ github.workflow }}
cache-to: type=gha, scope=${{ github.workflow }}

release:
runs-on: ubuntu-latest
needs: [ build-docker, version-info ]
needs: [build-docker, version-info]
if: ${{ needs.version-info.outputs.release == 1 }}
outputs:
url: ${{ steps.release.outputs.url }}
version: ${{ needs.version-info.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Download artifact webui
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: dist
path: webui/dist
Expand All @@ -237,7 +282,7 @@ jobs:
cd webui && ls -al && tree && zip -r dist.zip dist

- name: Download artifact app
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: dist
path: backend/src/dist
Expand All @@ -247,11 +292,10 @@ jobs:
run: |
echo ${{ needs.version-info.outputs.version }}
echo "VERSION='${{ needs.version-info.outputs.version }}'" >> module/__version__.py

- name: Copy requirements.txt
working-directory: ./backend
run:
cp requirements.txt src/requirements.txt
run: cp requirements.txt src/requirements.txt

- name: Zip app
run: |
Expand All @@ -267,7 +311,7 @@ jobs:
echo "version=🌟${{ needs.version-info.outputs.version }}" >> $GITHUB_OUTPUT
echo "pre_release=false" >> $GITHUB_OUTPUT
fi

- name: Release
id: release
uses: softprops/action-gh-release@v1
Expand All @@ -281,18 +325,4 @@ jobs:
webui/dist.zip
backend/app-v${{ needs.version-info.outputs.version }}.zip
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}


telegram:
runs-on: ubuntu-latest
needs: [ release ]
steps:
- name: send telegram message on push
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
New release: ${{ needs.release.outputs.version }}
Link: ${{ needs.release.outputs.url }}
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ dev-dist
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
backend/.vscode/
backend/src/.vscode/
.DS_Store
*.suo
*.ntvs*
Expand All @@ -216,4 +218,4 @@ dev-dist

# test file
test.*
test_*
test_*
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ COPY --chmod=755 entrypoint.sh /entrypoint.sh
ENTRYPOINT ["tini", "-g", "--", "/entrypoint.sh"]

EXPOSE 7892
VOLUME [ "/app/config" , "/app/data" ]
VOLUME [ "/app/config" , "/app/data" ]
6 changes: 3 additions & 3 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
anyio==3.7.0
bencode.py ==4.0.0
bs4==0.0.1
certifi==2023.5.7
charset-normalizer==3.1.0
Expand All @@ -21,7 +22,6 @@ python-jose==3.3.0
passlib==1.7.4
bcrypt==4.0.1
python-multipart==0.0.6
sqlmodel==0.0.8
sqlmodel==0.0.22
sse-starlette==1.6.5
semver==3.0.1
openai==0.28.1
semver==3.0.1
16 changes: 11 additions & 5 deletions backend/src/main.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import logging
import os
from pathlib import Path

import uvicorn
from fastapi import FastAPI, Request
from fastapi.responses import FileResponse, HTMLResponse, RedirectResponse
from fastapi.responses import FileResponse, RedirectResponse
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
from module.api import v1
from module.api import lifespan, v1
from module.conf import VERSION, settings, setup_logger
from module.network import load_image

setup_logger(reset=True)
logger = logging.getLogger(__name__)
Expand All @@ -27,7 +29,7 @@


def create_app() -> FastAPI:
app = FastAPI()
app = FastAPI(lifespan=lifespan)

# mount routers
app.include_router(v1, prefix="/api")
Expand All @@ -39,8 +41,12 @@ def create_app() -> FastAPI:


@app.get("/posters/{path:path}", tags=["posters"])
def posters(path: str):
return FileResponse(f"data/posters/{path}")
async def posters(path: str):
# TODO: 由于只有取的时候才会下载,所以会导致第一次请求的时候没有图片
post_path = Path("data/posters") / path
if not post_path.exists():
await load_image(path)
return FileResponse(post_path)


if VERSION != "DEV_VERSION":
Expand Down
3 changes: 2 additions & 1 deletion backend/src/module/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
from .bangumi import router as bangumi_router
from .config import router as config_router
from .log import router as log_router
from .program import lifespan
from .program import router as program_router
from .rss import router as rss_router
from .search import router as search_router

__all__ = "v1"
__all__ = ["v1"]

# API 1.0
v1 = APIRouter(prefix="/v1")
Expand Down
26 changes: 23 additions & 3 deletions backend/src/module/api/auth.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
from datetime import timedelta

from fastapi import APIRouter, Depends, HTTPException, status
from fastapi import APIRouter, Depends
from fastapi.responses import JSONResponse, Response
from fastapi.security import OAuth2PasswordRequestForm

from module.models import APIResponse
from module.models import APIResponse, ResponseModel
from module.models.user import User, UserUpdate
from module.security.api import (
active_user,
auth_user,
get_current_user,
update_user_info,
)
from module.security.jwt import create_access_token
from module.security.jwt import create_access_token, verify_password

from .response import u_response

Expand All @@ -23,6 +23,26 @@
async def login(response: Response, form_data=Depends(OAuth2PasswordRequestForm)):
user = User(username=form_data.username, password=form_data.password)
resp = auth_user(user)
if not resp:
if not verify_password(user.password, resp.password):
resp = ResponseModel(
status_code=401,
status=False,
msg_en="Incorrect password",
msg_zh="密码错误",
)
else:
resp = ResponseModel(
status_code=401,
status=False,
msg_en="User not found",
msg_zh="用户不存在",
)
else:
resp = ResponseModel(
status_code=200, status=True, msg_en="Login successfully", msg_zh="登录成功"
)

if resp.status:
token = create_access_token(
data={"sub": user.username}, expires_delta=timedelta(days=1)
Expand Down
Loading