diff --git a/.dockerignore b/.dockerignore index c6f14b75..3d5cb7ed 100644 --- a/.dockerignore +++ b/.dockerignore @@ -29,4 +29,5 @@ config/bangumi.json/config/bangumi.json /.cache /LICENSE /README.md -/setup.py \ No newline at end of file +/setup.py +dist.zip \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 90211cf6..d25d4aad 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -14,7 +14,7 @@ jobs: uses: actions/checkout@v3 - name: Create Version info run: | - echo "version = '$GITHUB_REF_NAME'" > src/__version__.py + echo "version='$GITHUB_REF_NAME'" > module/conf/version.py - name: Docker meta id: meta uses: docker/metadata-action@v4 diff --git a/Dockerfile b/Dockerfile index 5d22bd2c..edb95e8d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1 -FROM python:3.10-buster AS build +FROM python:3.11-buster AS build RUN mkdir /install WORKDIR /install @@ -7,17 +7,17 @@ COPY requirements.txt . RUN python3 -m pip install --upgrade pip \ && pip install -r requirements.txt --prefix="/install" -FROM python:3.10-alpine +FROM python:3.11-alpine ENV TZ=Asia/Shanghai \ PUID=1000 \ PGID=1000 \ UMASK=022 -WORKDIR /src +WORKDIR /app COPY --from=build --chmod=777 /install /usr/local -COPY --chmod=755 module /src +COPY --chmod=755 . . RUN apk add --no-cache \ curl \ @@ -25,17 +25,21 @@ RUN apk add --no-cache \ su-exec \ bash +# Download WebUI +RUN wget https://github.com/Rewrite0/Auto_Bangumi_WebUI/releases/download/v1.0.4/dist.zip && \ + unzip dist.zip && \ + mv dist template + RUN addgroup -S auto_bangumi -g 1000 && \ adduser -S auto_bangumi -G auto_bangumi -h /home/auto_bangumi -u 1000 && \ usermod -s /bin/bash auto_bangumi && \ mkdir -p "/config" && \ chmod a+x \ run.sh \ - getWebUI.sh \ setID.sh EXPOSE 7892 -VOLUME [ "/config" ] +VOLUME [ "/config" , "/data"] CMD ["sh", "run.sh"] diff --git a/module/core/download_client.py b/module/core/download_client.py index 95aa2f4f..1b63e37e 100644 --- a/module/core/download_client.py +++ b/module/core/download_client.py @@ -80,11 +80,11 @@ class DownloadClient: status_filter="completed", category="Bangumi" ) - def rename_torrent_file(self, hash, path_name, new_name): + def rename_torrent_file(self, hash, new_file_name, old_path, new_path): self.client.torrents_rename_file( - torrent_hash=hash, old_path=path_name, new_path=new_name + torrent_hash=hash, new_file_name=new_file_name, old_path=old_path, new_path=new_path ) - logger.info(f"{path_name} >> {new_name}") + logger.info(f"{old_path} >> {new_path}, new name {new_file_name}") def delete_torrent(self, hashes): self.client.torrents_delete( diff --git a/module/core/renamer.py b/module/core/renamer.py index 1e9e61c4..98d5c2e3 100644 --- a/module/core/renamer.py +++ b/module/core/renamer.py @@ -65,7 +65,8 @@ class Renamer: try: new_name = self._renamer.download_parser(name, folder_name, season, suffix, settings.bangumi_manage.rename_method) if path_name != new_name: - self.client.rename_torrent_file(torrent_hash, path_name, new_name) + old_name = info.content_path.replace(info.save_path, "") + self.client.rename_torrent_file(torrent_hash, new_name, old_name, new_name) rename_count += 1 else: continue diff --git a/module/downloader/qb_downloader.py b/module/downloader/qb_downloader.py index 7e0d628c..b51b2e4a 100644 --- a/module/downloader/qb_downloader.py +++ b/module/downloader/qb_downloader.py @@ -56,8 +56,9 @@ class QbDownloader: torrent_hashes=hash ) - def torrents_rename_file(self, torrent_hash, old_path, new_path): - self._client.torrents_rename_file(torrent_hash=torrent_hash, old_path=old_path, new_path=new_path) + def torrents_rename_file(self, torrent_hash, new_file_name, old_path, new_path): + self._client.torrents_rename_file(torrent_hash=torrent_hash, new_file_name=new_file_name, + old_path=old_path, new_path=new_path) def get_rss_info(self): item = self._client.rss_items().get("Mikan_RSS") diff --git a/module/parser/analyser/raw_parser.py b/module/parser/analyser/raw_parser.py index b1b2132e..5c8d737f 100644 --- a/module/parser/analyser/raw_parser.py +++ b/module/parser/analyser/raw_parser.py @@ -65,8 +65,8 @@ class RawParser: name = re.sub(season_rule, "", name_season) for season in seasons: season_raw = season - if re.search(r"S|Season", season) is not None: - season = int(re.sub(r"S|Season", "", season)) + if re.search(r"Season|S", season) is not None: + season = int(re.sub(r"Season|S", "", season)) break elif re.search(r"[第 ].*[季期]", season) is not None: season_pro = re.sub(r"[第季期 ]", "", season) @@ -148,7 +148,7 @@ class RawParser: sub, dpi, source = self.find_tags(other) # 剩余信息处理 return name_en, name_zh, name_jp, season, season_raw, episode, sub, dpi, source, group - def analyse(self, raw: str) -> Episode or None: + def analyse(self, raw: str) -> Episode | None: try: ret = self.process(raw) if ret is None: