diff --git a/app/services/book_service.py b/app/services/book_service.py index 234b7ed..5400418 100644 --- a/app/services/book_service.py +++ b/app/services/book_service.py @@ -11,7 +11,7 @@ from app.models import Setting class BookService: ALLOWED_CONTENT_TYPES = ['"application/octet-stream"', "application/octet-stream", "text/plain", - "application/zip"] + "application/zip", "application/vnd.rar"] def __init__(self): setting_record = Setting.query.filter_by(name="book_download").first() @@ -103,10 +103,12 @@ class BookService: print(f'跳转页面了:{file_url}') response = self.session.get(file_url, headers={"referer": file_url}, stream=True) print(f"下载状态码:{response.status_code} {file_url}") + response.raise_for_status() print(dir_name + "/" + file_name) content_type = response.headers.get('Content-Type', '') if content_type not in self.ALLOWED_CONTENT_TYPES: yield f"event: mes_error\ndata: {self.setting['targetDate']} {file_name}\n\n" + print(content_type) print("不是可下载文件") return target_dir = self.download_path / self.setting["targetDate"] / dir_name / file_name