Feature 增加内置反代

This commit is contained in:
EstrellaXD
2023-04-26 10:48:09 +08:00
parent e6f1c5f292
commit e1923d47a5
5 changed files with 41 additions and 18 deletions

View File

@@ -6,22 +6,15 @@ services:
- TZ=Asia/Shanghai
- PGID=${GID}
- PUID=${UID}
- AB_INTERVAL_TIME=1800
- AB_DOWNLOADER_HOST=localhost:${QB_PORT}
- AB_DOWNLOADER_USERNAME=admin
- AB_DOWNLOADER_PASSWORD=adminadmin
- AB_METHOD=pn
- AB_GROUP_TAG=True
- AB_NOT_CONTAIN=720
- AB_DOWNLOAD_PATH=${DOWNLOAD_PATH}
- AB_RSS=${RSS}
- AB_DEBUG_MODE=False
- AB_EP_COMPLETE=False
- AB_SEASON_ONE=True
networks:
- auto_bangumi
ports:
- 7892:7892
- '7892:7892'
volumes:
- auto_bangumi:/config
dns:

View File

@@ -14,12 +14,12 @@ services:
- ${DOWNLOAD_PATH}:/downloads # 填入下载绝对路径
ports:
- ${QB_PORT}:${QB_PORT}
- 6881:6881
- 6881:6881/udp
- "6881:6881"
- "6881:6881/udp"
networks:
- auto_bangumi
restart: unless-stopped
image: lscr.io/linuxserver/qbittorrent:4.4.3
image: superng6/qbittorrent
auto_bangumi:
container_name: AutoBangumi
@@ -32,13 +32,11 @@ services:
- AB_DOWNLOADER_PASSWORD=adminadmin
- AB_DOWNLOAD_PATH=/downloads/Bangumi
- AB_RSS=${RSS}
volumes:
- auto_bangumi:/config
networks:
- /path/to/config:/app/config
- /path/to/data:/app/data
ports:
- 7892:7892
- '7892:7892'
dns:
- 8.8.8.8
- 223.5.5.5

View File

@@ -1,6 +1,6 @@
import logging
from fastapi import FastAPI
from fastapi.responses import FileResponse
from fastapi.responses import FileResponse, Response
from module.core import APIProcess
from module.conf import DATA_PATH, LOG_PATH, settings
@@ -67,3 +67,15 @@ async def get_config():
async def update_config(config: Config):
return api_func.update_config(config)
@router.get("/RSS/MyBangumi")
async def get_rss(token: str):
content = api_func.get_rss(token)
return Response(content, media_type="application/xml")
@router.get("/Download/{full_path:path}")
async def download(full_path: str):
torrent = api_func.get_torrent(full_path)
return Response(torrent, media_type="application/x-bittorrent")

View File

@@ -5,9 +5,10 @@ from module.core import DownloadClient
from module.manager import FullSeasonGet
from module.rss import RSSAnalyser
from module.utils import json_config
from module.conf import DATA_PATH
from module.conf import DATA_PATH, settings
from module.conf.config import save_config_to_file, CONFIG_PATH
from module.models import Config
from module.network import RequestContent
from module.ab_decorator import api_failed
@@ -82,3 +83,16 @@ class APIProcess:
@staticmethod
def get_config() -> dict:
return json_config.load(CONFIG_PATH)
@staticmethod
def get_rss(token: str):
url = f"https://mikanani.me/RSS/MyBangumi?token={token}"
with RequestContent() as request:
content = request.get_html(url)
return re.sub(r"mikanani.me", settings.rss_parser.custom_url, content)
@staticmethod
def get_torrent(full_path):
url = f"https://mikanani.me/Downloads/{full_path}"
with RequestContent() as request:
return request.get_content(url)

View File

@@ -38,8 +38,8 @@ class RequestContent(RequestURL):
enclosure = item.find("enclosure")
return TorrentInfo(item.title.string, enclosure["url"])
def get_xml(self, url):
return BeautifulSoup(self.get_url(url).text, "xml")
def get_xml(self, _url):
return BeautifulSoup(self.get_url(_url).text, "xml")
# API JSON
def get_json(self, _url) -> dict:
@@ -50,3 +50,9 @@ class RequestContent(RequestURL):
def post_data(self, _url, data: dict) -> dict:
return self.post_url(_url, data)
def get_html(self, _url):
return self.get_url(_url).text
def get_content(self, _url):
return self.get_url(_url).content